hello I have a problem with my page. It just started happening. When I do a mysql Query, it pulls data from the database even though their are no entries in the rows. Here is the code that is pulling the database info:
echo"<font size=\"3\" face=\"verdana\" color=\"#ffffff\"><b>GIG LISTING</b><br><br></td></tr><tr>";
mysql_connect("localhost" , "******" , ******")
or die('Database is not responding.');
mysql_select_db("******") or die('Unable to connect to database');
$match2 = "SELECT gigs, gigtimedate, gigcover, gigcomments, gigstate, gigcity, gigaddress, gigcountry, gigzip FROM giglists WHERE gigemail = '$stemail'";
$qry2 = mysql_query($match2)
or die('Could not match data because of database error' . mysql_error());;
$num_rows2 = mysql_num_rows($qry2);
if ($num_rows2 <= 0){
echo"<td align=\"center\" valign=\"top\" bgcolor=\"#000000\" style=\"border:none\"><font size=\"2\" face=\"verdana\" color=\"#ffffff\"><b>No gigs have been listed yet!</b><br><br><form action=\"addgigs.php\" method=\"post\"><input type=\"image\" src=\"images/submitbutton.jpg\" name=\"postgigs\"><br>ADD GIGS NOW!!!!</form></td></tr></table></table></center></body>";
} else {
/* This sets to true even if all the above rows are empty. */
while ($row2 = mysql_fetch_array($qry2)){
$_SESSION['gigs'] = @unserialize($row2['gigs']);
$_SESSION['gigtimedate'] = @unserialize($row2['gigtimedate']);
$_SESSION['gigcover'] = @unserialize($row2['gigcover']);
$_SESSION['gigcomment'] = @unserialize($row2['gigcomments']);
$_SESSION['gigstate'] = @unserialize($row2['gigstate']);
$_SESSION['gigcity'] = @unserialize($row2['gigcity']);
$_SESSION['gigaddress'] = @unserialize($row2['gigaddress']);
$_SESSION['gigcountry'] = @unserialize($row2['gigcountry']);
$_SESSION['gigzip'] = @unserialize($row2['gigzip']);
}
echo"<td align=\"left\" valign=\"top\" bgcolor=\"#000000\" style=\"border:none\"><font size=\"2\" face=\"verdana\" color=\"#ffffff\">";
$gigcount = @count($_SESSION['gigs']);
$o = 1;
while ($o <= $gigcount){
$gigtime[$o] = @strtotime($_SESSION['gigtimedate'][$o]);
$o++;
}
$d = 1;
while ($d <= $gigcount){
$gigtime2[$d] = @strtotime($_SESSION['gigtimedate'][$d]);
$d++;
}
sort($gigtime);
$t = 0;
$f = 1;
$datecount = @count($_SESSION['gigs']);
while ($f <= $datecount){
$key = @array_search($gigtime[$t], $gigtime2);
if ($key !==""){
$newgigs[$f] = $_SESSION['gigs'][$key];
$newgigaddress[$f] = $_SESSION['gigaddress'][$key];
$newgigcity[$f] = $_SESSION['gigcity'][$key];
$newgigstate[$f] = $_SESSION['gigstate'][$key];
$newgigcity[$f] = $_SESSION['gigcity'][$key];
$newgigcover[$f] = $_SESSION['gigcover'][$key];
$newgigcomment[$f] = $_SESSION['gigcomment'][$key];
$newgigzip[$f] = $_SESSION['gigzip'][$key];
$newgigcountry[$f] = $_SESSION['gigcountry'][$key];
$newgigtimedate[$f] = @strtotime($_SESSION['gigtimedate'][$key]);
$r[$f] = $key;
}
$f++;
$t++;
}
$j = 1;
while ($j <= $gigcount){
echo"<b>Date:</b>"." ".date('F', $newgigtimedate[$j])." / ".date('d', $newgigtimedate[$j])." / ".date('Y', $newgigtimedate[$j])."<br><b>Time:</b> ".date('h', $newgigtimedate[$j]).":".date('i', $newgigtimedate[$j])." ".date('A', $newgigtimedate[$j])."<br>"."<b> Place:</b>"." ".@stripslashes($newgigs[$j])."<br>"."<b>Address:</b> ".@stripslashes($newgigaddress[$j]).","." ".@stripslashes($newgigcity[$j]).",".$newgigstate[$j].", ".@stripslashes($newgigzip[$j])."<br> "."<b>Cover:</b>"." "."$".@stripslashes($newgigcover[$j])." "."<br><br><b>Comments:</b>"." ".@stripslashes($newgigcomment[$j])."<br><br><hr width=\"500\" color=\"#888888\" noshade></td><td align=\"center\" valign=\"middle\" bgcolor=\"#000000\" style=\"border:none\"><form action=\"setsession.php\" method=\"post\"><input type=\"hidden\" name=\"existinggig\" value=\"".$newgigs[$j]."\"><input type=\"hidden\" name=\"order\" value=\"".$r[$j]."\"><input type=\"image\" src=\"images/editbutton.jpg\" name=\"editgigs\"><font size=\"2\" face=\"verdana\" color=\"#ffffff\"><br>Edit This Gig!!!</form></td></tr><br><tr><td align=\"left\" valign=\"top\ bgcolor=\"#0000000\" style=\"border:none\"><font size=\"2\" face=\"verdana\" color=\"#ffffff\">";
$j++;
}
echo"<br><br><br><br></td></tr><tr><td align=\"center\" valign=\"top\ bgcolor=\"#0000000\" style=\"border:none\"><font size=\"2\" face=\"verdana\" color=\"#ffffff\"><form action=\"setsession.php\" method=\"post\"><input type=\"hidden\" name=\"gignumber\" value=\"".@count($_SESSION['gigs'])."\"><input type=\"hidden\" name=\"addgigs\" value=\"yes\"><input type=\"image\" src=\"images/editbutton.jpg\" name=\"addgigs\"><font size=\"2\" face=\"verdana\" color=\"#ffffff\"><br>Add More Gigs!!!!</form></td></tr><table></table></center></body>";
}
ie. if the $row2 query is empty then I don't want it to set the session, however it still sets the session even if the $rows are empty.
I also can't get the database to pull data from the database that has ' in it. I haven't had this problem before. Thanks for any help you can provide.