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. Quote Link to comment 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)){?> Quote Link to comment 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... Quote Link to comment 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 ??? Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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" } ?> Quote Link to comment 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" } ?> Quote Link to comment 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 ' ?? Quote Link to comment 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" } ?> Quote Link to comment 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... Quote Link to comment 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 Quote Link to comment 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());?> Quote Link to comment 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 Quote Link to comment 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());?> Quote Link to comment 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"; } ?> Quote Link to comment 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"])); Quote Link to comment 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"; } ?> Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
Coreye Posted April 15, 2008 Share Posted April 15, 2008 nevermind... Quote Link to comment 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??) Quote Link to comment 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? Quote Link to comment 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! Quote Link to comment 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.