Having Difficulties With Pg_query(); In Php
Currently I am using Postgres with PHP. I'm writing an interface where a user can fill in a user, so it gets added to the total record of users in the database. (Very simple). Rece
Solution 1:
Use pg_query_params() to handle escaping and avoid SQL injection:
$query = pg_query_params(
$dbconnection,
'INSERT INTO clients(clientid, name, ipaddress,status) VALUES ($1, $2, $3, $4);', // placeholders
array($clientid, $name, $ipaddress, $status) // content
);
Solution 2:
Try this
$query = pg_query($dbconnection,
"INSERT INTO clients(clientid, name, ipaddress,status) VALUES ('$clientid', '$name', '$ipaddress', '$status' ");
Solution 3:
$query = pg_query($dbconnection, "INSERT INTO clients(clientid, name, ipaddress,status) VALUES ('$clientid', '$name', '$ipaddress', '$status')");
should do the work. Note no quotes around the field names and the closing parenthesis after the VALUES.
Post a Comment for "Having Difficulties With Pg_query(); In Php"