Jump to content

PHP/MySQL error - PMsys


bam2550

Recommended Posts

=== 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
Share on other sites

okay ill change to, i didnt know :P 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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

but it is not solved :P

 

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
Share on other sites

<?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
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.