Shadowing Posted January 5, 2012 Share Posted January 5, 2012 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 "); ?> Quote Link to comment https://forums.phpfreaks.com/topic/254389-turning-sql-into-a-query/ Share on other sites More sharing options...
trq Posted January 5, 2012 Share Posted January 5, 2012 having a problem turning this sql into a query Sorry, but that makes no sense. Queries are SQL. Now, why not tell us what the actual issue is. Quote Link to comment https://forums.phpfreaks.com/topic/254389-turning-sql-into-a-query/#findComment-1304411 Share on other sites More sharing options...
Shadowing Posted January 5, 2012 Author Share Posted January 5, 2012 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 <> ' ' "); ?> Quote Link to comment https://forums.phpfreaks.com/topic/254389-turning-sql-into-a-query/#findComment-1304416 Share on other sites More sharing options...
trq Posted January 5, 2012 Share Posted January 5, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/254389-turning-sql-into-a-query/#findComment-1304418 Share on other sites More sharing options...
Shadowing Posted January 5, 2012 Author Share Posted January 5, 2012 Thanks thorpe huge help. I found the error was missing a simi colon and () lol on a variable string its all working now. Quote Link to comment https://forums.phpfreaks.com/topic/254389-turning-sql-into-a-query/#findComment-1304420 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.