Jump to content

multiple $query and $result on the same page


webguync

Recommended Posts

is it ok to use multiple $query and $result for different SQL statements?

 

for example:

 

$query = "SELECT username,pwid,name,user_id
           FROM   roster
           WHERE
           pwid = '$pwid'
           AND
           username='$username'";

   $result = mysql_query($query) or die(mysql_error());

 

and further down the page...

$query = "UPDATE roster
          SET login_timestamp = DATE_ADD(NOW(), INTERVAL 3 HOUR)
          WHERE username = '$username'
           AND pwid = '$pwid' ";
//echo $query; //for debugging test 
$result = mysql_query($query) or die(mysql_error()); 

 

 

...even further down the page


$query = "DELETE FROM log WHERE user_id = $user_id AND roster.user_id = $user_id";
//echo $query; //for debugging test 
$result = mysql_query($query) or die(mysql_error()); 

 

or would I need to change to $query1,$result1,$query2,$result2,$query3,$result3?

 

Link to comment
Share on other sites

You will need to use different $result variables. When you loop through your dataset (the select statement) and you issue an update/delete/select query it will override the initial $result variable.

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.