snallemap Posted September 23, 2010 Share Posted September 23, 2010 Hello Php freaks! I've been reading a bit tutorials, and i keep getting errors... even when i take their already done code it shows me errors... Now im wondering if Php have changed? or is it just my program or something that cannot run the php code as it is?.... $query = 'INSERT INTO news (author, title, news) VALUES('$author', '$title', '$news')"; Mysql_query($query) or die(mysql_error()); echo "Thank you for submitting!"; In that bit there shows up errors in the $query and in the echo... Also in other tutorials it happens, seems it totally random when it decide to say its a error :/ Quote Link to comment https://forums.phpfreaks.com/topic/214206-error-happens/ Share on other sites More sharing options...
Miss_Rebelx Posted September 23, 2010 Share Posted September 23, 2010 Well, for future reference, you should post the error code you are getting as well to help us help you figure out what's wrong. But in this case, where you set $query, you need to change that first single quote (') to a double quote ("). EDIT: Can anyone confirm is mysql_query() is case sensitive? (hense would Mysql_query() be acceptable as he has it posted?) Quote Link to comment https://forums.phpfreaks.com/topic/214206-error-happens/#findComment-1114585 Share on other sites More sharing options...
PFMaBiSmAd Posted September 23, 2010 Share Posted September 23, 2010 We can only help you with specific errors. If you want help with the code you posted above, you would need to post the error as well. A lot of the php information posted on the Internet is there solely to earn the site money though advertising/link clicking... Many don't care if the code they have posted on their site works or produces errors. There were a few fundamental changes in php around 8 years ago and a lot of the scripts posted around on the Internet have never been updated or removed. It is really sad when we see someone trying to get help in the forum because they found code that was so out of date. Quote Link to comment https://forums.phpfreaks.com/topic/214206-error-happens/#findComment-1114586 Share on other sites More sharing options...
Pikachu2000 Posted September 23, 2010 Share Posted September 23, 2010 You left out the most important part, the actual errors. Quote Link to comment https://forums.phpfreaks.com/topic/214206-error-happens/#findComment-1114587 Share on other sites More sharing options...
snallemap Posted September 23, 2010 Author Share Posted September 23, 2010 The errors were in that code.... <?php include "config.php"; $author = $_POST['author']; $title = $_POST['title']; $news = $_POST['news]; // insert the data into the databse $query = 'INSERT INTO news (author, title, news) VALUES('$author', '$title', '$news')"; Mysql_query($query) or die(mysql_error()); echo "Thank you for submitting!"; ?> There is the entire code... The errors lays in the "echo "Than you for submitting!" and another error lays in the query to insert stuff to the database. Quote Link to comment https://forums.phpfreaks.com/topic/214206-error-happens/#findComment-1114590 Share on other sites More sharing options...
Miss_Rebelx Posted September 23, 2010 Share Posted September 23, 2010 I appreciate your telepathic abilities, snallemap, but I don't have them. If you want specific help (and if my post above wasn't the correct answer to this problem) then you need to post the error MESSAGE that PHP gives you. Not your interpretation of it. Quote Link to comment https://forums.phpfreaks.com/topic/214206-error-happens/#findComment-1114593 Share on other sites More sharing options...
Pikachu2000 Posted September 23, 2010 Share Posted September 23, 2010 Yeah, we get it, there are errors. Now paste the actual errors in if you expect anyone to be able to help. Quote Link to comment https://forums.phpfreaks.com/topic/214206-error-happens/#findComment-1114595 Share on other sites More sharing options...
ignace Posted September 23, 2010 Share Posted September 23, 2010 Well, for future reference, you should post the error code you are getting as well to help us help you figure out what's wrong. But in this case, where you set $query, you need to change that first single quote (') to a double quote ("). EDIT: Can anyone confirm is mysql_query() is case sensitive? (hense would Mysql_query() be acceptable as he has it posted?) PHP is case-insensitive when it comes to classes, methods, and functions. Also constants if you pass TRUE as a third parameter to define(). Quote Link to comment https://forums.phpfreaks.com/topic/214206-error-happens/#findComment-1114670 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.