PDA

View Full Version : PHP/MYSQL Syntax question



zerosignal0
January 26th, 2005, 03:30 PM
hello,
Ok Im working on a php input script and need to use a mysql update statement so that records within a table can be updated but Im really having a hard time getting the server to except the statement. I am familiar with msql but in reguards to all the "quirky" sytax that you need to use between php and mysql Im running into problems. Heres and example of what Im trying to do if any of you can possibly help.



$insertSQL = sprintf("UPDATE authuser SET student_name, student_address, student_phone, student_ss, student_funding, student_agent, student_aproxcomp VALUES (%s, %s, %s, %s, %s, %s, %s) WHERE uname = 'student'",
GetSQLValueString($_POST['student'], "text"),
GetSQLValueString($_POST['course'], "text"),
GetSQLValueString($_POST['completion'], "text"),
GetSQLValueString($_POST['instructor'], "text"),
GetSQLValueString($_POST['whenbilled'], "text"),
GetSQLValueString($_POST['whenpaid'], "text"),
GetSQLValueString($_POST['grade'], "int"));

any help would be greatly appriciated!

Maniaci
January 26th, 2005, 08:44 PM
In an update sql string, you need field = value like so



$sql = "UPDATE authuser SET student_name = '$new_name', student_address = '$new_address', student_phone = '$new_phone', student_ss = '$new_ss', student_funding = '$new_funding', student_agent = '$new_agent', student_aproxcomp = '$new_aproxcomp' WHERE student = '$student'";

$result = mysql_query($sql);


You can either set the $new_var values before the sql statement, or do the $_POST[]'s inside the update sql. I hope this helps. I did not test it, so there could be sytax errors :worried:.