Jump to content

Recommended Posts

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 :/

Link to comment
https://forums.phpfreaks.com/topic/214206-error-happens/
Share on other sites

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?)

Link to comment
https://forums.phpfreaks.com/topic/214206-error-happens/#findComment-1114585
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/214206-error-happens/#findComment-1114586
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/214206-error-happens/#findComment-1114590
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/214206-error-happens/#findComment-1114593
Share on other sites

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().

Link to comment
https://forums.phpfreaks.com/topic/214206-error-happens/#findComment-1114670
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.