finalmen Posted June 1, 2009 Share Posted June 1, 2009 Good evening, I'am working on this script on which i want to be able to update a certain amount of variables. $kwerie="UPDATE main_catagory SET keyword='$keyword'AND keyword2='$keyword2'AND keyword3='$keyword3' AND description='$description' AND name='$name' AND age='$age'AND picture='$picture'AND priority='$priority' AND alttext='$alttext' WHERE 'id' = $id "; mysql_query($kwerie); Is the code im using, the variables are coming true perfectly, although, it doesn't seem to insert it into the database....? Any help is welcome, breaking my head over this for hours now. Best Regards, Finalmen Link to comment https://forums.phpfreaks.com/topic/160513-solved-sqlphp-update-not-working/ Share on other sites More sharing options...
lonewolf217 Posted June 1, 2009 Share Posted June 1, 2009 mysql_query($kwerie) or die(mysql_error()); there's a problem with your SQL statement. when doing an update, you dont put 'AND' between the statements you are updating, just use a comma delimiter between them <?php $kwerie="UPDATE main_catagory SET keyword='$keyword', keyword2='$keyword2', keyword3='$keyword3', description='$description', name='$name', age='$age', picture='$picture', priority='$priority', alttext='$alttext' WHERE 'id' = $id "; The last suggestion someone else can confirm for me, but you may want to enclose all of your variables in the SQL statement with {} Link to comment https://forums.phpfreaks.com/topic/160513-solved-sqlphp-update-not-working/#findComment-847118 Share on other sites More sharing options...
finalmen Posted June 1, 2009 Author Share Posted June 1, 2009 Wow, That I dident think about that before! Its working now. Awesome , thanks for your really fast response. May I ask why you would add {} around variables? As in, what use would it have? Best Regards, Finalmen Link to comment https://forums.phpfreaks.com/topic/160513-solved-sqlphp-update-not-working/#findComment-847122 Share on other sites More sharing options...
lonewolf217 Posted June 1, 2009 Share Posted June 1, 2009 no idea but as long as this is working for you now that is what counts. dont forget to mark the topic solved! Link to comment https://forums.phpfreaks.com/topic/160513-solved-sqlphp-update-not-working/#findComment-847123 Share on other sites More sharing options...
Ken2k7 Posted June 1, 2009 Share Posted June 1, 2009 The curly braces, when used with variable interpolation, is to disambiguate a variable with other characters around it. Like an array lookup. <?php $e = "here is some static text and here's an {$array['lookup']}"; If you have $array['lookup'] with now curly braces, it can be a bit ambiguous whether you want to look up the variable $array or together as a whole. One can treat "['lookup']" as a string rather as part of an array lookup index key. This is the same for method calls like - <?php $e = "here is some static text and here is a {$method->call()}"; Again, it's a bit ambiguous if you want to evaluate the variable $method or $method->call() as a whole. Imagine you want something like - <?php $n = 42; $e = "here is some static text and here is the {$n}nd character of this string"; Without the curly braces there, it's ambiguous right? $nnd and {$n}nd is different as you can see the huge difference it would make. Hope this clears it up. By the way, you don't need the curly braces in your SQL. Link to comment https://forums.phpfreaks.com/topic/160513-solved-sqlphp-update-not-working/#findComment-847135 Share on other sites More sharing options...
lonewolf217 Posted June 1, 2009 Share Posted June 1, 2009 see, i knew someone would have the answer Link to comment https://forums.phpfreaks.com/topic/160513-solved-sqlphp-update-not-working/#findComment-847136 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.