usadarts Posted September 18, 2007 Share Posted September 18, 2007 Not sure if it has something to do with the RRN that i pass through, but when I modify the information, it does not change the database. index.php <html> <head> <script type="text/javascript"> <!-- function articleHandler(form){ var URL = "http://www.websites.com/cpanel/updatearticles?rrn="+articles.rrn.value; window.location.href = URL; } //--> </SCRIPT> <style type="text/css"> <!-- .style2 {color: #808080} --> </style> </head> <body> <center> <table width="75%" valign="top"> <tr> <td><?php $dbh=mysql_connect ("localhost", "xxxxxxxx", "xxxxxxxx") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("xxxxxxxx"); $query = "SELECT * FROM `articles` ORDER BY `date` DESC"; $result = mysql_query($query,$dbh) or die(mysql_error()); if (result){ echo "<center><form name=\"articles\">"; echo "<select name=\"rrn\" size=1 onChange=\"javascript:articleHandler()\">"; echo "<option value=''>Select Article To Update</option>"; while($row = mysql_fetch_array($result)) { echo "<option value='{$row['rrn']}'>{$row['date']} - {$row['title']}</option>"; } echo '</select></form></center>'; } ?> <?php $dbh=mysql_connect ("localhost", "xxxxxxxxx", "xxxxxxxx") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("xxxxxxxx"); $rrn = $_GET['rrn']; $queryr = "SELECT * FROM `articles` WHERE `rrn` = '$rrn'"; $resultr = mysql_query($queryr,$dbh) or die(mysql_error()); while($row = mysql_fetch_array($resultr)) { echo "<center><font size=+2>Add News Articles</font>"; echo "<form action=\"post.php?$rrn\" method=\"post\">"; echo "<textarea name=\"title\" cols=\"50\" rows=\"1\">"; echo $row['title']; echo "</textarea><br>"; echo "<textarea name=\"author\" cols=\"50\" rows=\"1\">"; echo $row['author']; echo "</textarea><br>"; echo "<textarea name=\"date\" cols=\"20\" rows=\"1\">"; echo $row['date']; echo "</textarea><br>"; echo "<textarea name=\"newcomments\" cols=\"100\" rows=\"50\">"; echo $row['info']; echo "</textarea><br>"; echo "<input type=\"submit\">"; echo "</form></center>"; } ?> </td> </tr> </table> </center> </body> </html> post.php code <?php $title = $_POST['title']; $author = $_POST['author']; $date = $_POST['date']; $info = $_POST['info']; $str = $info; $order = array("\r\n", "\n", "\r"); $replace = '<br />'; $newstr = str_replace($order, $replace, $str); $rrn = $_GET['rrn']; str_replace("/r/n","<br><br>",'$info'); $dbh=mysql_connect ("localhost", "xxxxxxxxxxx", "xxxxxxxx") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("xxxxxxxxx"); $insert = "UPDATE article SET title='$title', author='$author', date='$date', info='$newstr' WHERE rrn=$rrn"; $results = mysql_query($insert); echo "<center>Article Modified - <a href=\"../index.php\"><font size=\"4\">BACK TO CONTROL PANEL</font></A></center>"; echo ""; ?> Quote Link to comment https://forums.phpfreaks.com/topic/69715-information-not-loading-to-database/ Share on other sites More sharing options...
cooldude832 Posted September 18, 2007 Share Posted September 18, 2007 I'm tired of giving this solution DO NOT POST MYSQL ERRORS UNTIL YOU HAVE PUT OR DIE(MYSQL_ERROR()); ON ALL RELATIVE QUERIES!!!!! PERIOD! someone needs to sticky this Quote Link to comment https://forums.phpfreaks.com/topic/69715-information-not-loading-to-database/#findComment-350315 Share on other sites More sharing options...
usadarts Posted September 18, 2007 Author Share Posted September 18, 2007 I must be missing something, not sure what you mean.....I already have this code in there..... or die ('I cannot connect to the database because: ' . mysql_error()); on all relative queries Quote Link to comment https://forums.phpfreaks.com/topic/69715-information-not-loading-to-database/#findComment-350316 Share on other sites More sharing options...
cooldude832 Posted September 18, 2007 Share Posted September 18, 2007 $results = mysql_query($insert); Quote Link to comment https://forums.phpfreaks.com/topic/69715-information-not-loading-to-database/#findComment-350317 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.