RE: [PHP] SQL Error
| From: | Jason Bouwmeester | Date: | Sat, 04 Nov 2000 03:50:05 +0000 |
| Subject: | RE: [PHP] SQL Error | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-23677@lists.php.net to get a copy of this message | ||
Yeah it was - the title of the movie had a ' in it, I did a print"$Title"
and it returned "Movie\'s Name" - how can I get it so the ' is added to the
string and placed in the DB?
jb
-----Original Message-----
From: Frank M. Kromann
To: Jason Bouwmeester
Cc: 'php-general@lists.php.net'
Sent: 11/3/00 8:25 PM
Subject: Re: [PHP] SQL Error
Add som debug information to your script.
print "$query<br>";
just before odbc_exec().
You might have a single quote in one of the columns.
- Frank
>W2K, SQL Server 7, PHP4.
>
>I had this working then I changed one field and I don't know what I did
>wrong but now I get this error:
>
>Warning: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Line
1:
>Incorrect syntax near 's'., SQL state 37000 in SQLExecDirect in D:\Live
>Sites\www.bloodykisses.com\phptest\moviedb_add.php on line 28
>
>My function starting from Line 20 reads:
>
>20 function
>add_to_database($Title,$Year,$Synopsis,$Also_titled,$Sequel1,$Sequel2,$
Actor
>1,$Actor2,$Actor3,$Actor4,$Actor5,$Actor6,$Director,$Length,$Personal_r
ating
>,$dberror){
>21 // connect to a DSN called bkcontent
>22 $db=odbc_pconnect("bkcontent","user","password");
>23 if(!$db){
>24 $dberror="Couldn't connect to SQL server";
>25 return false;
>26 }
>27 $query="INSERT INTO movies
>(Title,Year,Synopsis,Also_titled,Sequel1,Sequel2,Actor1,Actor2,Actor3,A
ctor4
>,Actor5,Actor6,Director,Length,Personal_rating)
>values('$Title','$Year','$Synopsis','$Also_titled','$Sequel1','$Sequel2
','$A
>ctor1','$Actor2','$Actor3','$Actor4','$Actor5','$Actor6','$Director','$
Lengt
>h','$Personal_rating')";
>28 $result=odbc_exec($db,$query);
>29 return true;
>30 }
>
>Does anyone know what is causing this error?
>
>TIA,
>jb
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
>For additional commands, e-mail: php-general-help@lists.php.net
>To contact the list administrators, e-mail:
php-list-admin@lists.php.net
>
>
>