[HELP]Undefined Varible
Posted: Sat Aug 21, 2004 10:15 am
code (note starting at line 23):
---
Errors:
Line 36:
Line 45:
Line 54:
Line 63:
Line 72:
-------------------------
I ran the script thro Zend Dev Environment, but it didnt pickup anything - do you guys see any problems with the script?
Edit: when i run the script like "index.php?id=genre" it wont display the errors
Code: Select all
<?php
error_reporting(E_ALL);
switch ($id) {
default:
$dbh=mysql_connect ("localhost", "<hidden>", "<hidden>") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("cds");
$sql = "SELECT * FROM cds ORDER BY name";
echo mysql_error();
$result = mysql_query($sql, $dbh);
echo mysql_error();
break;
case 'cdname':
$dbh=mysql_connect ("localhost", "<hidden>", "<hidden>") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("cds");
$sql = "SELECT * FROM cds ORDER BY cdname";
echo mysql_error();
$result = mysql_query($sql, $dbh);
echo mysql_error();
break;
case 'genre':
$dbh=mysql_connect ("localhost", "<hidden>", "<hidden>") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("cds");
$sql = "SELECT * FROM cds ORDER BY genre";
echo mysql_error();
$result = mysql_query($sql, $dbh);
echo mysql_error();
break;
case 'tracks':
$dbh=mysql_connect ("localhost", "<hidden>", "<hidden>") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("cds");
$sql = "SELECT * FROM cds ORDER BY tracks";
echo mysql_error();
$result = mysql_query($sql, $dbh);
echo mysql_error();
break;
case 'rlsdate':
$dbh=mysql_connect ("localhost", "<hidden>", "<hidden>") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("cds");
$sql = "SELECT * FROM cds ORDER BY rlsdate";
echo mysql_error();
$result = mysql_query($sql, $dbh);
echo mysql_error();
break;
case 'rlsgroup':
$dbh=mysql_connect ("localhost", "<hidden>", "<hidden>") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("cds");
$sql = "SELECT * FROM cds ORDER BY rlsgroup";
echo mysql_error();
$result = mysql_query($sql, $dbh);
echo mysql_error();
break;
}Errors:
----Notice: Undefined variable: id in c:\program files\apache group\apache\htdocs\cdview.php on line 36
Notice: Undefined variable: id in c:\program files\apache group\apache\htdocs\cdview.php on line 45
Notice: Undefined variable: id in c:\program files\apache group\apache\htdocs\cdview.php on line 54
Notice: Undefined variable: id in c:\program files\apache group\apache\htdocs\cdview.php on line 63
Notice: Undefined variable: id in c:\program files\apache group\apache\htdocs\cdview.php on line 72
Line 36:
Code: Select all
case 'cdname':Code: Select all
case 'genre':Code: Select all
case 'tracks':Code: Select all
case 'rlsdate':Code: Select all
case 'rlsgroup':I ran the script thro Zend Dev Environment, but it didnt pickup anything - do you guys see any problems with the script?
Edit: when i run the script like "index.php?id=genre" it wont display the errors