Jump to content

if statement and URL passed variable problems


Darkmatter5

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.