I am having the hardest time trying to figure out what I am doing wrong with this section of code. Basically, I am using the GET method to pull a variable from the URL which I then want to search the database for. This "ticket" is unique and I only want to pull the one row of info and store that into a array and then separate out the info and display that info. Here is my code:
<?php
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
$ticket = clean($_GET['ticket']);
echo $ticket;
$query = "SELECT * FROM notice_info WHERE notice_code= '$ticket'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$sessionCode= $row[1];
$sessionText= $row[2];
echo "<b>$sessionCode</b><br>Phone: $sessionText<br>";
echo $sessionCode;
echo $sessionText;
mysql_close();
?>
The error I keep getting is: "Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in..." and refers to line 31 which is actually line 14 above:
$row = mysql_fetch_array($result);
I am also seeing no record being displayed at all, just the error.
What am I doing wrong? I am somewhat new at this so any help is appreciated. Thanks in advance.