BillyBoB Posted July 13, 2006 Share Posted July 13, 2006 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]<?phpecho("<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 longbut i know its like 4 in the mourning but the faster the better Quote Link to comment https://forums.phpfreaks.com/topic/14457-need-help/ Share on other sites More sharing options...
GingerRobot Posted July 13, 2006 Share Posted July 13, 2006 Well what happens?And also, you might wanna edit out your database username and password. Quote Link to comment https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57177 Share on other sites More sharing options...
brown2005 Posted July 13, 2006 Share Posted July 13, 2006 dont know if it matters but u have Submit as the value in the form and if ($_POST[submit])try changing if ($_POST[submit]) to if ($_POST[Submit]) Quote Link to comment https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57178 Share on other sites More sharing options...
BillyBoB Posted July 13, 2006 Author Share Posted July 13, 2006 im goin to edit but the Value=\"Submit\" is the text that shows up on the button Quote Link to comment https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57182 Share on other sites More sharing options...
BillyBoB Posted July 13, 2006 Author Share Posted July 13, 2006 nothing happens thats the prob i need the data to go to the database but it doesnt Quote Link to comment https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57183 Share on other sites More sharing options...
GingerRobot Posted July 13, 2006 Share Posted July 13, 2006 Add an or die statement:$query = mysql_query("INSERT INTO `news` (title, by, on, message) VALUES('$title','$by','$time','$message')") or die(mysql_error());So we can see if that is the problem. Quote Link to comment https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57185 Share on other sites More sharing options...
BillyBoB Posted July 13, 2006 Author Share Posted July 13, 2006 heres the errorYou 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('omga','moga','2006-07-13 09:49:23','te Quote Link to comment https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57190 Share on other sites More sharing options...
BillyBoB Posted July 13, 2006 Author Share Posted July 13, 2006 does it matter if i have MySQL version 4.0.25-standard ? Quote Link to comment https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57192 Share on other sites More sharing options...
BillyBoB Posted July 13, 2006 Author Share Posted July 13, 2006 ne 1? Quote Link to comment https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57197 Share on other sites More sharing options...
brown2005 Posted July 13, 2006 Share Posted July 13, 2006 i dunno... Quote Link to comment https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57198 Share on other sites More sharing options...
BillyBoB Posted July 13, 2006 Author Share Posted July 13, 2006 robot can u figure this out Quote Link to comment https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57199 Share on other sites More sharing options...
GingerRobot Posted July 13, 2006 Share Posted July 13, 2006 Im unsure if you are allowed spaces inside this part:(title, by, on, message)try:(title,by,on,message) Quote Link to comment https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57201 Share on other sites More sharing options...
brown2005 Posted July 13, 2006 Share Posted July 13, 2006 maybe someone can tell me,include("config.php"); does it need to be include('config.php'); Quote Link to comment https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57202 Share on other sites More sharing options...
BillyBoB Posted July 13, 2006 Author Share Posted July 13, 2006 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 listill happens and i even fixed the time so there is no spacesand brown there doesnt need the be ' there cuz i have used that b4 Quote Link to comment https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57203 Share on other sites More sharing options...
BillyBoB Posted July 13, 2006 Author Share Posted July 13, 2006 the only thing i can think of would be the id because its the primary key but that should set itself right? Quote Link to comment https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57205 Share on other sites More sharing options...
GingerRobot Posted July 13, 2006 Share Posted July 13, 2006 Im not sure, try adding it in and see what happens:$query = mysql_query("INSERT INTO `news` (id,title, by, on, message) VALUES('','$title','$by','$time','$message')"); Quote Link to comment https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57207 Share on other sites More sharing options...
BillyBoB Posted July 13, 2006 Author Share Posted July 13, 2006 man this is making me mad how do u guys setup the news on the siteserror: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('','fff','fff','20060713101229','test')' Quote Link to comment https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57208 Share on other sites More sharing options...
BillyBoB Posted July 13, 2006 Author Share Posted July 13, 2006 brb30 min Quote Link to comment https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57209 Share on other sites More sharing options...
CheesierAngel Posted July 13, 2006 Share Posted July 13, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57210 Share on other sites More sharing options...
BillyBoB Posted July 13, 2006 Author Share Posted July 13, 2006 thx for your help and that was it the by fixed it now so thx alot Quote Link to comment https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57360 Share on other sites More sharing options...
kenrbnsn Posted July 13, 2006 Share Posted July 13, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57368 Share on other sites More sharing options...
BillyBoB Posted July 13, 2006 Author Share Posted July 13, 2006 dude i fixed it all i did was change the fields names Quote Link to comment https://forums.phpfreaks.com/topic/14457-need-help/#findComment-57386 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.