PHP Newby Posted November 22, 2006 Share Posted November 22, 2006 I'm a bit new to PHP and I have a question. It might be a little hard to answer but, here it is.This is the snipet I'm having problems with:[code]CODE $name = $_POST['name']; $price = $_POST['price']; $item = $_POST['item']; $date = $_POST['date']; $query = "INSERT INTO `secondlifetrans` ( `Name` , `Item` , `Price` , `Date` )VALUES ('$name', '$item', '$price', '$date');";[/code]This, for some reason, outputs empty strings into the sql database, but I'm sure all the variables are completly defined. Any help, anyone? Link to comment https://forums.phpfreaks.com/topic/28041-question/ Share on other sites More sharing options...
hitman6003 Posted November 22, 2006 Share Posted November 22, 2006 The manual states:[quote]The query string should not end with a semicolon.[/quote]http://www.php.net/mysql_query#AEN116010 Link to comment https://forums.phpfreaks.com/topic/28041-question/#findComment-128295 Share on other sites More sharing options...
jawapro Posted November 22, 2006 Share Posted November 22, 2006 Comment out the SQL part and echo:$name $price$item $date to make sure you are actually getting the values from the previous script.-------Modify-------Not really sure that the semi-colon causes the problem. I know it isnt needed - but I didnt think it killed it either. Link to comment https://forums.phpfreaks.com/topic/28041-question/#findComment-128297 Share on other sites More sharing options...
PHP Newby Posted November 22, 2006 Author Share Posted November 22, 2006 Okay thanks very much. If I come across further problems I will reply this thread. Link to comment https://forums.phpfreaks.com/topic/28041-question/#findComment-128301 Share on other sites More sharing options...
jawapro Posted November 22, 2006 Share Posted November 22, 2006 Did it fix the problem? Link to comment https://forums.phpfreaks.com/topic/28041-question/#findComment-128343 Share on other sites More sharing options...
trq Posted November 22, 2006 Share Posted November 22, 2006 [quote]The query string should not end with a semicolon.[/quote]Why would the manual say that? Ending an SQL query with a semicolon is perfectly valid SQL. The php manual should stick to php. Link to comment https://forums.phpfreaks.com/topic/28041-question/#findComment-128368 Share on other sites More sharing options...
jawapro Posted November 22, 2006 Share Posted November 22, 2006 It says that because when you run SQL from PHP it ADDS a semi-colon at the end.So you'd end up with ;;.But I dont think it kills it - its just not necessary Link to comment https://forums.phpfreaks.com/topic/28041-question/#findComment-128375 Share on other sites More sharing options...
PHP Newby Posted November 22, 2006 Author Share Posted November 22, 2006 No, It did not fix the problem. Well, changing everything to $_GET worked, but it outputs everything into one column now.... Link to comment https://forums.phpfreaks.com/topic/28041-question/#findComment-128548 Share on other sites More sharing options...
jawapro Posted November 23, 2006 Share Posted November 23, 2006 If you were using GET to post the variables and using POST to read them it wouldnt have worked.When you say it outputs everything into one column what do you mean?JP Link to comment https://forums.phpfreaks.com/topic/28041-question/#findComment-128874 Share on other sites More sharing options...
ataria Posted November 23, 2006 Share Posted November 23, 2006 How is the page set up? Link to comment https://forums.phpfreaks.com/topic/28041-question/#findComment-128880 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.