Jump to content


Photo

syntax error?


  • Please log in to reply
3 replies to this topic

#1 h4v0c

h4v0c
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 07 September 2006 - 08:04 PM

PHP version: 4.4.4
MySQL version: 4.1.2

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 's style of relating when things are going well and in conflict.

Code:

$host = "server URL" ;
	$login = "user name" ;
	$pwd = "password" ;
	$db = "clientd_psp" ;

	$conn = mysql_connect("$host", "$login", "$pwd") or die('SQL Error: '.mysql_error().'') ;
	mysql_select_db($db, $conn) ;
	$edit = stripslashes($_POST['PSP_editor']);
	$page = $_POST['page_id_value'];
	$result = mysql_query("UPDATE `content_tbl` SET `page_content`='$edit' WHERE `page_id`='$page'");
	
	if(!$result)
    	echo mysql_error();

wtf? the query should be perfect. what gives?

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 07 September 2006 - 08:10 PM

Change this:
<?php
	$result = mysql_query("UPDATE `content_tbl` SET `page_content`='$edit' WHERE `page_id`='$page'");
	
	if(!$result)
    	echo mysql_error();
?>
to
<?php
        $query = "UPDATE `content_tbl` SET `page_content`='$edit' WHERE `page_id`='$page'";
	$result = mysql_query($query) or die("Problem with the query: $query<br>" . mysql_error());
?>

This will print out the query. Check it for errors.

Ken

#3 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 07 September 2006 - 08:11 PM

looks like you're not escaping your variables. run all your user entered text through mysql_real_escape_string() and you should be fine.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#4 h4v0c

h4v0c
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 07 September 2006 - 08:29 PM

i would serisouly buy you two a beer right now. thanks so much guys.  ;D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users