Re: Cant set info in DB...HELP

From: Date: Sun, 03 Jun 2007 10:36:14 +0000
Subject: Re: Cant set info in DB...HELP
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-256024@lists.php.net to get a copy of this message
On 6/3/07, Stut <stuttle@gmail.com> wrote:
K. Hayes wrote: What "lists" are you referring to? Also this is how the examples show I've seen. I mean hit "Reply to all" in your mail client. That way you include the email address of the PHP General mailing list so everyone, including the archives, can see your reply. I know this is basic general stuff but I try many times before posting, and I have followed all directions given. Change the following line... mysqli_query($connection,$sql_query); ?> to... mysqli_query($connection,$sql_query)
    or die("Query failed: ".mysqli_error($connection);
you're missing a ) here, it should be: mysqli_query($connection,$sql_query) or die("Query failed: ".mysqli_error($connection)) Tijnema
If you still get no output, check error_reporting and display_errors in your php.ini file to make sure you are seeing at least errors and warnings. -Stut ===========================END NEW CODE===================================== ----- Original Message ----- From: "Stut" <stuttle@gmail.com> To: "K.Hayes" <k3cheese@insightbb.com> Cc: "php-general" <php-general@lists.php.net> Sent: Saturday, June 02, 2007 9:52 PM Subject: Re: [PHP] Cant set info in DB...HELP
Please include the list on all replies. K.Hayes wrote:
I don't know if I'm escaping the 'vars correctly'. If I'm wrong can you give me an example?
<snip>
$sql_query = "INSERT INTO contestants (conName, conAddress, conCity, conState, conZip, conPhone, schName, schAddress, schCity, schState, schZip, strName, strCity, strState) VALUES('$regName', '$regAddress', '$regCity', '$regState', '$regZip', '$regPhone', '$sclName', '$sclName', '$sclCity', 'sclState', '$sclZip', '$stoName', '$stoCity', '$stoState')"; $insert_query = mysqli_real_escape_string($connection, $sql_query); mysqli_query($connection,$insert_query); ?>
No, this is not the right way. I suggest you read the manual page on mysqli_real_escape_string (http://php.net/mysqli_real_escape_string). You need to run it on every variable you are using *in* the SQL query, not on the SQL query itself. Google for a php mysqli tutorial - all this stuff is very basic and should be covered by most tutorials you'll find. -Stut


« previous php.general (#256024) next »