Hi, I've been tearing my hair out over this problem! <?php //Server, configure for incoming data //Connect to DB $hostname = "localhost"; $mysql_login = "brum_***"; $mysql_password = "***"; $database = "brum_***"; // connect to the database server if (!($db = mysql_pconnect($hostname, $mysql_login , $mysql_password))){ die( "Can't connect to database server." ); }else{ // select a database if (!(mysql_select_db("$database",$db))){ die( "Can't connect to database." ); } } //Get information in cookies from the client $client_name = $_REQUEST['name']; $client_name_hashed = hash(md5, $client_name); //Get person's number of zombies from DB $search = "SELECT * FROM 'data' WHERE 'name_hashed' = $client_name_hashed"; while($info = mysql_fetch_array( $search )){ $server_name = $info['name']; $server_name_hashed = $info['name_hashed']; $zombies = $info['zombies']; } ECHO $server_name; ECHO "<br>".$server_name_hashed; ECHO "<br>".$zombies; //Below is debugging ECHO mysql_error(); $debug = "INSERT INTO data (name, name_hashed, zombies) VALUES ('sam', '2832893237d2dew', '100')"; mysql_query($debug); ?> PHP: I get the error: $debug works fine and writes to the DB, but this "while.." string doesn't work. If anyone has any ideas I'd be more than grateful. Thanks, Lee.
you could try running the search first, this will give u a resource to use $search = "SELECT * FROM 'data' WHERE 'name_hashed' = $client_name_hashed"; //TO $search =mysql_query("SELECT * FROM 'data' WHERE 'name_hashed' = $client_name_hashed"); PHP:
Thanks for your help. I feel like I'm getting a little bit closer, but I still get the error, and a new one too:
SELECT * FROM 'data' WHERE 'name_hashed' = $client_name_hashed //TO SELECT * FROM 'data' WHERE name_hashed = '$client_name_hashed' PHP: Have moved the single quotes from the field to the value
It should be: $search = mysql_query ("SELECT * FROM `data` WHERE `name_hashed` = '$client_name_hashed' "); Code (markup): Notice the use of backticks (optional) and single quotes (not optional).