Removed by Administrator
I have been working on PHP script, and was working through some problems over at the PHP group. However, I believe my problem now boils down to a MySQL problem. The script takes PHP variables and reads them into a MySQL database. Here is tthe relevant part of the script: $query='INSERT INTO review_registration() VALUES($FName, $LName, $Company, $Title, $Address, $Apt, $City, $State, $Zip, $Phone, $Fax, $Email, $Var1l, $Var2, $Var3, $Var4, $Var5)' The error message is: Query failed: Unknown column '$FName' in 'field list' The table exists, and the varibles are correct. If I put quotation marks around each variable inside VALUES, ...
I have been working on PHP script, and was working through some
problems over at the PHP group. However, I believe my problem now boils
down to a MySQL problem. The script takes PHP variables and reads them
into a MySQL database. Here is tthe relevant part of the script:
$query='INSERT INTO review_registration() VALUES($FName, $LName,
$Company, $Title, $Address, $Apt, $City, $State, $Zip, $Phone, $Fax,
$Email, $Var1l, $Var2, $Var3, $Var4, $Var5)'
The error message is:
Query failed: Unknown column '$FName' in 'field list'
The table exists, and the varibles are correct. If I put quotation
marks around each variable inside VALUES, it will actually write the
variable name into the database. $FName for instance, instead of the
data that $FName references. However, this demonstrates that the
database connection is being made, the table is being found, and data
can be written to it. I am running MySQL 4.0.1.
The thing that sticks out at me is that $FName is not a column name,
but I don't know why the system thinks that it is. I tried defining the
columns in review_registration() but I got the same error message. Any
help will be greatly appreciated.
Removed by Administrator
Jerim79 wrote:
Try this:
$query="INSERT INTO `review_registration` VALUES('$FName', '$LName',
'$Company', '$Title', '$Address', '$Apt', '$City', '$State', '$Zip',
'$Phone', '$Fax',
'$Email', '$Var1l', '$Var2', '$Var3', '$Var4', '$Var5');";
com says...
The PHP Pr will not attempt to p strings encapsulated in single
quotes.
Use double-quotes instead, or escape+concatenate the variables.
$query="INSERT INTO review_registration() VALUES($FName, $LName,
$Company, $Title, $Address, $Apt, $City, $State, $Zip, $Phone, $Fax,
$Email, $Var1l, $Var2, $Var3, $Var4, $Var5)";
or
$query='INSERT INTO review_registration() VALUES('.$FName.', '.$LName.',
'.$Company.', '.$Title.', '.$Address.', '.$Apt.', '.$City.', '.$State.',
'.$Zip.', '.$Phone.', '.$Fax.', '.$Email.', '.$Var1l.', '.$Var2.', '.
$Var3.', '.$Var4.', '.$Var5.')';
Geoff M
Jerim79 wrote:
The error is a PHP error.
Expand your error message:
<?php
// ...
$res = mysql_query($query);
if (!$res) {
# die('Query failed: ' . mysql_error()); // simple version
die('Query failed: ' . mysql_error() .
' The SQL statement was: ' . $query); // expanded version
}
--
I (almost) never check the dodgeit address.
If you *really* need to mail me, use the address in the Reply-To
header with a message in *plain* *text* *without* *attachments*.
Pedro Graca wrote:
>
> The error is a PHP error.
> Expand your error message:
>
> <?php
> // ...
> $res = mysql_query($query);
> if (!$res) {
> # die('Query failed: ' . mysql_error()); // simple version
> die('Query failed: ' . mysql_error() .
> ' The SQL statement was: ' . $query); // expanded version
> }
>
>
> --
> I (almost) never check the dodgeit address.
> If you *really* need to mail me, use the address in the Reply-To
> header with a message in *plain* *text* *without* *attachments*.[/ref]
It is working now. The double quotes was the fix. Thanks for all the
help. (I still have the p the phone numbers to get them to enter
right.)
Bookmarks