PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
hei i have this if command and its not working. the error is: server version for the right syntax to use near 'WHERE projnr='8888' AND customernr='88.88.'' at line 1
But: customernr='".$_POST['customernr']."
is right- isnt it???
The whole code is:
I usually echo the $sql statement variable together in die() function, makes troubleshooting a lot easier. Why don't you try that and copy and paste the executed SQL statement here?
hai
i found the problem ... i have another if/update command before this one in the script, and if i take that one out it is working. it also has this in it:
$sql = "UPDATE sam_date_val SET tovalue=$tovalue WHERE projnr='".$_POST['projnr']."' AND customernr='".$_POST['customernr']."'";
mysql_query ( $sql ) or die ( 'MySQL-Fehler: ' . mysql_error () );
So could that be the problem ????
I mean it has to be because when i delete it - it is working!!!
NO still same error: server version for the right syntax to use near 'WHERE projnr='8888' AND customernr='88.88.'' at line 120
(line 120 is the second update command)
Why is it a problem to use it a second time ???
I mean it doesnt say anything about the first update!
You'll need to see what the actual string of the SQL statement contains in order to suss the error, which you are on track to doing.
But another very vital point about your use of SQL and $_POST .. you are so, so open to SQL Injection attacks, please read up on PHP+MySQL security. (For example, take a look at the mysql_real_escape_string() function)
Yes. As SQL injection can be accidental as well as deliberate. (if any of your $_POST values contain an apostrophe for example, your script will break)
so do you have any suggestions???
or do you have a good url or tutorial???
and the script is finally working ... hbut still one thing i need to know.
if i updatet like this:
$sql = "UPDATE sam_date_val SET tovalue=tovalue+$tovalue WHERE (projnr='$projnr' AND customernr='$customernr' AND contrdate='$contrdate')";
mysql_query ( $sql ) or die ( 'MySQL-Fehler: ' . mysql_error () );
And now i want to save the value again (sam_date_val.tovalue).
How can i get this new Value so i can save it like
$newsamtoval=......;