bam2550 Posted April 14, 2008 Share Posted April 14, 2008 === Where the error is occuring ==== (below) inbox.php - http://pastebin.com/m474f8f25 include/session.php - i think this might have to be edited, except it has some sensitive material... I will only post it if it is a must have. The error... Error, MySQL Said: 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 'to='mod123'' at line 1 === Other Parts that might not be correct, but i think they are... === (below) send.php - http://pastebin.com/m7084f4a7 usermsg.php - http://pastebin.com/m3dc7d7bb If someone would be so kind to look over the first half (and maybe even the second half) to see what is going on, i would be most appreciative! I think i had another topic, but i lost it. Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/ Share on other sites More sharing options...
darkfreaks Posted April 14, 2008 Share Posted April 14, 2008 try doing : <?php if(!result) { // die }?> Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517010 Share on other sites More sharing options...
rhodesa Posted April 14, 2008 Share Posted April 14, 2008 TO is a reserved word in MySQL, change the column name or wrap it with backticks: $result = mysql_query("SELECT * FROM private_messages WHERE `to`='$username'", $con); Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517014 Share on other sites More sharing options...
darkfreaks Posted April 14, 2008 Share Posted April 14, 2008 i suggest you change the name of the column rather and TO is indeed a function in MYSQL i had forgotten Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517015 Share on other sites More sharing options...
bam2550 Posted April 14, 2008 Author Share Posted April 14, 2008 okay ill change to, i didnt know thanks You guys are soo speedy and smart! ~Also, for some reason, the area is blank... I could have sworn i sent a message... ~~ Could the way i am displaying the things be the problem? (like to, from, subject message...) If someone could help me with that also, thatd be great! Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517030 Share on other sites More sharing options...
bam2550 Posted April 14, 2008 Author Share Posted April 14, 2008 Still found nothing... Hmm.. Ill check some more, send some more things... Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517126 Share on other sites More sharing options...
darkfreaks Posted April 14, 2008 Share Posted April 14, 2008 also on send.php might want to use isset() and empty() to determine if things are isset or !isset not isset empty or !empty not empty make sense ??? Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517139 Share on other sites More sharing options...
bam2550 Posted April 14, 2008 Author Share Posted April 14, 2008 Okay well i isset() all the variables, and it seems they where all right. I am receiving NO ERRORS, anywhere... The only problem is that inbox.php has nothing in. Blank screen. Notta! Anyone want to test it out? Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517171 Share on other sites More sharing options...
darkfreaks Posted April 14, 2008 Share Posted April 14, 2008 Send.php: <?php include("include/session.php"); ?> <?php $to =trim(mysql_real_escape_string($_POST["to"])); $from = $username; $sub = trim(mysql_real_escape_string($_POST["sub"])); $msg = trim(mysql_real_escape_string($_POST["msg"])); if (isset($to)||isset($from)||isset($sub)||isset($msg)||!empty($to)||!empty($sub|)|!empty($msg)){ ?> <?php $con = mysql_connect("localhost","1","1"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("messaging"[b][/b], $con); mysql_query("INSERT INTO private_messages (to, from, subject, message) VALUES ('$to', '$from', '$sub', '$msg')"); mysql_close($con); } ?> Inbox.php: <?php include("include/session.php"); ?> <?php $con = mysql_connect("localhost","s","s"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("messaging", $con); $result = mysql_query("SELECT * FROM private_messages WHERE to='$username'", $con); if (!$result) { die( "Error, MySQL Said: " . mysql_error() ); } while($row = mysql_fetch_array($result)) { echo $row['from'] . " " . $row['message']; echo "<br />"; echo $row['to'] . " " . $row['subject']; } mysql_close($con); ?> Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517195 Share on other sites More sharing options...
bam2550 Posted April 15, 2008 Author Share Posted April 15, 2008 JEEZE! This is still not working... Would anyone like to test for themselves? Maybe they can see... or something... Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517221 Share on other sites More sharing options...
darkfreaks Posted April 15, 2008 Share Posted April 15, 2008 Please paste any errors and if there is no errors do this and tell me what you get ok ??? <?php ini_set('error_reporting',E_ALL);?> Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517225 Share on other sites More sharing options...
bam2550 Posted April 15, 2008 Author Share Posted April 15, 2008 K ill do that now... Maybe my MySQL Database/Tables/Thingys in the tables are setup incorrectly in Mysql? I just set everything to the same thing except different lengths... Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517227 Share on other sites More sharing options...
bam2550 Posted April 15, 2008 Author Share Posted April 15, 2008 http://img178.imageshack.us/img178/170/screenshotfe4.png 1) This is the Database 2) This is the Table 3) This is the stuff in the Table Should i change anything? add anything? rename anything? Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517240 Share on other sites More sharing options...
darkfreaks Posted April 15, 2008 Share Posted April 15, 2008 the code is flawed not your DB Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517242 Share on other sites More sharing options...
bam2550 Posted April 15, 2008 Author Share Posted April 15, 2008 hmm... Debugging is difficult... Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517244 Share on other sites More sharing options...
darkfreaks Posted April 15, 2008 Share Posted April 15, 2008 like i said if you are getting errors please paste them or we cant help you sorry Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517245 Share on other sites More sharing options...
bam2550 Posted April 15, 2008 Author Share Posted April 15, 2008 Nope no errors at all... when i fill out the form to send something, blank screen... When i click inbox.php, blank screen... Also, the table says nothing is recordered... so inbox.php is probably not the problem (since it is printing what it says it is printing... nothing!) Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517246 Share on other sites More sharing options...
darkfreaks Posted April 15, 2008 Share Posted April 15, 2008 made some modifications to send.php <?php include("include/session.php"); $to =trim(mysql_real_escape_string($_POST["to"])); $from = $username; $sub = trim(mysql_real_escape_string($_POST["sub"])); $msg = trim(mysql_real_escape_string($_POST["msg"])); if (isset($to)||isset($sub)||isset($msg)||!empty($to)||!empty($sub|)|!empty($msg)){ $con = mysql_connect("localhost","1","1"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("messaging"[b][/b], $con); mysql_query("INSERT INTO private_messages (to, from, subject, message) VALUES ('$to', '$from', '$sub', '$msg')"); mysql_close($con); } else if(!isset($to)||!isset($sub)||!isset($msg)||empty($to)||empty($msg)||empty($sub)) { echo "Please fill out the form":} ?> Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517249 Share on other sites More sharing options...
bam2550 Posted April 15, 2008 Author Share Posted April 15, 2008 This is sooo annoying Want to test it out yourself? http://68.38.155.104/test/main.php Register 2 names, send a message from name1 to name2 and tell me if name2 receives it! hehe Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517257 Share on other sites More sharing options...
darkfreaks Posted April 15, 2008 Share Posted April 15, 2008 now tell me if you get an error <?php include("include/session.php"); $to =trim(mysql_real_escape_string($_POST["to"])); $from = $username; $sub = trim(mysql_real_escape_string($_POST["sub"])); $msg = trim(mysql_real_escape_string($_POST["msg"])); if (isset($to)||isset($sub)||isset($msg)||!empty($to)||!empty($sub|)|!empty($msg)){ $con = mysql_connect("localhost","1","1"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("messaging", $con); mysql_query("INSERT INTO private_messages (to, from, subject, message) VALUES ('$to', '$from', '$sub', '$msg')") or die(mysql_error()); mysql_close($con); } else if(!isset($to)||!isset($sub)||!isset($msg)||empty($to)||empty($msg)||empty($sub)) { echo "Please fill out the form":} ?> Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517261 Share on other sites More sharing options...
Coreye Posted April 15, 2008 Share Posted April 15, 2008 Try: <?php include("include/session.php"); $to = trim(mysql_real_escape_string($_POST["to"])); $from = $username; $sub = trim(mysql_real_escape_string($_POST["sub"])); $msg = trim(mysql_real_escape_string($_POST["msg"])); if ((isset($to) && isset($sub) && isset($msg)) && (!empty($to) && !empty($sub) && !empty($msg)){ $con = mysql_connect("localhost","1","1"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("messaging", $con); mysql_query("INSERT INTO private_messages (to, from, subject, message) VALUES ('$to', '$from', '$sub', '$msg')") or die(mysql_error()); mysql_close($con); } else { echo "Please fill out the form" } ?> Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517298 Share on other sites More sharing options...
bam2550 Posted April 15, 2008 Author Share Posted April 15, 2008 oh great we are making progress it seems!! NEW E RROR 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 'from, subject, message) VALUES ('mod123', 'admin', 'hihi', 'hi')' at line 1 Also i did so debugging in your script! hehe, also its not, to, in the table anymore... it is sendto thanks Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517309 Share on other sites More sharing options...
darkfreaks Posted April 15, 2008 Share Posted April 15, 2008 ah ok if solved please click topic solved Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517316 Share on other sites More sharing options...
bam2550 Posted April 15, 2008 Author Share Posted April 15, 2008 but it is not solved I ran into another error, which is a good thing i think... Can you help? 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 'from, subject, message) VALUES ('mod123', 'admin', 'hihi', 'hi')' at line 1 Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517317 Share on other sites More sharing options...
darkfreaks Posted April 15, 2008 Share Posted April 15, 2008 <?php include("include/session.php"); $to = trim(mysql_real_escape_string($_POST["sendto"])); $from = $username; $sub = trim(mysql_real_escape_string($_POST["sub"])); $msg = trim(mysql_real_escape_string($_POST["msg"])); if ((isset($to) && isset($sub) && isset($msg)) && (!empty($to) && !empty($sub) && !empty($msg)){ $con = mysql_connect("localhost","1","1"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("messaging", $con); mysql_query("INSERT INTO private_messages (sendto, from, subject, message) VALUES ('$to', '$from', '$sub', '$msg')") or die(mysql_error()); mysql_close($con); } else { echo "Please fill out the form" } ?> Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/#findComment-517323 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.