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

 

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?

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.