Kovo Posted February 19, 2007 Share Posted February 19, 2007 I want a specific query that will go to the specified name and display its corresponding data on the page, the table looks like this: (beta, so dummy text) So I want my particular page to display the 'data' of gg for example.I tried this, but I know im so wrong: <?phpinclude ('config.php'); MYSQL_CONNECT("localhost","$mysql_u","$mysql_p"); mysql_select_db("$mysql_db"); $query = "SELECT data WHERE name LIKE gg";$result = mysql_query($query);while($row = mysql_fetch_assoc($result)) { $data = $row['data'] ; echo ("$data"); } MYSQL_CLOSE();?> any ideas? Link to comment Share on other sites More sharing options...
pulpfiction Posted February 19, 2007 Share Posted February 19, 2007 Guess its the $query, You dont have to user LIKE, its better to use "=" if you know the "name" for sure..... $query = "SELECT data WHERE name = 'gg' "; Link to comment Share on other sites More sharing options...
Kovo Posted February 19, 2007 Author Share Posted February 19, 2007 Guess its the $query, You dont have to user LIKE, its better to use "=" if you know the "name" for sure..... $query = "SELECT data WHERE name = 'gg' ";thanks, but it still seems to disagree wtih meWarning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /mnt/w0300/d41/s44/b02877b8/www/kovo.ca/kp/documents2.php on line 13 Link to comment Share on other sites More sharing options...
pulpfiction Posted February 19, 2007 Share Posted February 19, 2007 im so sorry, missed the table name completly..... it should be $query = "SELECT data FROM tblname WHERE name LIKE 'gg' "; Link to comment Share on other sites More sharing options...
Kovo Posted February 19, 2007 Author Share Posted February 19, 2007 im so sorry, we missed the table name completly..... it should be $query = "SELECT data FROM tblname WHERE name LIKE 'gg' ";Again, thank you for your time and paitence, but yet still, i recieve the same error. Odd no? Do I need that fetch assoc line? Link to comment Share on other sites More sharing options...
pulpfiction Posted February 19, 2007 Share Posted February 19, 2007 There are few changes needed..... one in the echo statement in the while loop.... while($row = mysql_fetch_assoc($result)) { $data = $row['data']; echo ("$data"); }change it towhile($row = mysql_fetch_assoc($result)) { echo $row['data']; }check this link, it should help.....http://us2.php.net/mysql_fetch_assoc Link to comment Share on other sites More sharing options...
Kovo Posted February 19, 2007 Author Share Posted February 19, 2007 There are few changes needed..... one in the echo statement in the while loop.... while($row = mysql_fetch_assoc($result)) { $data = $row['data']; echo ("$data"); }change it towhile($row = mysql_fetch_assoc($result)) { echo $row['data']; }check this link, it should help.....http://us2.php.net/mysql_fetch_assoc alas, to no avail, but its ok, thanks for ur help neway, ill try and figure this one out Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now