urbanxtremes Posted June 28, 2008 Share Posted June 28, 2008 Hello, I have created a script to update a news section, I have used this script before and it works fine on my other sites; however, it just does not want to update the MySQL (MySQL client version: 5.0.45) db? I am going mad, have been trying to fix it for the last 9 hours. If someone can help that would be great. ??? The following code is step 2, the first step is just a page that pushes the ID across (update_list.php -- update_list_edit.php -- update_list_changed.php) The Form update_list_edit.php <? $id=$_POST['id']; $db="data_-_data"; $link = mysql_connect("127.0.0.1","username", "password"); if (! $link) die("Couldn't connect to MySQL"); mysql_select_db($db , $link) or die("Couldn't open $db: ".mysql_error()); $query=" SELECT * FROM Vector_Hpages WHERE HpagesID='$id'"; $result=mysql_query($query); $num=mysql_num_rows($result); $i=0; while ($i < $num) { $HpagesID =mysql_result($result,$i,"HpagesID"); $HpagesCat =mysql_result($result,$i,"HpagesCat"); $HpagesHeader =mysql_result($result,$i,"HpagesHeader"); $HpagesContent =mysql_result($result,$i,"HpagesContent"); $HpagesSContent =mysql_result($result,$i,"HpagesSContent"); $HpagesMKey =mysql_result($result,$i,"HpagesMKey"); ?> <h3>Edit and Submit</h3> <form action="update_list_changed.php" method="post"> <input type="text" name="vec_id" value="<? echo "$HpagesID" ?>"> <strong>Page Header:</strong><br> <input type="text" name="vec_header" value="<? echo "$HpagesHeader" ?>"><p> <strong>Page Content:</strong><br> <textarea cols="40" rows="10" name="vec_content"><? print "$HpagesContent" ?></textarea><p> <strong>Small Content:</strong><br> <textarea cols="40" rows="5" name="vec_scontent"><? print "$HpagesSContent" ?></textarea><p> <strong>Meta Keyword:</strong><br> <textarea cols="40" rows="5" name="vec_mkey"><? print "$HpagesMKey" ?></textarea><p> <strong>Page Category:</strong><br> <input type="text" name="vec_cat" value="<? echo "$HpagesCat" ?>"><p> <input type="Submit" value="Update"> </form> <? ++$i; } ?> This is step 3, which pushes the information into the MySQL db (well it should do?) The Push to MySQL update_list_changed.php <? $vec_id = mysql_real_escape_string($_POST['vec_id']); $vec_header = mysql_real_escape_string($_POST['vec_header']); $vec_content = mysql_real_escape_string($_POST['vec_content']); $vec_scontent = mysql_real_escape_string($_POST['vec_scontent']); $vec_mkey = mysql_real_escape_string($_POST['vec_mkey']); $vec_cat = mysql_real_escape_string($_POST['vec_cat']); $db="data_-_data"; $link = mysql_connect("127.0.0.1","ursername", "password"); if (! $link) die("Couldn't connect to MySQL"); mysql_select_db($db , $link) or die("Couldn't open $db: ".mysql_error()); mysql_query("UPDATE Vector_Hpages SET HpagesHeader='$vec_header', HpagesContent='$vec_content', HpagesSContent='$vec_scontent', HpagesMKey='$vec_mkey', HpagesCat='$vec_cat' WHERE HpagesID='$vec_id'") or die("Update Error: ".mysql_error()); echo "Record Updated"; mysql_close($link); ?> Can anyone see where this issue is happening, I have printed the code out and checked it, but, still can not see the error... :-\ :'( Would appriciate any help. Regards, Mark PS - this is the MySQL DB CREATE TABLE `Vector_Hpages` ( `HpagesID` bigint(20) NOT NULL auto_increment, `HpagesCat` tinytext NOT NULL, `HpagesHeader` varchar(255) NOT NULL default '', `HpagesContent` longtext NOT NULL, `HpagesSContent` tinytext NOT NULL, `HpagesMKey` tinytext NOT NULL, `Active` tinyint(4) NOT NULL default '0', `Counter` int(11) NOT NULL default '0', `DateAdded` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, PRIMARY KEY (`HpagesID`), KEY `HpagesID` (`HpagesID`,`DateAdded`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PACK_KEYS=1 AUTO_INCREMENT=0 ; Link to comment https://forums.phpfreaks.com/topic/112356-update-mysql-with-php-whole-day-trying-but-no-joy/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.