Coreye Posted April 15, 2008 Share Posted April 15, 2008 For future reference, if (isset($to)||isset($sub)||isset($msg)||!empty($to)||!empty($sub|)|!empty($msg)){ was making it blank. Notice the ($sub|)|!empty($msg part. Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/page/2/#findComment-517326 Share on other sites More sharing options...
darkfreaks Posted April 15, 2008 Share Posted April 15, 2008 he copied my code wrong and modified it or i messed it up oops :-\ <?php if (isset($to)||isset($sub)||isset($msg)||!empty($to)||!empty($sub)||!empty($msg)){?> Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/page/2/#findComment-517328 Share on other sites More sharing options...
bam2550 Posted April 15, 2008 Author Share Posted April 15, 2008 sooo close... Parse error: syntax error, unexpected T_VARIABLE in /opt/lampp/htdocs/test/send.php on line 10 it looks right... Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/page/2/#findComment-517329 Share on other sites More sharing options...
darkfreaks Posted April 15, 2008 Share Posted April 15, 2008 did you use my code instead of his ??? Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/page/2/#findComment-517332 Share on other sites More sharing options...
bam2550 Posted April 15, 2008 Author Share Posted April 15, 2008 Yes, i have kind of only been using yours the hole time Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/page/2/#findComment-517337 Share on other sites More sharing options...
darkfreaks Posted April 15, 2008 Share Posted April 15, 2008 please paste your current code and comment out line 10 Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/page/2/#findComment-517340 Share on other sites More sharing options...
bam2550 Posted April 15, 2008 Author 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)) // This is Line 10 // $con = mysql_connect("localhost","iii","iii"); 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/page/2/#findComment-517343 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/page/2/#findComment-517346 Share on other sites More sharing options...
bam2550 Posted April 15, 2008 Author Share Posted April 15, 2008 using that exact code i received this error... 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 ('', 'admin', 'fe', 'fe')' at line 1 do i have to use ´ or ` or ' ?? Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/page/2/#findComment-517354 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/page/2/#findComment-517358 Share on other sites More sharing options...
bam2550 Posted April 15, 2008 Author Share Posted April 15, 2008 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 ''sendto', 'from', 'subject', 'message') VALUES ('', 'admin', 'r', 'r')' at line 1 is it not reading the from? it doesnt look like it is... seeing as from is blank in this error message, but it is aparent in the boxes... === I think i found why... ==== The onlything that was changed to sendto was the tables in MySQL... Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/page/2/#findComment-517367 Share on other sites More sharing options...
bam2550 Posted April 15, 2008 Author Share Posted April 15, 2008 now i get this error! 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 ''sendto', 'from', 'subject', 'message') VALUES ('mod123', 'admin', 'r', 'r')' at line 1 hmm Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/page/2/#findComment-517368 Share on other sites More sharing options...
darkfreaks Posted April 15, 2008 Share Posted April 15, 2008 try: <?php mysql_query("INSERT INTO private_messages (sendto,from,subject,message) VALUES ($to,$from,$sub,$msg)") or die(mysql_error());?> Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/page/2/#findComment-517369 Share on other sites More sharing options...
bam2550 Posted April 15, 2008 Author Share Posted April 15, 2008 i still get... 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,r,r)' at line 1 Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/page/2/#findComment-517373 Share on other sites More sharing options...
darkfreaks Posted April 15, 2008 Share Posted April 15, 2008 <?php mysql_query("INSERT INTO private_messages VALUES ($to,$from,$sub,$msg)") or die(mysql_error());?> Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/page/2/#findComment-517376 Share on other sites More sharing options...
bam2550 Posted April 15, 2008 Author Share Posted April 15, 2008 Okay well i found the error was i didnt wrap the things in single quotes... i did and got a totally new error! My new error is: Unknown column 'mod123' in 'field list' PS mod123 is my to feild, atleast it should be! <?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","r","l"); 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/page/2/#findComment-517378 Share on other sites More sharing options...
Coreye Posted April 15, 2008 Share Posted April 15, 2008 $to = trim(mysql_real_escape_string($_POST["to"])); should be $to = trim(mysql_real_escape_string($_POST["sendto"])); Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/page/2/#findComment-517380 Share on other sites More sharing options...
Coreye Posted April 15, 2008 Share Posted April 15, 2008 If your getting 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 '`testing`,``,``)' at line 2 Try: <?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","r","l"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("messaging", $con); mysql_query("INSERT INTO `private_messages` (`sendto`, `from`, `subject`, `message`) VALUES ('" . $sendto . "', '" . $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/page/2/#findComment-517386 Share on other sites More sharing options...
bam2550 Posted April 15, 2008 Author Share Posted April 15, 2008 ^^ that last thing worked perfectly! not i just have to edit it a little to retreive it correctly! Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/page/2/#findComment-517391 Share on other sites More sharing options...
Coreye Posted April 15, 2008 Share Posted April 15, 2008 nevermind... Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/page/2/#findComment-517417 Share on other sites More sharing options...
bam2550 Posted April 15, 2008 Author Share Posted April 15, 2008 Okay... Yeah. Now my only problem is retreiving it in inbox.php. It is probably a similar problem to send.php ... If anyone would like to assist me... [code=php:0]<?php include("include/session.php"); ?> <?php $con = mysql_connect("localhost","~","~"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("messaging", $con); $result = mysql_query("SELECT * FROM private_messages WHERE 'sendto'='$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['sendto'] . " " . $row['subject']; } mysql_close($con); ?>[/php The way it is output is pretty crudy, but even if it is messy, idc. I just want to get it outputted (is that even a word??) Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/page/2/#findComment-517520 Share on other sites More sharing options...
GingerRobot Posted April 15, 2008 Share Posted April 15, 2008 This line: $result = mysql_query("SELECT * FROM private_messages WHERE 'sendto'='$username'", $con); Should be: $result = mysql_query("SELECT * FROM private_messages WHERE sendto='$username'", $con); Weather or not that is the problem, i dont know - i've not read the whole thread, just saw the error. I assume $username is defined in session.php? Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/page/2/#findComment-517521 Share on other sites More sharing options...
bam2550 Posted April 15, 2008 Author Share Posted April 15, 2008 I found the error... $username does not define to username correctly, so basically, everything is there except the to field. Which is bad, since no one can then receive the message! Link to comment https://forums.phpfreaks.com/topic/101092-phpmysql-error-pmsys/page/2/#findComment-517523 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.