rdwinder Posted July 2, 2008 Share Posted July 2, 2008 Hey Guys Im having some problem with my MYSQL, Here is the source code for my content <?php $db = new sql(); $id = $_GET['edit']; $db->sql_query("SELECT * FROM `content` WHERE `id` = '$id'"); $mysql_array = $db->fetch_array(); ?> <form id="form2" name="form1" method="post" onsubmit="return submitForm();" action="?content&update=<?php echo $_GET['edit']; ?>"> <p> Page name<br /> <span id="sprytextfield2"> <input name="name" type="text" value="<?php echo $mysql_array['pagename']; ?>" id="name" size="85" /> <span class="textfieldRequiredMsg">A value is required.</span></span></p> <p>Page content<br /> <script language="JavaScript" type="text/javascript"> //<!-- //Usage: writeRichText(fieldname, html, width, height, buttons, readOnly) writeRichText('rte1', '<?php echo rteSafe($mysql_array['content']); ?>', 760, 500, true, false); //--> </script> <br /> <input type="submit" name="button2" id="button2" value="Submit" /> </p> </form> Here's the "IF" to see when to update the database. if (isset($_GET['update'])) { echo updateContent($_POST['name'], $_POST['rte1'], $_GET['update']); echo "updating"; } This is my update function function updateContent($pgname, $content, $id) { $db = new sql(); $db->sql_query("UPDATE `content` SET `pagename` = '$pgname', `content` = '$content' WHERE `id` = '$id'"); echo mysql_error(); } Now when i submit the data, the database has no record of my data, i have uploaded my code to my webserver and it seems to do it there too.. Please help me i am SO ???ed Thanks, Richard Quote Link to comment https://forums.phpfreaks.com/topic/112889-mysql-issues/ Share on other sites More sharing options...
mmarif4u Posted July 2, 2008 Share Posted July 2, 2008 i dont think so that you have to echo your function: echo updateContent($_POST['name'], $_POST['rte1'], $_GET['update']); should be: updateContent($_POST['name'], $_POST['rte1'], $_GET['update']); Quote Link to comment https://forums.phpfreaks.com/topic/112889-mysql-issues/#findComment-579839 Share on other sites More sharing options...
kathas Posted July 2, 2008 Share Posted July 2, 2008 hey richard we have no idea what the $db object is, now if we take your word for the fact that it works correctly why do you create another object for the update function...? but i guess that is how this object works... now after all these that may not be wrong where do you submit the data to the db update is used to alter already existing records in the db... Quote Link to comment https://forums.phpfreaks.com/topic/112889-mysql-issues/#findComment-579842 Share on other sites More sharing options...
rdwinder Posted July 2, 2008 Author Share Posted July 2, 2008 I have used the same sql class a million times before on this project.. its only this instance that this issue happens.. Check these screenshots: http://www.gethosted.co.za/confusion/ Rich Quote Link to comment https://forums.phpfreaks.com/topic/112889-mysql-issues/#findComment-579848 Share on other sites More sharing options...
Wolphie Posted July 2, 2008 Share Posted July 2, 2008 Have you tried to echo the parameters to see if the variables are even getting set before calling the function? <?php function updateContent($pgname, $content, $id) { echo $pagname . '<br />'; echo $content . '<br />'; echo $id; $db = new sql(); // Always add error handling $result = $db->sql_query("UPDATE `content` SET `pagename` = '$pgname', `content` = '$content' WHERE `id` = '$id'") or trigger_error(mysql_error()); if($result) return $result; else return false; } // Then when calling your function use a condition with error handling if(updateContent($_POST['name'], $_POST['rte1'], $_GET['update'])) { echo 'Updating...'; else echo 'Could not update!'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/112889-mysql-issues/#findComment-579849 Share on other sites More sharing options...
rdwinder Posted July 2, 2008 Author Share Posted July 2, 2008 Tried your entry, it says, "Updating" and posts all the information i sent to the function.. Quote Link to comment https://forums.phpfreaks.com/topic/112889-mysql-issues/#findComment-579853 Share on other sites More sharing options...
Wolphie Posted July 2, 2008 Share Posted July 2, 2008 Try running an update query by itself, without any predefined variables. And see if it updates the database. If that fails, try a regular update query without the MySQL class. Quote Link to comment https://forums.phpfreaks.com/topic/112889-mysql-issues/#findComment-579855 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.