tommy445 Posted April 20, 2009 Share Posted April 20, 2009 i am getting the error 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 'Resource id #1' at line 1 I am trying to update client_phone in db through a form input. <?php $con = mysql_connect("localhost","xxxxx","xxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("xxxxx", $con); mysql_query(" UPDATE site_clients SET client_phone = '".$_POST['client_phone']."' WHERE client_first_name= '".$_POST['$client_first_name']."'"); if (!mysql_query($con)) { die('Error: ' . mysql_error()); } mysql_close($con) ?> ***One note... Currently the client_phone in the db is blank. Not sure if this makes a difference. Please help. Thanks Link to comment https://forums.phpfreaks.com/topic/154825-having-trouble-updating-to-mysql/ Share on other sites More sharing options...
revraz Posted April 20, 2009 Share Posted April 20, 2009 Your error may be in another query. The error you get appears to be using a Resource Result as a variable instead of the data. Put your query into a variable and echo it to see if that is even the right query. Link to comment https://forums.phpfreaks.com/topic/154825-having-trouble-updating-to-mysql/#findComment-814483 Share on other sites More sharing options...
Mchl Posted April 20, 2009 Share Posted April 20, 2009 I think you should change if (!mysql_query($con)) to if (!mysql_query(" UPDATE site_clients SET client_phone = '".$_POST['client_phone']."' WHERE client_first_name= '".$_POST['$client_first_name']."'")) And remove this mysql_query(" UPDATE site_clients SET client_phone = '".$_POST['client_phone']."' WHERE client_first_name= '".$_POST['$client_first_name']."'"); Link to comment https://forums.phpfreaks.com/topic/154825-having-trouble-updating-to-mysql/#findComment-814520 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.