Re: INSERT Won't Insert
| From: | Gremlins Mailing List | Date: | Wed, 01 Aug 2001 18:50:16 +0000 |
| Subject: | Re: INSERT Won't Insert | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-10968@lists.php.net to get a copy of this message | ||
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 <sf@mnetsys.com>
To: <php-db@lists.php.net>
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: php-db-unsubscribe@lists.php.net
> For additional commands, e-mail: php-db-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>