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
https://forums.phpfreaks.com/topic/124275-quick-diagnosis/
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
https://forums.phpfreaks.com/topic/124275-quick-diagnosis/#findComment-641741
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
https://forums.phpfreaks.com/topic/124275-quick-diagnosis/#findComment-641744
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
https://forums.phpfreaks.com/topic/124275-quick-diagnosis/#findComment-641745
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
https://forums.phpfreaks.com/topic/124275-quick-diagnosis/#findComment-641749
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.