Jump to content


Photo

PHP noob needs help with mysql_query


  • Please log in to reply
3 replies to this topic

#1 h4v0c

h4v0c
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 01 September 2006 - 10:22 PM

Hi All,

Im relatively new to php and am working on a project for a client. I am using the FCKeditor(www.fckeditor.net)  version 2.1. The webserver the PHP is running on is(to my knowledge) windows 2000 server, and the PHP version on the server is the latest stable version(which I dont remember the actual number). The editor is posting the data to my script. My post handler script is as follows:

$sValue =  stripslashes( $_POST['PSP_editor'] ) ;
$posted_id = $_POST['page_id_value'] ;
mysql_connect("database URL", "Username", "Password") or die ('I can?t connect to the database.') ;
mysql_select_db("clientd_psp") ;
mysql_query("UPDATE content_tbl SET page_content=$sValue WHERE page_id=$posted_id") ;

Obviously I have changed the URL, username and password. This has me stumped, if I comment out the mysql commands and have it echo the 2 variables and they come back with the correct data, but it refuses to successfully update the fields. I do have read and write access to the database as I entered the content into the DB. Whats up?

Thanks is advance,
John

#2 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 01 September 2006 - 10:25 PM

try...
$sValue =  stripslashes( $_POST['PSP_editor'] ) ;
$posted_id = $_POST['page_id_value'] ;
mysql_connect("database URL", "Username", "Password") or die ('I can?t connect to the database.') ;
mysql_select_db("clientd_psp") ;
mysql_query("UPDATE content_tbl SET page_content='$sValue' WHERE page_id='$posted_id'") ;

if not i'll read the problem.. :/

#3 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 01 September 2006 - 10:30 PM

Or try:
$host="localhost"; // default is this change if nessesary.
$login="user";
$pwd="pwd";
$db="database_name";

$conn = mysql_connect("$host", "$login", "$pwd") or die('SQL Error: '.mysql_error().'');
mysql_select_db($db, $conn);

mysql_query("UPDATE content_tbl SET page_content='".stripslashes($_POST['PSP_editor'])."' WHERE page_id='".$_POST['page_id_value']."'");


#4 h4v0c

h4v0c
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 01 September 2006 - 11:42 PM

Thank you so much. the second one fixed it, now it works perfectly. OMG THANKS SO MUCH!  ;D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users