h4v0c Posted September 5, 2006 Share Posted September 5, 2006 Hi, Its me againI asked a question concerning saving posted data out of the FCKeditor v.2.3.1 in the thread below:http://www.phpfreaks.com/forums/index.php/topic,106562.msg426288.html (Thanks to xyn, who was very helpful)I got that problem solved, but now the editor only saves to the first row in the database.Just to sum it up again:The editor is passed the page ID from a page listing. Editor then loads the data using this query:[code]<?php mysql_connect("server URL", "user name", "password") or die ('I can?t connect to the database.') ; mysql_select_db("clientd_psp") ; $pagedid = $_GET['id']; $posted_id = $_POST['id']; $result = mysql_query("SELECT * FROM content_tbl WHERE page_id=$pagedid") ; $row = mysql_fetch_array($result) ; echo "<div style=\"font-size:18px;\">" . $row['name'] . "</div><br />" ; //$sBasePath = $_SERVER['PHP_SELF'] ; //$sBasePath = substr( $sBasePath, 0, strpos( $sBasePath, "_samples" ) ) ; $oFCKeditor = new FCKeditor('PSP_editor') ; $oFCKeditor->BasePath = '/psp/fckeditor/' ; $oFCKeditor->Value = $row['page_content'] ; $oFCKeditor->Height = '500' ; $oFCKeditor->Create() ; echo ("<input type='hidden' value='$pagedid' name='page_id_value' />") ; ?>[/code]This part works flawlessly. The problem I have is that when posting it to this script:[code]<?php$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) ; mysql_query("UPDATE content_tbl SET page_content='".stripslashes($_POST['PSP_editor'])."' WHERE page_id='".$_POST['page_id_value']."'") ;?>[/code]This only works when page_id is 100(the very first row in the database) I have no idea whats going, and I am definately a php noob, so I am at a loss as to whats going on with it not working. Like I said, its a problem with every row except the first one. Does anyone have any experience in using this wysiwyg? Quote Link to comment Share on other sites More sharing options...
ober Posted September 5, 2006 Share Posted September 5, 2006 I assume you have other rows in the database that it can update?As a troubleshooting technique, you should always build your query outside of the mysql_query() function. Then you can echo the query to see what is actually going into the query.Also, you're not checking for failure of the query. You should be doing this:$result = mysql_query($query);if(!$result) echo mysql_error(); Quote Link to comment Share on other sites More sharing options...
paul2463 Posted September 5, 2006 Share Posted September 5, 2006 I have had problems with queries before and I found that a couple of my problems have been in putting complex variables into the query statement, it might be worth a try setting thos variables up and then writing the query i.e [code]$edit = stripslashes($_POST['PSP_editor']);$page = $_POST['page_id_value'];mysql_query("UPDATE content_tbl SET page_content='$edit' WHERE page_id='$page") ;[/code]it might work, it might not, but I have had some success doing things this way. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.