Jump to content

Recommended Posts

Hi,

 

I have a need to clear down a field in a table prior to re-filling it with new values. If in the PHP page I clear it down and then immediatley run the query to fill in the values I find that the first query hasn\'t finished in time and therefore wipes out new values.

 

The cose is:

	$query = "update LOW_PRIORITY " . $selDim . " set limitint = null;";

$result = mysql_query($query) or die($selDim . " Update (set to NULL) failed");



$i=0;

while ($_GET["selChosen"][$i] != "")

{

  $query= "update " . $selDim . " set limitint = " . $i .

 " where dimvalue = \'" . $_GET["selChosen"][$i] . "\'";

  $result = mysql_query($query) or die($selDim . " Update (set limitint) failed");



  $i++;

}



 

$selDim is the table name.

 

The Values are based on a multiple selection box and I use the value that I place in the field for ordering purposes.

 

Can anyone tell me what I amdoing wrong - or is there a way of putting an appropriate if-then clause in the MySQL?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/512-mysql-walking-over-itself/
Share on other sites

If you think the second query executes before the first query finishes, then its better to have an if condition into which you can have the second query. Like

 

$a = 0;

$query = \"do something\";

if ($result = mysql_query($query, $connection)) {

 

$a = 1;

 

}

 

if ($a = \'1\'\') {

 

****** Your Second Query Goes Here ***********

 

}

 

Hope this helps

:wink:

Link to comment
https://forums.phpfreaks.com/topic/512-mysql-walking-over-itself/#findComment-1752
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.