if(isset($_GET['Id'])){
$Id=$_GET['Id'];
$query = mysql_query("SELECT * FROM page WHERE ID='$Id'");
$row = mysql_fetch_array($query);
$PageId=$row['PageId'];
$MenuName=$row['MenuName'];
$ParentMenuId=$row['ParentMenuId'];
$LinkWidth=$row['LinkWidth'];
$OtherUrl=$row['OtherUrl'];
$Status1=$row['Status'];
$OnMainMenu=$row['OnMainMenu'];
$FooterMenu=$row['FooterMenu'];
}
?>
<form style="width:100%" action="" method="post" id="form1">
<table class="viewjob" align="center" >
<tr class="tableheader">
<td align="center" colspan="4"> Update </td>
</tr>
<tr class="tablerow">
<td>Page Id</td>
<td><select name='PageId' class="select">
<option  value='0' >select any page</option>

<?php
$sql10 = "SELECT Id,Title FROM abc";
$val=$row['PageId']?:'';
$rs = mysql_query($sql10) or die(mysql_error());
while($row = mysql_fetch_array($rs)){
$selected = ($val == $row['Id'] ? 'selected="selected"' : '');
echo '<option value ="' . $row['Id'] . '" '. $selected .'>' . $row['Title'] . '</option>';

}
mysql_free_result($rs);
?>
</select>
</td>

i am insert and update on the same php page
this code is run in update but the error of Illegal string offset 'PageId' is on insert

if $_GET['Id'] (line 1) is not set, $row['PageId'] (line 27) will no exist

adding this line on the top of coding

error_reporting(E_PARSE);

That just turns off any error message below E_PARSE level.
It doesnot solve the error.

so how can i do this
if $_GET['Id'] (line 1) is not set, $row['PageId'] (line 27) will no exist
can you please apply and send me

and can you solve my this problem @pzuurveen
Click Here

I didn't give you the solution because you already know it.
isset() will test test if a var exists without giving an error.
Simular as you do on line 1.
empty() whill test if i has a value that is not FALSE
combining the 2:

if( isset($row['PageId']) && !empty($row['PageId']) )   
    {
    $val=$row['PageId'];
    }
else 
    {
    $val='';
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.