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
PHP error
Moderator: General Moderators
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: PHP error
Looks like the problem is with the quotation marks from here =" . $_GET['movie_id'];
Near the value of $_GET['id'] the quotation marks are as follows (im adding spaces between the quotation marks to illustrate): ' " . $_GET['id'] . " '
Code: Select all
<?php $query = "SELECT * FROM movie
WHERE movie_id = '". $_GET['id'] ."' "; ?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
-
mikecampbell
- Forum Commoner
- Posts: 38
- Joined: Tue Oct 12, 2010 7:26 pm
Re: PHP error
Also when your query is concatenated together it is going to look like SELECT * FROM movieWHERE ... with no space between movie and WHERE.