Page 1 of 1

PHP error

Posted: Thu Dec 09, 2010 12:57 am
by Fayaz_aaja
Hi Everyone,

Im new to php. I have written a code in php. While im running i got following error
Notice: Undefined index: movie_id in C:\wamp\www\Wamp_Test\movie_details.php on line 50
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


Error line code is

$query = "SELECT * FROM movie".
"WHERE movie_id =" . $_GET['movie_id'];
$result = mysql_query($query,$con) or die (mysql_error());

Pls anyone can help me on this.

Regards
Fayaz

Re: PHP error

Posted: Thu Dec 09, 2010 2:29 am
by social_experiment
Looks like the problem is with the quotation marks from here =" . $_GET['movie_id'];

Code: Select all

<?php $query = "SELECT * FROM movie 
WHERE movie_id = '". $_GET['id'] ."' "; ?>
Near the value of $_GET['id'] the quotation marks are as follows (im adding spaces between the quotation marks to illustrate): ' " . $_GET['id'] . " '

Re: PHP error

Posted: Thu Dec 09, 2010 3:07 am
by mikecampbell
Also when your query is concatenated together it is going to look like SELECT * FROM movieWHERE ... with no space between movie and WHERE.