Jump to content

Archived

This topic is now archived and is closed to further replies.

Guteman

SQL Insert Issue

Recommended Posts

I cannot make the SQL statment insert the information (message).

[code]
<?php
if($logged['login'])
{
switch($_GET['page'])
{
case 'createmessage':

if(isset($_POST['createmessage']))
{
?>
<div style="text-align: right; margin: 0 10px 0 0;">Create a New Message</div>
<?php

$checkname = mysql_query("SELECT login FROM clients") or die ("MySQL query error.");
$checkname= mysql_fetch_array($checkname);

if(strlen($_POST['recipient']) <= 0)
{
$error_message .= '<p class="failure">Error: You did not enter a Recipient.</p>';
}

else if($checkname['login'] != $_POST['recipient'])
{
$error_message .= '<p class="failure">Error: Username does not exist.</p>';
}

if(strlen($_POST['subject']) <= 0)
{
$error_message .= '<p class="failure">Error: You did not enter a Subject.</p>';
}

if(strlen($_POST['message']) <= 0)
{
$error_message .= '<p class="failure" style="margin: 0 0 10px 0;">Error: You did not enter a Message.</p>';
}

if(isset($error_message))
{
echo("$error_message");
}

if(!isset($error_message))
{
$subject = htmlspecialchars($_POST['subject']);
$message = htmlspecialchars($_POST['message']);
$recipient = htmlspecialchars($_POST['recipient']);
$from = htmlspecialchars($logged['login']);

$query = mysql_query("INSERT INTO pms (subject, message, recipient, from, status)
VALUES('$subject','$recipient','$message','$from','unread')") or die ("MySQL Problem");

echo("Message Sent!");
}


}
?>
[/code]

Share this post


Link to post
Share on other sites
Perhaps the account does not have the permissions, or the syntax is incorrect.

Try this:
[code]
INSERT INTO `pms` (`subject`, `message`, `recipient`, `from`, `status`) VALUES('$subject','$recipient','$message','$from','unread');"
[/code]

Share this post


Link to post
Share on other sites

×

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.