0
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

Attachments Untitled.png 127.91 KB
2
Contributors
6
Replies
33
Views
3 Years
Discussion Span
Last Post by pzuurveen
0

adding this line on the top of coding

error_reporting(E_PARSE);
0

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

0

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='';
    }

Edited by pzuurveen

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.