Page 1 of 1
undefined variables
Posted: Thu Oct 31, 2002 5:55 am
by jonat8
Hi,
Can anyone help me with this code? When I run it I get ther errors:
Notice: Undefined variable: D1 in C:\Xitami\webpages\ukr\epg.php on line 20
and
Notice: Undefined variable: searchcriteria in C:\Xitami\webpages\ukr\epg.php on line 20
The code is as follows ("x's" substituted where IPs, authentication information etc. are)
Code: Select all
<?php
echo("<font face=tahoma><h2><b><u>Showing EPG events.</u></h2></b>\n");
echo("<b>Search Results: Click on the file's title to start the player.</b><br><br>");
$dbconn = mysql_connect("xxx.xxx.xx.xxx", "xxxxx", "xxxxxxx");
$result = mysql_select_db("ukradioprogs", $dbconn);
if ( $result == false )
{
echo mysql_error();
} else {
$sql = "SELECT * from progs WHERE ".$D1." = '".$searchcriteria."'";
$result = mysql_query( $sql );
if ( $result != false )
{
while ( $data = mysql_fetch_assoc( $result ) )
{
echo 'Track Details: '.
$dataї'prognumber'].' (<a href="javascript:playMedia('.
$dataї'progfilename'].')"><b>'.
$dataї'prognowon'].'</a></b>)<br>';
}
} else {
echo ("Please enter your search criteria below! Thank you.");
}
}
?>
Underneath that code in the same file is some HTML code that contains a form:
<form action="epg.php" method="post">
<select name="D1" size="1">
<option selected value="prognowon">media title</option>
<option value="proglevel">subscription level</option>
<option value="prognumber">content provider</option>
</select>
=
<input type="text" name="searchcriteria">
<input type="submit">
</form>
---
But whenever I open the PHP doc or submit the form I am getting that error. I am running PHP 4.2.3 on Xitami.
---
Does this have something to do with the register_globals problem? I tried setting it to on and off but it still doesn't seem to work, or am I doing something wrong?
Thanks
jonat8
Posted: Thu Oct 31, 2002 6:32 am
by twigletmac
You need to have some way of determining whether the form has been submitted or not, a hidden field in your form could be used for that:
Code: Select all
<input type="hidden" name="action" value="post">
then you can adjust your PHP code to something like:
Code: Select all
<?php
if (!empty($_POSTї'action'])) {
echo '<font face=tahoma><h2><b><u>Showing EPG events.</u></h2></b>'."\n";
echo '<b>Search Results: Click on the file''s title to start the player.</b><br><br>';
$dbconn = mysql_connect('xxx.xxx.xx.xxx', 'xxxxx', 'xxxxxxx') or die(mysql_error());
$result = mysql_select_db('ukradioprogs') or die(mysql_error());
$sql = "SELECT prognumber, progfilename, prognowon from progs WHERE ".$D1." = '".$searchcriteria."'";
$result = mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');
if (mysql_num_rows($result) > 0) {
while ($data = mysql_fetch_assoc($result)) {
echo 'Track Details: '.
$dataї'prognumber'].' (<a href="javascript:playMedia('.
$dataї'progfilename'].')"><b>'.
$dataї'prognowon'].'</a></b>)<br>';
}
} else {
echo 'Please enter your search criteria below! Thank you.';
}
} else {
echo 'Please enter your search criteria below! Thank you.';
}
?>
Mac
Posted: Thu Oct 31, 2002 7:38 am
by jonat8
Hi, thanks for replying
I tried your code and it still didn't work, I got the exact 2 same variable undefined errors that I posted above, and also:
You have an error in your SQL syntax near '= ''' at line 1
Sorry for being a pain, I'm kind of new to this. The code I posted above worked on another site fine, but the field names were different and obviously the server address was different but that was all I changed.
The entire code I'm using now is below (bit of a long read, I'm afraid)
Code: Select all
<title>Search<title>
<body>
<?php
if (!empty($_POSTї'action'])) {
echo '<font face=tahoma><h2><b><u>Showing EPG events.</u></h2></b>'."\n";
echo '<b>Search Results: Click on the file''s title to start the player.</b><br><br>';
$dbconn = mysql_connect('169.254.40.112', 'jonat8', 'viijwk') or die(mysql_error());
$result = mysql_select_db('ukradioprogs') or die(mysql_error());
$sql = "SELECT prognumber, progfilename, prognowon from progs WHERE ".$D1." = '".$searchcriteria."'";
$result = mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');
if (mysql_num_rows($result) > 0) {
while ($data = mysql_fetch_assoc($result)) {
echo 'Track Details: '.
$dataї'prognumber'].' (<a href="javascript:playMedia('.
$dataї'progfilename'].')"><b>'.
$dataї'prognowon'].'</a></b>)<br>';
}
} else {
echo 'Please enter your search criteria below! Thank you.';
}
} else {
echo 'Please enter your search criteria below! Thank you.';
}
?>
<center>
<img src="http://www.lovelarisa.org/exphorsa.gif" width=300 height=10>
</center>
<SCRIPT LANGUAGE=JavaScript>
function playMedia(filename) {
WindowsMediaPlayer.FileName = "http://localhost/ukrmedia/" + filename
}
</SCRIPT>
<br><br>
<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" width="287" height="228" id="WindowsMediaPlayer" border="1">
<param name="AudioStream" value="-1">
<param name="AutoSize" value="0">
<param name="AutoStart" value="-1">
<param name="AnimationAtStart" value="-1">
<param name="AllowScan" value="-1">
<param name="AllowChangeDisplaySize" value="-1">
<param name="AutoRewind" value="0">
<param name="Balance" value="0">
<param name="BufferingTime" value="15">
<param name="ClickToPlay" value="-1">
<param name="CursorType" value="0">
<param name="CurrentPosition" value="-1">
<param name="CurrentMarker" value="0">
<param name="DisplayBackColor" value="0">
<param name="DisplayForeColor" value="16777215">
<param name="DisplayMode" value="0">
<param name="DisplaySize" value="4">
<param name="Enabled" value="-1">
<param name="EnableContextMenu" value="0">
<param name="EnablePositionControls" value="-1">
<param name="EnableFullScreenControls" value="0">
<param name="EnableTracker" value="-1">
<param name="InvokeURLs" value="-1">
<param name="Language" value="-1">
<param name="Mute" value="0">
<param name="PlayCount" value="1">
<param name="PreviewMode" value="0">
<param name="Rate" value="1">
<param name="SelectionStart" value="-1">
<param name="SelectionEnd" value="-1">
<param name="SendOpenStateChangeEvents" value="-1">
<param name="SendWarningEvents" value="-1">
<param name="SendErrorEvents" value="-1">
<param name="SendKeyboardEvents" value="0">
<param name="SendMouseClickEvents" value="0">
<param name="SendMouseMoveEvents" value="0">
<param name="SendPlayStateChangeEvents" value="-1">
<param name="ShowCaptioning" value="0">
<param name="ShowControls" value="-1">
<param name="ShowAudioControls" value="-1">
<param name="ShowDisplay" value="0">
<param name="ShowGotoBar" value="0">
<param name="ShowPositionControls" value="-1">
<param name="ShowStatusBar" value="-1">
<param name="ShowTracker" value="-1">
<param name="TransparentAtStart" value="0">
<param name="VideoBorderWidth" value="0">
<param name="VideoBorderColor" value="0">
<param name="VideoBorder3D" value="0">
<param name="Volume" value="-410">
<param name="WindowlessVideo" value="0">
</object><br>
<b><u>Search for media below. <a href="epg.php">Click here to show all media</a></u></b><br>
<form action="epg.php" method="post">
<select name="D1" size="1">
<option selected value="prognowon">media title</option>
<option value="proglevel">subscription level</option>
<option value="prognumber">content provider</option>
</select>
=
<input type="text" name="searchcriteria">
<input type="submit">
<input type="hidden" name="action" value="post">
</form>
<br><br>
Any suggestions would be greatly appreciated to why this isn't working! Thanks.
jonat8
Posted: Thu Oct 31, 2002 7:50 am
by twigletmac
I missed one thing:
Code: Select all
$sql = "SELECT prognumber, progfilename, prognowon from progs WHERE ".$D1." = '".$searchcriteria."'";
your SQL statement should be
Code: Select all
$sql = "SELECT prognumber, progfilename, prognowon from progs WHERE ".$_POSTї'D1']." = '".$_POSTї'searchcriteria']."'";
Please read this:
viewtopic.php?t=511
Mac
Posted: Thu Oct 31, 2002 10:16 am
by jonat8
Thank you very much

It worked perfectly.
jonat8