Jump to content

Quick Diagnosis


aznjay

Recommended Posts

$msg = $_POST['message'];
$date = $_POST['date'];
$time = $_POST['time'];
$head = $_POST['title'];
$descri = $_POST['desp'];
$whbase = $_POST['base'];

$query = "INSERT INTO '$whbase' (title, time, date, desp, article) VALUES ('$head', '$time', '$date', '$descri', '$msg')";
mysql_query($query) or die('Error, insert query failed');

 

Is there something wrong with this?

Link to comment
Share on other sites

This is what i got '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 ''' (title, time, date, desp, article) VALUES ('', '', '', '', '')' at line 1'

 

I don't know how to fix it

Link to comment
Share on other sites


<?
include 'database.php';
$msg = $_POST['message'];
$date = $_POST['date'];
$time = $_POST['time'];
$head = $_POST['title'];
$descri = $_POST['desp'];
$whbase = $_POST['base'];

$query = "INSERT INTO "'$whbase'" (title, time, date, desp, article) VALUES ('$head', '$time', '$date', '$descri', '$msg')";
mysql_query($query) or die(mysql_error());

?>



Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/jayjay/public_html/phpentrytut.php on line 10

 

 

That is what i got...can somebody fix this please..i'm a noob..

Link to comment
Share on other sites

but backticks around your field names, because ones like date and time are mysql functions.

 

INSERT INTO $whbase (`title`, `time`, `date`, `desp`, `article`) VALUES ('$head', '$time', '$date', '$descri', '$msg')

 

 

THERE is no problem with that I can gaurantee you that..the one i'm having problem to is the $whbase

Link to comment
Share on other sites

but backticks around your field names, because ones like date and time are mysql functions.

 

INSERT INTO $whbase (`title`, `time`, `date`, `desp`, `article`) VALUES ('$head', '$time', '$date', '$descri', '$msg')

 

 

THERE is no problem with that I can gaurantee you that..the one i'm having problem to is the $whbase

 

I guarantee you.

do

$query = "INSERT INTO $whbase (`title`, `time`, `date`, `desp`, `article`) VALUES ('$head', '$time', '$date', '$descri', '$msg')";

Link to comment
Share on other sites

From that error, I can see that you did not do

 

$query = "INSERT INTO $whbase (`title`, `time`, `date`, `desp`, `article`) VALUES ('$head', '$time', '$date', '$descri', '$msg')";

 

;)

 

let me explain, you must remove the quotes from the database because that's not good syntax. You must put backticks around the time and date fields because they are mysql functions (DATE() AND TIME()) and they confuse the parser. The other backticks are for consistency.

Link to comment
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.