English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hi

Problem:
http://localhost/www.website.com/new.php?id="180"
returns error as follows:
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 '\"180\"' at line 1


This works!:
http://localhost/www.website.com/new.php?id=180

Thing is i dont know ho to chnage my code to get rid of the double quotes!

On iis :http://localhost/www.website.com/new.php?id="180"
works fine, but on apache it doesnt!


whay is this?
What shall i do?




index.php:
print "id\">$row->title";



new.php:
include("db/db_config.php");

{
$id = $_GET["id"];
$sql = "SELECT * FROM articles WHERE id = $id";
}

// $sql = "SELECT id,datetime,title,author,body,author_box FROM t4d.articles WHERE id = $_GET["id"] LIMIT 1";
$rs = mysql_query($sql) or die(mysql_error());


Thanks in advance

Tovia Singer

2007-12-10 03:53:31 · 5 answers · asked by jam 5 in Computers & Internet Programming & Design

5 answers

print ''.$row->title..

2007-12-10 04:04:53 · answer #1 · answered by daa 7 · 0 0

without the quotes should work for both and that is the convention.. it is assumed that everything from the = to either & or the end of the URL is a string and will be interpreted by php as such

if you do need to get rid of the quotes you can do: str_replace('"", '', $id);
however it would be better to change the url not the code

2007-12-10 11:57:01 · answer #2 · answered by Brady 3 · 0 0

9 out of 10 cats prefer Whiskers

2007-12-10 11:57:27 · answer #3 · answered by Anonymous · 1 1

The dirty way:
$sql = str_replace('"','',$sql);

A better way is to fix all your links

2007-12-10 12:14:16 · answer #4 · answered by fretless 4 · 0 0

try harder

1 out of ten cats doesn't like whiskers

2007-12-10 11:57:42 · answer #5 · answered by dave has run away _|_ 2 · 0 0

fedest.com, questions and answers