Re: PHP and MySQL

From: Date: Wed, 11 Dec 2002 20:42:08 +0000
Subject: Re: PHP and MySQL
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-127896@lists.php.net to get a copy of this message
Numerous syntax errors produce your invalid query... 1) If you use double quotes to enclose the string, "INSERT..., then you do not have to delimit your single quotes. 2) You accidently delimit a variable at VALUES ('\$select 3) The SQL command its self does not need to end with a semi-colon. Fixed string.. $sql = "INSERT INTO guest (title, first_name, last_name, login, password, passport_number, e_mail, question, answer, industry, job_title, state, city, company, last_visit) VALUES ('$select', '$f_name', '$l_name', '$login', '$password', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NOW())"; -Kevin ----- Original Message ----- From: "Pushpinder Singh Garcha" <pgarcha@adelphia.net> To: <php-general@lists.php.net> Sent: Wednesday, December 11, 2002 1:30 PM Subject: [PHP] PHP and MySQL Hello, I am using PHP to create forms and then am entering the user input into a MySQL DB In the first query I am trying to select the values that the user entered on the form THIS DOES NOT WERK.... gives error unable to execute query $sql = "INSERT INTO guest (title, first_name, last_name, login, password, passport_number, e_mail, question, answer, industry, job_title, state, city, company, last_visit) VALUES ('\$select\', \'$f_name\', \'$l_name\', \'$login\', \'$password\', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NOW());"; WHEN I TRY TO HARD CODE THE VALUES INTO THE MYSQL QUERY, IT WERKS FINE // $sql = 'INSERT INTO guest (title, first_name, last_name, login, password, passport_number, e_mail, question, answer, industry, job_title, state, city, company, last_visit) VALUES (\'gh\', \'ghdfghhgj\', \'hgddj\', \'ggfgfg\', \'hfgdj\', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NOW());'; Can somebody please tell me where I am going wrong..?? Many thanks Pushpinder Singh Garcha _________________________________ Web Architect T. Falcon Napier and Associates, Inc.

« previous php.general (#127896) next »