Jump to content

[SOLVED] Using two variables in an insert command


dark_destroyer

Recommended Posts

Hi All,

 

Im trying to do something pretty simple but i cant seem to get it to work, i want to update a field in a table where and ID number is for example "1009", i use a HTML form to allow the user to type in what they want to update, the user myst type in the ID number and then the message that they want to store.

 

It then calls the php page that has the mysql commands in it but it does not seem to connect and upate the table.  Here is the code that I am using:

 

     echo ID ;
     echo $_REQUEST["ID"] . " was updated.";
     $_ID = $_REQUEST["ID"];
     
     echo $_REQUEST["Actions"];
     $_Actions = $_REQUEST["Actions"];

     
     mysql_connect("localhost", "root","somepassword") or die(mysql_error());
     mysql_select_db("task_logging") or die(mysql_error());

     $query="UPDATE in_progress SET steps_taken = '$_Actions' wbere ID = '$_ID'";
     $result=mysql_query($query);
mysql_close();

I have tried giving the request different names, i.e $_REQUEST1 and $_REQUEST2 but that does not seem to work, can anyone see what I am doing wrong?  Thanks

 

Link to comment
Share on other sites

but it does not seem to connect and upate the table. 

 

can you explain this

 

does it connect or does your connection script throw an error??

does it select the database or does it throw an error?

you have the "or die" statement on the above two mysql statements so why not on your query?

 

try this

$query="UPDATE in_progress SET steps_taken = '$_Actions' wbere ID = '$_ID'";
$result=mysql_query($query)or die ("Error in the query" .mysql_error());

 

does this throw an error, if so what is it?

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.