Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts

    Whiles not working!

    The whiles are not outputing any data and i have the data in my MySQL DB! Please take a look! Oh, and i have error reporting on!

    PHP Code:
    <?php
    $dizzle 
    $_GET['q'];
    $connect  = @mysql_connect("localhost","root","root") or die("Could not connect to database!");
    $db          = @mysql_select_db("sptxbx");
    $query 'SELECT * FROM `news` WHERE * LIKE \'%' $dizzle '%\'';  
    $mksql     =@mysql_query($query);
    $fet    =@mysql_fetch_array($mksql);
    ?>

    <?php
    $dizzle1 
    $_GET['q'];
    $connect1  = @mysql_connect("localhost","root","root") or die("Could not connect to database!");
    $db1          = @mysql_select_db("sptxbx");
    $query1 'SELECT * FROM `games` WHERE * LIKE \'%' $dizzle1 '%\'';  
    $mksql1     =@mysql_query($query1);
    $fet1    =@mysql_fetch_array($mksql1);
    ?>

    <?php
    $dizzle2 
    $_GET['q'];
    $connect2  = @mysql_connect("localhost","root","root") or die("Could not connect to database!");
    $db2          = @mysql_select_db("sptxbx");
    $query2 'SELECT * FROM `reviews` WHERE * LIKE \'%' $dizzle2 '%\'';  
    $mksql2     =@mysql_query($query2);
    $fet2    =@mysql_fetch_array($mksql2);
    ?>

    <div align="center">
    <table width="410" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>News Results:</td>
      </tr>
      <?php while($fet    =@mysql_fetch_array($mksql)) { ?>
      <tr>
        <td><a href="newsitem.php?id=<?php $fet['id']; ?>"><?php echo $fet['title']; ?></a></td>
      </tr>
      <?php ?>
    </table>
    <br />
    <table width="410" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>Games Results:</td>
      </tr>
      <?php while($fet1    =@mysql_fetch_array($mksql1)) { ?>
      <tr>
        <td><a href="viewgame.php?id=<?php $fet1['id']; ?>"><?php echo $fet1['name']; ?></a></td>
      </tr>
      <?php ?>
    </table>
    <br />
    <table width="410" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>Reviews Results:</td>
      </tr>
      <?php while($fet2    =@mysql_fetch_array($mksql2)) { ?>
      <tr>
        <td><a href="viewreview.php?id=<?php $fet2['id']; ?>"><?php echo $fet2['title']; ?></a></td>
      </tr>
      <?php ?>
    </table>
    </div>

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Too bad you're not checking your queries for errors.... too bad.

  • #3
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts
    oh yeah i still have the @ in there sorry for my mistake!!!

  • #4
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts
    What could i use instead of mysql_fetch_array() could i use the mysql_querey() ?

  • #5
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts
    or mysql_fetch_assoc() ?????

  • #6
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    try it and see

  • #7
    Regular Coder
    Join Date
    Apr 2007
    Posts
    295
    Thanks
    0
    Thanked 19 Times in 19 Posts
    Take out all those @'s and you'll have a much easier time debugging

  • #8
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    Quote Originally Posted by the-dream View Post
    oh yeah i still have the @ in there sorry for my mistake!!!
    i think he took them out already

  • #9
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts
    i have tryed all of them but it come up with the same error:


    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /Applications/MAMP/htdocs/sptxbx_des/searchres.php on line 104


    PLEASE GIVE ME SOME HELP!!!!!!!!!!!!!!!!!

  • #10
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Ok i have seen the error: 'SELECT * FROM `games` WHERE * LIKE \'%' . $dizzle1 . '%\'' to 'SELECT * FROM `games` WHERE name, des LIKE \'%' . $dizzle1 . '%\'' !!!


    But i still get that not valid result resource!

  • #11
    Regular Coder
    Join Date
    Apr 2007
    Posts
    295
    Thanks
    0
    Thanked 19 Times in 19 Posts
    Try changing your queries to this and see if you're getting errors
    PHP Code:
    mysql_query($query) OR die(mysql_error()); 

  • #12
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts
    i cannot see my syntax error! I get this error!


    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' des LIKE '%test%'' at line 1

  • #13
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts
    done it!!!

    Working Code:
    PHP Code:
    <?php
    $dizzle 
    $_GET['q'];
    $connect  mysql_connect("localhost","root","root") or die("Could not connect to database!");
    $db          mysql_select_db("sptxbx");
    $query 'SELECT * FROM `news` WHERE title LIKE \'%' $dizzle '%\'';  
    $mksql     =mysql_query($query) or die(mysql_error());  ;
    $fet    =mysql_fetch_array($mksql);
    ?>

    <?php
    $dizzle1 
    $_GET['q'];
    $connect1  mysql_connect("localhost","root","root") or die("Could not connect to database!");
    $db1          mysql_select_db("sptxbx");
    $query1 'SELECT * FROM `games` WHERE name LIKE \'%' $dizzle1 '%\'';  
    $mksql1     =mysql_query($query1) or die(mysql_error());  ;
    $fet1    =mysql_fetch_array($mksql1);
    ?>

    <?php
    $dizzle2 
    $_GET['q'];
    $connect2  mysql_connect("localhost","root","root") or die("Could not connect to database!");
    $db2          mysql_select_db("sptxbx");
    $query2 'SELECT * FROM `reviews` WHERE title LIKE \'%' $dizzle2 '%\'';  
    $mksql2     =mysql_query($query2) or die(mysql_error());  ;
    $fet2    =mysql_fetch_array($mksql2);
    ?>

    <div align="center">
    <table width="410" border="0" cellspacing="0" cellpadding="5">
      <tr>
        <td bgcolor="#99CC00"><div align="center" class="style8 style7 style9">News Results:</div></td>
      </tr>
      <?php while($fet    =mysql_fetch_array($mksql)) { ?>
      <tr>
        <td bgcolor="#CCCCCC"><a href="newsitem.php?id=<?php $fet['id']; ?>" class="style7"><?php echo $fet['title']; ?></a></td>
      </tr>
      <?php ?>
    </table>
    <br />
    <table width="410" border="0" cellspacing="0" cellpadding="5">
      <tr>
        <td bgcolor="#99CC00" class="style9"><div align="center" class="style8">Games Results:</div></td>
      </tr>
      <?php while($fet1    =mysql_fetch_array($mksql1)) { ?>
      <tr>
        <td bgcolor="#CCCCCC" class="style9"><a href="viewgame.php?id=<?php $fet1['id']; ?>" class="style7"><?php echo $fet1['name']; ?></a></td>
      </tr>
      <?php ?>
    </table>
    <br />
    <table width="410" border="0" cellspacing="0" cellpadding="5">
      <tr>
        <td bgcolor="#99CC00"><div align="center" class="style8">Reviews Results:</div></td>
      </tr>
      <?php while($fet2    =mysql_fetch_array($mksql2)) { ?>
      <tr>
        <td bgcolor="#CCCCCC"><a href="viewreview.php?id=<?php $fet2['id']; ?>" class="style7"><?php echo $fet2['title']; ?></a></td>
      </tr>
      <?php ?>
    </table>
    </div>

    <?php
        mysql_free_result
    ($mksql);
        
    mysql_free_result($mksql1);
        
    mysql_free_result($mksql2);
    ?>

  • #14
    Regular Coder
    Join Date
    Apr 2007
    Posts
    295
    Thanks
    0
    Thanked 19 Times in 19 Posts
    Good to hear

    Just to let you know, you don't have to reconnect and reselect your database every time you want to query something (as long as you're using the same database), you can just connect once and select your database once, then query as many times as you'd like

  • #15
    bla
    bla is offline
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try
    <?
    while($row = mysql_fetch_array($yourSqlQuery)) {
    $id = $row["id"];
    }
    ?>
    Get rid of all your $fet variables this screwing up your php. this is created as a row automatically as above.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •