PHP error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Fayaz_aaja
Forum Newbie
Posts: 1
Joined: Thu Dec 09, 2010 12:50 am

PHP error

Post 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
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: PHP error

Post 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'] . " '
“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

Post 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.
Post Reply