Jump to content

Archived

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

h4v0c

PHP noob needs help with mysql_query

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

Share this post


Link to post
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.. :/

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites
Thank you so much. the second one fixed it, now it works perfectly. OMG THANKS SO MUCH!  ;D

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.