Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 23rd, 2008, 01:33 AM
Registered User
 
Join Date: Apr 2008
Location: Peshawar, N.W.F.P, Pakistan.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default php


When I running this programme to retrieve the data from table,
its gives me this type of error in browser window, given below .


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 '>1990 ORDER BY movie_type' at line 1.



Please tell me about its solution.

Thank You.

This is the programme given below.

<?php
$connect=mysql_connect("localhost","root","asimpc" )
or die("Hey loser,check your server connection.");
mysql_select_db("moviesite");


$query="SELECT movie_name,movie_type ".
       "FROM MOVIE".
       "WHERE movie_year>1990 ".
       "ORDER BY movie_type ";
$results=mysql_query($query)
or die(mysql_error());


while($row=mysql_fetch_array($results))
{
extract($row);
echo $movie_name;
echo " - ";
echo $movie_type;
echo "<br>";
}
?>





Reply With Quote
  #2 (permalink)  
Old May 13th, 2008, 09:16 AM
Friend of Wrox
Points: 1,515, Level: 15
Points: 1,515, Level: 15 Points: 1,515, Level: 15 Points: 1,515, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2003
Location: Oxford, , United Kingdom.
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

A quick hint on debugging sql problems is to print your sql statement. It would have helped here ;)

Code:
$query="SELECT  movie_name,movie_type ".
       "FROM MOVIE".
       "WHERE movie_year>1990 ".
       "ORDER BY movie_type ";
echo $query;
Gives us:
Code:
SELECT  movie_name,movie_type FROM MOVIEWHERE movie_year>1990 ORDER BY movie_type
See the missing space? So, try:
Code:
$query="SELECT  movie_name,movie_type ".
       "FROM MOVIE ". // <-- extra space here
       "WHERE movie_year>1990 ".
       "ORDER BY movie_type ";
echo $query;
And we get:
Code:
SELECT  movie_name,movie_type FROM MOVIE WHERE movie_year>1990 ORDER BY movie_type
HTH
Charlie

--
Charlie Harvey's website - linux, perl, java, anarchism and punk rock: http://charlieharvey.org.uk
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Beg. PHP 5 > Ch. 11 - fetch_field.php crater BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 0 January 2nd, 2007 12:20 PM
PHP Warning: PHP Startup: Unable to load dynamic l surendran Beginning PHP 1 May 29th, 2006 08:49 AM
begin php & mysql - chapter 12, user_form.php jon_stubber Beginning PHP 1 March 9th, 2006 10:57 AM
Error: movie.php & commit.php on p182-186, ch6 willburke BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 October 12th, 2004 02:48 PM
Ch. 1: PHP Installation Troubles: php3 vs php manjito BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 4 June 12th, 2003 03:59 PM



All times are GMT -4. The time now is 09:00 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.