Jump to content

PHP noob needs help with mysql_query


h4v0c

Recommended Posts

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:

[code]
$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") ;
[/code]

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

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.. :/
Link to comment
Share on other sites

Or try:
[code=php:0]$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']."'");
[/code]
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.