Jump to content


Photo

SQL Insert Issue


  • Please log in to reply
3 replies to this topic

#1 Guteman

Guteman
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts
  • LocationWisconsin

Posted 04 August 2006 - 08:44 PM

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

<?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!");
				}
			
			
			}
?>


#2 PHPSpirit

PHPSpirit
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 04 August 2006 - 08:54 PM

Perhaps the account does not have the permissions, or the syntax is incorrect.

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


#3 Guteman

Guteman
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts
  • LocationWisconsin

Posted 04 August 2006 - 09:00 PM

what you mean by syntax

#4 Guteman

Guteman
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts
  • LocationWisconsin

Posted 04 August 2006 - 09:07 PM

fixed it.. nevermind




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users