Jump to content

Recommended Posts

this is what i have but i cant figure whats not working
[code]
<?php
ob_start();
include("config.php");
?>
[/code]
heres the config.php
[code]
<?php
  ob_start();
  $conn = mysql_connect("localhost","user","pass");
  mysql_select_db(database) or die(mysql_error());
  $logged = MYSQL_QUERY("SELECT * from users WHERE id='$_COOKIE[id]' AND password = '$_COOKIE[pass]'");
  $logged = mysql_fetch_array($logged);
?>
[/code]

heres the rest of the page

[code]
<?php
echo("
<center>
<form method=\"POST\">
Title:<br>
<input type=\"text\" size=\"25\" maxlength=\"50\" name=\"title\"><br>
By:<br>
<input type=\"text\" size=\"25\" maxlength=\"50\" name=\"by\"><br>
Message:<br>
<textarea cols=\"50\" rows=\"5\" name=\"message\" >test</textarea><br>
<input type=\"submit\" value=\"Submit\" name=\"submit\">
</form>
</center>
");
if ($_POST[submit]) {
$title = $_POST[title];
$by = $_POST[by];
$message = $_POST[message];
if ($title==NULL|$by==NULL|$message==NULL) {
echo("You left a space blank!");
}else{
$newtime = time();
$time = gmdate("Y-m-d H:i:s", $newtime);
$query = mysql_query("INSERT INTO `news` (title, by, on, message) VALUES('$title','$by','$time','$message')");
}
}
?>
[/code]

the query is prob goin to be spaced because its long
but i know its like 4 in the mourning but the faster the better

Link to comment
https://forums.phpfreaks.com/topic/14457-need-help/
Share on other sites

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 'by,on,message) VALUES('fg','fg','20060713100640','test')' at li

still happens and i even fixed the time so there is no spaces

and brown there doesnt need the be ' there cuz i have used that b4
Link to comment
https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57203
Share on other sites

What happens if you leave out the part (id, title, by, on, message) ?

[code]
$query = <<<SQL
    INSERT INTO news
    VALUES ('', '$title', '$by', '$time', '$message')
SQL;
[/code]

Your query is propably giving this error because your SQL interpreter sees the 'by' - column as a standard keyword used in other query syntaxes. (Aswell the 'on' - column will be giving the same error). Would be the same if your table would look like:

[code]
$query = <<<SQL
    INSERT INTO news (INSERT, GRANT, SELECT, ...)
    VALUES ('aaa', 'bbb', 'ccc', ...)
SQL;
[/code]
Link to comment
https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57210
Share on other sites

Change this line:
[code]<?php
$query = mysql_query("INSERT INTO `news` (title, by, on, message) VALUES('$title','$by','$time','$message')");
?>[/code]
to
[code]<?php
$q ="INSERT INTO `news` (`title`, `by`, `on`, `message`) VALUES('$title','$by','$time','$message')"
$query = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error());
?>[/code]

Ken
Link to comment
https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57368
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.