a1amattyj Posted May 13, 2008 Share Posted May 13, 2008 Hello, When i try to use my script, once i confirm i want to do my action (see below) by javascript alert, i get the following error: Unknown column 'name' in 'where clause' All the tables rename them selfs, except my update doesnt actually update. See few lines from bottom : if($_GET['act'] == 'name'){ $id = $_REQUEST['id']; $newname = $_POST['fname']; $query = "SELECT * FROM {$db_prfix}mf_forums WHERE id = '$id'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); echo ' Updating Forum Name <span style="color:green; font-weight:bold"> '.$row['fname'].' </span> . . <hr />'; $name = $row['fname']; if($name == $newname){ echo 'The requested name is the same as the name it currently is. The forum name was <b>not</b> updated. <a href="forums.php?act=view&id='.$row['id'].'">Go Back</a>'; echo '<br /><br /><br />'; require("footer.php"); exit(); }else{ ?> <script language=javascript1.1> var answer = confirm("Are you sure you want to rename this forum to <? echo $newname; ?>?") if (answer){ } else{ alert("Cancelled Update!") window.location = "forums.php?act=view&id=<? echo $row['id']; ?>"; } </script> <? $oldprefix = ''.$row['fname'].'_'; $newprefix = ''.$newname.'_'; $result = mysql_query('SHOW TABLES') or die(mysql_error()); while ($record = mysql_fetch_row($result)) { $oldname = $record[0]; $newname = str_replace($oldprefix, $newprefix, $oldname); mysql_query("RENAME TABLE $oldname TO $newname"); } $query = "UPDATE {$db_prfix}mf_forums SET name = {$newname} WHERE name = {$row['fname']}"; $result = mysql_query($query) or die(mysql_error()); echo 'Forum name successfully changed to '.$newname.'!'; } Thanks Link to comment https://forums.phpfreaks.com/topic/105476-problem-mysql-pdate-with-php/ Share on other sites More sharing options...
tendrousbeastie Posted May 13, 2008 Share Posted May 13, 2008 Without any more to go on it looks like the problem is simply with the line below at the bottom of the script you've posted - there is no column/field called 'name' in the table you're trying to update... $query = "UPDATE {$db_prfix}mf_forums SET name = {$newname} WHERE name = {$row['fname']}"; Link to comment https://forums.phpfreaks.com/topic/105476-problem-mysql-pdate-with-php/#findComment-540260 Share on other sites More sharing options...
a1amattyj Posted May 13, 2008 Author Share Posted May 13, 2008 Without any more to go on it looks like the problem is simply with the line below at the bottom of the script you've posted - there is no column/field called 'name' in the table you're trying to update... $query = "UPDATE {$db_prfix}mf_forums SET name = {$newname} WHERE name = {$row['fname']}"; Ta, that was the issue, ive not got this error, but it still doesnt update that certain query. Unknown column 'test_topics' in 'field list' updating, matty to matty1. Link to comment https://forums.phpfreaks.com/topic/105476-problem-mysql-pdate-with-php/#findComment-540273 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.