PHP+MySQL UPDATE query (multiple columns) not working -
ok, it's simple i'm overlooking, i've combed through many times..!
just simple update via php form, pulls in variables, builds query:
// connect $connect = mysql_connect('host','login','passwd'); if (!$connect) { $errors .= "not connected : ".mysql_error(); } $database = mysql_select_db('db', $connect); if (!$database) { $errors .= "could not database: ".mysql_error(); } // update database table $info = "update `gsa_officers` set `term` = '2012-2013', `office` = 'president', `type` = 'poop', `dept` = 'visual arts', `name` = 'matthew w. jarvis', `email` = 'president@gsa.ucsd.edu', `blurb` = 'serves chair of both gsa executive committee , council, oversees direction of organization , ensures execution of responsibilities , commitments.', `picture` = 'http://gsa.ucsd.edu/sites/gsa.ucsd.edu/files/mat%20w%20jarvis.jpg' `id` = 1"; $query = mysqli_query($info); if (!$query) { $errors .= "bad query: ".mysql_error(); } mysql_close($connect);
i no errors, prints out: "bad query: "
what missing/doing wrong? eyeballs appreciated ^_^
you're using mysql_connect()
connect database server , select db. use mysqli_query()
run query, mysql_error()
report error. can't mix these api's.
you should use mysqli_*
functions throughout, because mysql_*
functions deprecated , removed future version of php.
example:
// connect $mysqli = new mysqli('host','login','passwd','db'); if ($mysqli->connect_error) { $errors .= "not connected : ".$mysqli->connect_error; } // update database table $info = "update `gsa_officers` set `term` = '2012-2013', `office` = 'president', `type` = 'poop', `dept` = 'visual arts', `name` = 'matthew w. jarvis', `email` = 'president@gsa.ucsd.edu', `blurb` = 'serves chair of both gsa executive committee , council, oversees direction of organization , ensures execution of responsibilities , commitments.', `picture` = 'http://gsa.ucsd.edu/sites/gsa.ucsd.edu/files/mat%20w%20jarvis.jpg' `id` = 1"; if (!$mysqli->query($info)) { $errors .= "bad query: ".$mysqli->error; } $mysqli->close();
Comments
Post a Comment