Hello all,
I'm trying to use a variable I'm passing via URL to complete a mysql_query.
Here's the URL, as it appears at the top of the Chrome browser:
localhost/podadmin-0.5.1/episode_editor.php?action=edit&guid=100D1274-4EF6-5F92-3050-924811BA108E
I have two lines within my code, one which uses a variable within the mysql_query statement, and one with the value hard coded.
If I use the line that has the $val variable, I get the error:
Warning: mysql_result() expects parameter 1 to be resource, boolean given in /media/CHATEAU/robertjm/www/podadmin-0.5.1/episode_editor.php on line 21 (errors repeat for lines 22 thru 36 and 39).
However, using the hard coded value, the script will return the proper information.
<?PHP
// Report all PHP errors
ini_set('error_reporting', E_ALL);
// Set the display_errors directive to On
ini_set('display_errors', 1);
$con = mysql_connect("localhost", "user", "password");
$db_selected = mysql_select_db('podadmin', $con);
$val = $_GET['guid'];
echo "the GUID is: $val\n <br />";
$result = mysql_query('SELECT * from episodes WHERE guid="100D1274-4EF6-5F92-3050-924811BA108E"') or dieWithError("mysql query error: " . mysql_error());
// $result = mysql_query("SELECT * from episodes WHERE guid=`$val`"); //or dieWithError("mysql query error: " . mysql_error());
$field_guid=mysql_result($result, 0, "guid");
$field_id=mysql_result($result,0,"id");
$field_title=mysql_result($result, 0,"title");
$field_subtitle=mysql_result($result,0,"subtitle");
$field_keywords=mysql_result($result,0,"keywords");
$field_explicit=mysql_result($result,0,"explicit");
$field_isClosedCaptioned=mysql_result($result,0,"isClosedCaptioned");
$field_author=mysql_result($result,0,"author");
$field_description=mysql_result($result,0,"description");
$field_pubdate=mysql_result($result,0,"pubdate");
$field_puzZoneOffset=mysql_result($result,0,"pubZoneOffset");
$field_blockEpisode=mysql_result($result,0,"blockEpisode");
$field_size=mysql_result($result,0,"size");
$field_duration=mysql_result($result,0,"duration");
$field_folder=mysql_result($result,0,"folder");
$field_filename=mysql_result($result,0,"filename");
echo mysql_result($result,0,'title');
mysql_close();
?>