Re: [PHP-DB] INSERT Won't Insert

2001-08-01 Thread Gremlins Mailing List

Steve

I believe you're missing the closing bracket ) after $Website.

I think it's clearer if you use single quotes (') rather than double quotes
and then having to escape them.

Something like:

"INSERT INTO $table_name
 (CompanyID, CompanyName, Address, City, StateorProvince,
PostalCode,Region,Country,WebSite)
 VALUES ('',
 '$CompanyName',
 '$Address',
 '$City',
 '$StateorProvince',
 '$PostalCode',
 '$Region',
 '$Country',
 '$WebSite')";

regards
--
Jason Wong
Gremlins Associates

- Original Message -
From: Steve Fitzgerald <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 02, 2001 2:35 AM
Subject: [PHP-DB] INSERT Won't Insert


> This should be a simple insert. I must be missing something because I keep
> getting: Couldn't execute query.
>
> What am I missing?
>
>  error_reporting(15);
>
> $db_name = "dbname";
> $table_name="company";
> $connection = @mysql_connect("servname","username", "password")or die
> ("Couldn't connect.");
>
> $db = @mysql_select_db($db_name, $connection) or die ("Couldn't select
> database.");
>
> $add_co_sql = "INSERT INTO $table_name
> (CompanyID, CompanyName, Address, City, StateorProvince,
> PostalCode,Region,Country,WebSite)
> VALUES
> (\"\",
>
\"$CompanyName\",\"$Address\",\"$City\",\"$StateorProvince\",\"$PostalCode\"
> ,\"$Region\",\"$Country\",\"$WebSite\"
> ";
>
> $result = @mysql_query($add_co_sql, $connection) or die ("Couldn't execute
> query.");
> ?>
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] INSERT Won't Insert

2001-08-01 Thread Craig Vincent

If you simplify the query you'll see your error...all those escaped " were
giving me a headache hehe


*modified*
$add_co_sql = "INSERT INTO $table_name
(CompanyID, CompanyName, Address, City, StateorProvince,
PostalCode,Region,Country,WebSite)VALUES
('','$CompanyName','$Address','$City','$StateorProvince','$PostalCode','$Reg
ion','$Country','$WebSite'";


If you're still missing it, you're missing a ) after '$WebSite'

Sincerely,

Craig Vincent


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]