Jump to content

turning sql into a query


Shadowing

Recommended Posts

having a problem turning this sql into a query and I need it to only update rows where id field is empty.

 

 UPDATE systems SET naqahdah = naqahdah + naqahdah_mines * 2 

 

I tried this out with failure

 <?php mysql_query("UPDATE systems SET naqahdah= naqahdah + naqahdah_mines * 2 WHERE id <> ' ' "); ?> 

 

so i tried getting rid of WHERE and couldnt even get this to work. I tested the sql out it works fine.

 

 <?php mysql_query("UPDATE systems SET naqahdah= naqahdah + naqahdah_mines * 2 "); ?> 

Link to comment
https://forums.phpfreaks.com/topic/254389-turning-sql-into-a-query/
Share on other sites

yah my termnology is nothing short but noob like.

Im getting hit with a syntax issue. unexpected T_STRING

so i guess my problem is how do I turn this SQL statement into a workable string?

 

 UPDATE systems SET naqahdah = naqahdah + naqahdah_mines * 2 

 

updates all naqahdah columns and adds the naqahdah column value plus  naqahdah_mines column * 2 only in rows where id isnt empty. I use dial up so googling is extremly time consusming but so far i think i need () in the math im trying to do here

 

 <?php mysql_query("UPDATE systems SET naqahdah= naqahdah + naqahdah_mines * 2 WHERE id <> ' ' "); ?> 

 

 

 

 

 

The error you are receiving is a PHP error, not mysql. There is nothing in the code you have provided that would produce that error. PHP will tell you where is halted because of the error, you will often find that the error however occurs a a few lines prior to where PHP halted.

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.