Jump to content

Query was empty


bscyb

Recommended Posts

Not quite

if(!$result)
{
echo 'error';
}
else
{
    // check that a record was deleted
    if(mysql_affected_rows() == 1)
    {
        echo 'Query deleted the record ' . $tID . ' successfully';
    }
    // record was not deleted
    else
    {
        echo 'The query did not delete the record' . $tID;
    }
}

 

if(mysql_query($result,$conn)){

        echo "$i  encountered an error.<br/>";

  } else {

        echo "$i successfully inserted.<br/>";

      }

That does need even relate to the OP's code.

all he is trying to do is get a good message when it has deleted not if it has deleted he knows its deleting it.

So swapping the error message around would make a false positive a positive false.

He did not say he wanted to know if it has deleted anything from the mysql just to get a good message when the right id is used.

As he knows the rows are being deleted.

 

if(mysql_query($result,$conn)){

        echo "$i  encountered an error.<br/>";

  } else {

        echo "$i successfully inserted.<br/>";

      }

 

So what you're saying is that if the query executes without error, display an error message, and if the query fails to execute, display a success message? That's what that code does.

 

A syntactically correct DELETE query with a non-existent id will execute successfully. The only way to tell if the query had the intended result of actually deleting a record is with mysql_affected_rows().

Not quite

if(!$result)
{
echo 'error';
}
else
{
    // check that a record was deleted
    if(mysql_affected_rows() == 1)
    {
        echo 'Query deleted the record ' . $tID . ' successfully';
    }
    // record was not deleted
    else
    {
        echo 'The query did not delete the record' . $tID;
    }
}

 

if(mysql_query($result,$conn)){

        echo "$i  encountered an error.<br/>";

  } else {

        echo "$i successfully inserted.<br/>";

      }

That does need even relate to the OP's code.

 

ok this code fixed it all now i get the correct message

when the record is deleted i get Query deleted the record

and if the record is not deleted i get The query did not delete the record

thanks allot

works for me

if it looking at the false is correct but the code works then the error message is wrong

so swapping them round would give the opposite effect yes ?

 

As the CODE WORKS

 

A return of FALSE is not the correct result. FALSE means the query entirely failed to execute due to a syntax or other error, and the query could not possibly have deleted anything at all.

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.