Darkmatter5 Posted October 13, 2008 Share Posted October 13, 2008 Here's the executed code: <?php function ret_info($search,$type,$field_id,$field) { include 'library/config.inc.php'; $conn=mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql'); mysql_select_db($dbnamemain); if($type=="cabinets") { $ident="cabinet_id"; } elseif($type=="folders") { $ident="folder_id"; } elseif($type=="items") { $ident="item_id"; } if(isset($_POST['cab_load']) || isset($_GET['cabinet_id'])) { if(isset($_GET['cabinet_id'])) { $field_id==$_GET['cabinet_id']; } if($search=="data") { /*$query="SELECT $field FROM $type WHERE $ident=$field_id"; $result=mysql_query($query) or die ($query. '<br>' .mysql_error()); $row=mysql_fetch_array($result); echo $row[$field];*/ echo $_GET['cabinet_id']. "<br>"; echo "field_id: $field_id<br>"; echo "search: $search<br>"; echo "type: $type<br>"; echo "field: $field"; } elseif($search=="count") { /*$query="SELECT $ident FROM $type WHERE $field=$field_id"; $result=mysql_query($query) or die ($query. '<br>' .mysql_error()); $count=mysql_num_rows($result); echo $count;*/ } } else { echo ""; } mysql_close($conn); } ?> Here's the code that runs the above code <?php $ec->ret_info(data,cabinets,$cabinet_id,cab_name); ?> And here's the URL variable "...myurl/res_detcab.php?cabinet_id=2 " Now here's the output: 2 field_id: search: data type: cabinets field: cab_name Why is field_id not being set? How can I fix this? Link to comment https://forums.phpfreaks.com/topic/128255-if-statement-and-url-passed-variable-problems/ Share on other sites More sharing options...
CroNiX Posted October 13, 2008 Share Posted October 13, 2008 $field_id==$_GET['cabinet_id']; should be $field_id=$_GET['cabinet_id']; since you are assigning a value and not comparing them there. Link to comment https://forums.phpfreaks.com/topic/128255-if-statement-and-url-passed-variable-problems/#findComment-664273 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.