Jump to content

PHP variable in mysql UPDATE statement?


neocamel

Recommended Posts

Hello all.

Hope I'm in the right section, this is my first post here!

 

I'm having syntax problems.  I'm basically trying to use a php variable to define the table in a mysql UPDATE statement.  Anyone know how to accomplish this?  I tried something like...

$whatclient=mysql_real_escape_string($_POST['theclient']);
$sql="UPDATE $whichclient SET name = '$name' , email = '$email'";

 

basically "theclient" is the result of the user choosing a drop down option, I'll name the tables after the drop down choices' values. 

 

Thanks so much in advance for the help!

 

Link to comment
Share on other sites

Oh my apoligies, thats a typo.  Let me correct.

$whichclient=mysql_real_escape_string($_POST['theclient']);
$sql="UPDATE $whichclient SET name = '$name' , email = '$email'";

 

Sorry about that, I'm on hour 5 of this project and am burning out!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.