Jump to content

having trouble updating to mysql


tommy445

Recommended Posts

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

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']."'");

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.