View Single Post
  #2 (permalink)  
Old 2005-07-21, 07:32 AM
Antyrael Antyrael is offline
Junior Member
 
Join Date: Jul 2005
Posts: 2
Antyrael
Default

I'm not sure if this isthe cause of your problem, but it seems to me you used the wrong quotes in your MySQL query.
I would do it like this:

Code:
$link_id = mysql_connect ($dbhost, $dbusername, $dbuserpass);
mysql_select_db("$dbname", $link_id);
$username = "Testfirst12";
$result = mysql_query('SELECT * WHERE first_name = ' . $username . ' FROM address_book', $link_id); 
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row
echo $row['first_name']." - ".$row['last_name']. "<br />";
} 
mysql_close($link_id);
Another option is to not concatenate at all, like this:
Code:
$result = mysql_query("SELECT * WHERE first_name = '$username' FROM address_book", $link_id);
Since you're using double quotes inside your query, you don't need to do the " . $username . " part.
Reply With Quote