Just changed from hosting company, now code not working
Posted: Tue Mar 20, 2007 11:55 am
Hi all, this is my first post and fairly new to PHP.
Im migrating my applications to another hosting provider, already have my website running, so connections to the DB are working OK. But it seems that certain code is not comfortable with, but at the same time, works ok on my actual server:
URL--> http://www.mysite.com/list.php?idc=6
The result is the following message:
SELECT name, picture FROM categories WHERE id_category=Error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
It seems that is an issue with the quotes (single/double), because the result is not displaying the value of the variable idc. Both servers (actual and new) share the same configuration:
Apache 2.0
PHP 4.3.9
mySQL 4.1.20
I tried to search the forum and Google and it seems that some people write the code like this:
$sql="SELECT name, picture FROM categories WHERE id_category='$idc' ";
Any idea?, maybe a setting that I dont know?. Sorry if this is a dumb question
Thx
Leo
Im migrating my applications to another hosting provider, already have my website running, so connections to the DB are working OK. But it seems that certain code is not comfortable with, but at the same time, works ok on my actual server:
URL--> http://www.mysite.com/list.php?idc=6
Code: Select all
<?
$conn= @mysql_connect("localhost","$user","$pwd");
$db= mysql_select_db($db_name,$conn) or die("Cant connect.");
$sql="SELECT name, picture FROM categories WHERE id_category=$idc";
print $sql;
$result=mysql_query($sql,$conn) or die ('Error '.mysql_error());
?>SELECT name, picture FROM categories WHERE id_category=Error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
It seems that is an issue with the quotes (single/double), because the result is not displaying the value of the variable idc. Both servers (actual and new) share the same configuration:
Apache 2.0
PHP 4.3.9
mySQL 4.1.20
I tried to search the forum and Google and it seems that some people write the code like this:
$sql="SELECT name, picture FROM categories WHERE id_category='$idc' ";
Any idea?, maybe a setting that I dont know?. Sorry if this is a dumb question
Thx
Leo