Updating SQL with selection creteria

Hello,
I have a problem with a solution. I was trying to find the problem for days now with no lack.
In this project there is an option to change the template of the webpage accotding to 10 predefine templates.
Herewith is the code for the file change_template. When I execute this commant an error appears “OBJECT NOT FOUND”. I know tha SQL database has no problem because if I manually change the “templateid” number from lets say 1 -> 2 then my template is changing. So I thought that the problem might be is this code here.
Can you help me please?

[code]<?php

include("includes/functions.php");
include("includes/connect.php");
include('includes/config.php');
include('validate.php');
	
//ADD CATEGORY,DESCRIPTION AND IMAGE ON SUBMIT
$caption="Add";
$caption="Update";
$title="Choose Template Setting";

$sql="select * from ".$prefix."setting where id='1'";
$rs=mysql_query($sql) or die("Error".mysql_error());

if(mysql_num_rows($rs))
{
	$rows	  	 = mysql_fetch_object($rs);

	$templateid	 = $rows->templateid;   // type
	
}

if($_POST['submit'] == "Update")
{
	
	$templateid		= trim($_POST['templateid']);
		
			
	$query2="update ".$prefix."setting set templateid='$templateid' where id=1";
	$result2=mysql_query($query2) or die("Erron in updating".mysql_error());
	if($result2)
		$msg = "<center>Template Setting Updated Successfully...</center>";
	else
		$err="Erron in updating";	
	
}		

?>

  <?=$msg?> <?=$err?> method='post' enctype="multipart/form-data"> name="id"> name="start">
	<table width="90%" cellpadding="5" cellspacing="1" border="0" class="borderbrwn" align="center" >
		<tr>
			<td colspan="6"><font class="titleinner"><b><?=$title?></b></font> </td>
		</tr>
		<tr>  
				<td colspan="6" height="1" bgcolor="#990000">	</td>
		 </tr>
		
		<tr>
			<td  align='center'><img src="./template/template1.gif"><br><br><input class = textbox type=radio name=templateid value="1" <? if ($templateid == "1") echo 'checked'; ?> ></td>
			<td  align='center'><img src="./template/template2.gif"><br><br><input class = textbox type=radio name=templateid value="2" <? if ($templateid == "2") echo 'checked'; ?> ></td>
			<td  align='center'><img src="./template/template3.gif"><br><br><input class = textbox type=radio name=templateid value="3" <? if ($templateid == "3") echo 'checked'; ?> ></td>
		</tr>
		
		<tr>
			<td  align='center'><img src="./template/template4.gif"><br><br><input class = textbox type=radio name=templateid value="4" <? if ($templateid == "4") echo 'checked'; ?> ></td>
			<td  align='center'><img src="./template/template5.gif"><br><br><input class = textbox type=radio name=templateid value="5" <? if ($templateid == "5") echo 'checked'; ?> ></td>
			<td  align='center'><img src="./template/template6.gif"><br><br><input class = textbox type=radio name=templateid value="6" <? if ($templateid == "6") echo 'checked'; ?> ></td>
		</tr>
		
		<tr>
			<td  align='center'><img src="./template/template7.gif"><br><br><input class = textbox type=radio name=templateid value="7" <? if ($templateid == "7") echo 'checked'; ?> ></td>
			<td  align='center'><img src="./template/template8.gif"><br><br><input class = textbox type=radio name=templateid value="8" <? if ($templateid == "8") echo 'checked'; ?> ></td>
			<td  align='center'><img src="./template/template9.gif"><br><br><input class = textbox type=radio name=templateid value="9" <? if ($templateid == "9") echo 'checked'; ?> ></td>
		</tr>
		<tr>
			<td  align='center'><img src="./template/template10.gif"><br><br><input class = textbox type=radio name=templateid value="10" <? if ($templateid == "10") echo 'checked'; ?> ></td>
			<td  align='center'>&nbsp;</td>
			<td  align='center'>&nbsp;</td>
		</tr>
		    	<tr>
			<td colspan=3 align='center'><input type='submit' name='submit' class='button' value='<?=$caption?>'></td>
		</tr>
	</table>
</form>	
</td>
<? include('bottom.php'); ?>[/code]

What part of the script is causing the Error message to be displayed?

I am not sure. I press the update button which executed the mehtod =‘post’ and an error appears

Object not found!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster.

Error 404

What’s the URL of the page that’s being requested? Sounds like you’re calling a non-existent page.

I don`t think that this is the problem because when I change manually the SQL database this function works. I thing the problem is when I try to update the SQL database something is not working.

What query/queries are you running?

The queries that I am running are shown in my first post. I paste the code.

I’m seeing you doing this:

...
$sql="select * from ".$prefix."setting where id='1'";
...
$query2="update ".$prefix."setting set templateid='$templateid' where id=1";
...

But I don’t see you initializing $prefix, and it looks like $templateid is only initialized if a $_POST value is provided. Do some echo statements right before the mysql_query() calls and see what is being run.

Sponsor our Newsletter | Privacy Policy | Terms of Service