| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Senior Member Join Date: May 2005 Location: Ontario Canada
Posts: 3,088
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Query error Hey i am getting a querry error from this line: PHP Code: ????: NamePros.com http://www.namepros.com/programming/275776-query-error.html 1. If there is any visible problem in that piece of code 2. How can i make it show the actual error instead of the die command that i gave it..if i remove that die command..it shows nothing..
__________________ |
| |
| | THREAD STARTER #3 (permalink) |
| Senior Member Join Date: May 2005 Location: Ontario Canada
Posts: 3,088
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | hm it is like that..i duno y it added that space when i copy pasted it here :-s $query = "INSERT INTO mpg ('id','Manufacturer','Year','Car Name','Miles Per Gallon City', 'Miles Per Gallon Freeway','Year Gas Price') VALUES ('','$manufacturer','$year','$car_name','$mpgc','$ mpgf','$year_gas_price')"; mysql_query($query) or die ("Error, insert query failed");
__________________ |
| |
| | #4 (permalink) |
| is on hiatus Join Date: May 2006
Posts: 2,453
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | mysql_query("INSERT INTO mpg ('id','Manufacturer','Year','Car Name','Miles Per Gallon City', 'Miles Per Gallon Freeway','Year Gas Price') VALUES ('','$manufacturer','$year','$car_name','$mpgc','$ mpgf','$year_gas_price'")or die ("Error, insert query failed");
__________________ Currently on hiatus. Back whenever. |
| |
| | #6 (permalink) |
| Buy my domains. Join Date: Feb 2006
Posts: 2,796
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | It's the same thing.. >__> Run the query in phpMyAdmin and post the error it gives you. I don't see anything that would just be wrong on its own, unless you can't have spaces in the column titles. The only other thing I see is ' around column names.. shouldn't it be ` or nothing? If you used spaces between items, it wouldn't put that space in by itself into $mpgf |
| |
| | #7 (permalink) |
| Senior Member Join Date: Dec 2006 Location: England
Posts: 1,568
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Always added error reporting to every query, this will gve you a more descriptive error as Dan said phpmyadmin will. Run this: PHP Code: The problem is (i suspect) that you are not using backticks for field names, instead you are using '. ????: NamePros.com http://www.namepros.com/showthread.php?t=275776 Correct query should be: Code: INSERT INTO `mpg` (`id`,`Manufacturer`,`Year`,`Car Name`,`Miles Per Gallon City`,
`Miles Per Gallon Freeway`,`Year Gas Price`)
VALUES ('','$manufacturer','$year','$car_name','$mpgc','$ mpgf','$year_gas_price')
Last edited by Matthew.; 01-02-2007 at 05:15 AM.
|
| |
| | #8 (permalink) | ||||
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,069
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
PHP Code: PHP Code: ????: NamePros.com http://www.namepros.com/showthread.php?t=275776 EDIT Looks like Matthew. just beat me
Last edited by filth@flexiwebhost; 01-02-2007 at 05:10 AM.
| ||||
| |
| | #9 (permalink) | ||||||||
| Senior Member Join Date: Dec 2006 Location: England
Posts: 1,568
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
(having said that i normally extend my error logger into the mysql class so they do get hidden) | ||||||||
| |
| | #10 (permalink) |
| Ultima Ratio Regum Join Date: Sep 2003 Location: Up North
Posts: 2,082
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Edit: *remider to self: Alway refresh before posting* Someone beat me to it..
__________________ IP Whois + Geolocation|Geolocate your IP|Dynamic Forum Sigs <meta name="Jedi Mind Trick" content="Buy my domains, you will!"> |
| |