-1

i have a script that works fine for years and suddenly i face this problem : please check the code and mend any solutionplease. any kind of help willbe appreciated.

Notice: Undefined variable: ids in /home/content/a/t/a/ataasaid1/html/category.php on line 4

Notice: Undefined variable: id in /home/content/a/t/a/ataasaid1/html/category.php on line 5

Notice: Use of undefined constant image - assumed 'image' in /home/content/a/t/a/ataasaid1/html/category.php on line 11

Notice: Use of undefined constant video - assumed 'video' in /home/content/a/t/a/ataasaid1/html/category.php on line 15

Notice: Use of undefined constant sound - assumed 'sound' in /home/content/a/t/a/ataasaid1/html/category.php on line 19

the code in file category.php is :

<?
  error_reporting(E_ALL | E_STRICT);
  ini_set("display_errors", 1);    
$id1=$ids;
$id2=$id;
                      include('config.php');

                    $result= mysql_query("SELECT * FROM products where id like '$id1' ;");
                    $row=mysql_fetch_array ($result);
                    $type=$row['type'];
                    if($type==image)
                    {
                    include('categories.php');
}
else if($type==video)
{
include('categories2.php');
}
else if($type==sound)
{
include('categories3.php');
}
?>

i use the url like:

/category.php?id=64&ids=305

thank you in advanced

  • 2
    I don't see where $ids and $id are defined...And, you missed quotes around video and sound : 'video', 'sound'. – Brice Nov 05 '13 at 13:26
  • 1) Your line 4 and 5 are different from what you posted here. 2) You're trying to access undefined constants in your code. Change `if($type==image)` to `if($type == "video")` (replace all similar occurrences) – Amal Murali Nov 05 '13 at 13:27
  • i use the url like: /category.php?id=64&ids=305 – user2956413 Nov 05 '13 at 13:51

3 Answers3

0

write like this:

if($type=="video")

else if($type=="sound")
Suresh Kamrushi
  • 15,627
  • 13
  • 75
  • 90
0

Are you looking for

$id1=$_GET["ids"];
$id2=$_GET["id"];

or

$id1=$_POST["ids"];
$id2=$_POST["id"];

???

Daniele Vrut
  • 2,835
  • 2
  • 22
  • 32
0

This error basically means that you're trying to use the variables $ids and $id, even though they do not exist. You need to define a variable before you can use it. Otherwise, you will get notices like this and your application will end up being a buggy mess. Because those two variables are not set and you are assigning them to other variables:

$id1 = $ids;
$id2 = $id;

Those variables are now useless, which means that your SQL query is also useless:

$result= mysql_query("SELECT * FROM products where id like '$id1' ;");

because $id1 isn't anything.

Wayne Whitty
  • 19,513
  • 7
  • 44
  • 66