timmah1 Posted May 6, 2009 Share Posted May 6, 2009 I have a script that grab everything from the database depending on a package type, then shows everything according to the package type. There are 6 packages, everything shows perfect for package 1-5, but for the 6th package, the $hint part does not show. The hint is actually a rollover Can anybody look at the code and tell me why this part of the code don't show the hint? case "6-spl": $Ddate = date("Y-m-d"); $firstDate = date("Y-m-01"); $lastDate = date("Y-m-d", strtotime("-1 Day")); $Dtime = date("H:i"); $query1 = "SELECT * FROM packages1 WHERE sport = '$sport' AND start = '".date("Y-m-d")."'"; $w1 = mysql_query($query1); $numrows = mysql_num_rows($w1); if($numrows == 0 ){ //echo "No special for today"; $query3 = "SELECT * FROM packages1 WHERE sport = '$sport' AND start BETWEEN '$firstDate' AND '$lastDate' ORDER BY id DESC LIMIT 1"; $w3 = mysql_query($query3); while($b3 = mysql_fetch_array($w3)){ $id = $b3['id']; $end = date("Y-m-d h:i:s", strtotime($b3['exp'])); $id = $b3['id']; $name = $b3['name']; $package = $b3['package']; $start = date("Y-m-d h:i:s"); $hint = $b2['hint']; $price = $b3['price']; } } elseif($numrows > 0){ //echo "There is a special for today<br />"; $query1 = "SELECT * FROM packages1 WHERE sport = '$sport' AND start = '".date("Y-m-d")."' AND '".date("H:i")."' >= starttime ORDER BY starttime DESC LIMIT 1"; $w1 = mysql_query($query1); $numrows = mysql_num_rows($w1); if($numrows == 0 ) { //echo "Special for today hasn't started yet<br />"; $query1 = "SELECT * FROM packages1 WHERE sport = '$sport' AND start BETWEEN '$firstDate' AND '$lastDate' ORDER BY id DESC LIMIT 1"; $w1 = mysql_query($query1); } while($b2 = mysql_fetch_array($w1)){ //echo "Start time: $b2[starttime]<br />Current time: $Dtime<br />Special for current time"; $id = $b2['id']; $end = date("Y-m-d h:i:s", strtotime($b2['exp'])); $id = $b2['id']; $name = $b2['name']; $package = $b2['package']; $start = date("Y-m-d h:i:s"); $hint = $b2['hint']; $price = $b2['price']; } } break; Here is the entire code <?php $sport = "nba"; //$sport = "nfl"; //$sport = "ncaaf"; //$sport = "ncaab"; switch($sport){ case "nba": $title = "NBA Basketball"; break; case "nfl": $title = "NFL Football"; break; case "ncaaf": $title = "NCAA Football"; break; case "ncaab": $title = "NCAA Basketball"; break; } ?> <!--start NCAA Football table--> <table width="100%" cellpadding="3" border="1" cellspacing="0" height="175"> <tr> <td align="center" height="15" bgcolor="#000000" class="orderHeader"><?=$title;?></td> </tr> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td height="25" align="left" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <?php $sql = "SELECT * FROM packages1 WHERE sport = '$sport' ORDER BY package LIMIT 6"; $q = mysql_query($sql); $numrows = mysql_num_rows($q); if($numrows == 0){ echo "nothing"; } while($a = mysql_fetch_assoc($q)){ //put variables into easily read $id = $a['id']; $name = $a['name']; $package = $a['package']; $start = date("Y-m-d h:i:s"); $price = $a['price']; switch($package){ case "1-sngl": $end = date("Y-m-d 23:59:59"); $hint = $a['hint']; break; case "2-ult": $end = date("Y-m-d 23:59:59", strtotime('+7 days')); $hint = $a['hint']; break; case "3-mnth": $end = date("Y-m-d 23:59:59", strtotime('+30 days')); $hint = $a['hint']; break; case "4-ssn": $end = date("Y-m-d h:i:s", strtotime($a['exp'])); $hint = $a['hint']; break; case "5-po": $end = date("Y-m-d h:i:s", strtotime($a['exp'])); $hint = $a['hint']; break; case "6-spl": $Ddate = date("Y-m-d"); $firstDate = date("Y-m-01"); $lastDate = date("Y-m-d", strtotime("-1 Day")); $Dtime = date("H:i"); $query1 = "SELECT * FROM packages1 WHERE sport = '$sport' AND start = '".date("Y-m-d")."'"; $w1 = mysql_query($query1); $numrows = mysql_num_rows($w1); if($numrows == 0 ){ //echo "No special for today"; $query3 = "SELECT * FROM packages1 WHERE sport = '$sport' AND start BETWEEN '$firstDate' AND '$lastDate' ORDER BY id DESC LIMIT 1"; $w3 = mysql_query($query3); while($b3 = mysql_fetch_array($w3)){ $id = $b3['id']; $end = date("Y-m-d h:i:s", strtotime($b3['exp'])); $id = $b3['id']; $name = $b3['name']; $package = $b3['package']; $start = date("Y-m-d h:i:s"); $hint = $b2['hint']; $price = $b3['price']; } } elseif($numrows > 0){ //echo "There is a special for today<br />"; $query1 = "SELECT * FROM packages1 WHERE sport = '$sport' AND start = '".date("Y-m-d")."' AND '".date("H:i")."' >= starttime ORDER BY starttime DESC LIMIT 1"; $w1 = mysql_query($query1); $numrows = mysql_num_rows($w1); if($numrows == 0 ) { //echo "Special for today hasn't started yet<br />"; $query1 = "SELECT * FROM packages1 WHERE sport = '$sport' AND start BETWEEN '$firstDate' AND '$lastDate' ORDER BY id DESC LIMIT 1"; $w1 = mysql_query($query1); } while($b2 = mysql_fetch_array($w1)){ //echo "Start time: $b2[starttime]<br />Current time: $Dtime<br />Special for current time"; $id = $b2['id']; $end = date("Y-m-d h:i:s", strtotime($b2['exp'])); $id = $b2['id']; $name = $b2['name']; $package = $b2['package']; $start = date("Y-m-d h:i:s"); $hint = $b2['hint']; $price = $b2['price']; } } break; } ?> <tr> <td height="25" align="left" valign="middle"> <span class="purchase"> <?php if($a['price'] == "") { $price = ""; $price_box = "<input name='package_[$name]' type='checkbox' value='$package,$price,$end,$sport' disabled/>"; $dollar = ""; echo $price_box." ".$name; } else { $price1 = number_format ($price, 2); $price = $price1; $price_box = "<input name='package_[$name]' type='checkbox' value='$package,$price,$end,$sport,$id'/>"; $dollar = "$"; echo $price_box." ".$name; } if($hint == "") { } else { ?> <a href="#" onMouseOver="showhint('<?=$hint; ?>', this, event, '200px')">[?]</a> <?php } ?> <br /> </span></td> <td width="55" align="right" valign="middle"><span class="purchase"><?=$dollar;?><?=$price;?> </span></td> </tr> <?php }; ?> </table> <span class="purchase"></span></td> </tr> </table> </td> </tr> </table> <br /> Thanks in advance Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 6, 2009 Share Posted May 6, 2009 When you did a "view source" of the page in your browser to check it, was there data everywhere you expected? Does the data possibly contain any HTML characters <, >, ", or ' that could break the HTML on your page? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 6, 2009 Share Posted May 6, 2009 $hint = $b2['hint']; Did you mean $b3['hint']? Quote Link to comment Share on other sites More sharing options...
timmah1 Posted May 6, 2009 Author Share Posted May 6, 2009 If I echo everything out, it shows with no problem. When you mouseover the [?] on the page, it shows the hint It does that with the top 5, but not the last You can see what I mean here if you want https://www.secure.vegasdsports.com/test/ Quote Link to comment Share on other sites More sharing options...
timmah1 Posted May 6, 2009 Author Share Posted May 6, 2009 I correct that Ken2k7, but it's still not showing Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 6, 2009 Share Posted May 6, 2009 Which is the last one? Wednesday's NBA Basketball 2 Games Playoff Special [?] ^ Is that it? Quote Link to comment Share on other sites More sharing options...
timmah1 Posted May 6, 2009 Author Share Posted May 6, 2009 Correct That one is this code case "6-spl": $Ddate = date("Y-m-d"); $firstDate = date("Y-m-01"); $lastDate = date("Y-m-d", strtotime("-1 Day")); $Dtime = date("H:i"); $query1 = "SELECT * FROM packages1 WHERE sport = '$sport' AND start = '".date("Y-m-d")."'"; $w1 = mysql_query($query1); $numrows = mysql_num_rows($w1); if($numrows == 0 ){ //echo "No special for today"; $query3 = "SELECT * FROM packages1 WHERE sport = '$sport' AND start BETWEEN '$firstDate' AND '$lastDate' ORDER BY id DESC LIMIT 1"; $w3 = mysql_query($query3); while($b3 = mysql_fetch_array($w3)){ $id = $b3['id']; $end = date("Y-m-d h:i:s", strtotime($b3['exp'])); $id = $b3['id']; $name = $b3['name']; $package = $b3['package']; $start = date("Y-m-d h:i:s"); $hint = $b3['hint']; $price = $b3['price']; } } elseif($numrows > 0){ //echo "There is a special for today<br />"; $query1 = "SELECT * FROM packages1 WHERE sport = '$sport' AND start = '".date("Y-m-d")."' AND '".date("H:i")."' >= starttime ORDER BY starttime DESC LIMIT 1"; $w1 = mysql_query($query1); $numrows = mysql_num_rows($w1); if($numrows == 0 ) { //echo "Special for today hasn't started yet<br />"; $query1 = "SELECT * FROM packages1 WHERE sport = '$sport' AND start BETWEEN '$firstDate' AND '$lastDate' ORDER BY id DESC LIMIT 1"; $w1 = mysql_query($query1); } while($b2 = mysql_fetch_array($w1)){ //echo "Start time: $b2[starttime]<br />Current time: $Dtime<br />Special for current time"; $id = $b2['id']; $end = date("Y-m-d h:i:s", strtotime($b2['exp'])); $id = $b2['id']; $name = $b2['name']; $package = $b2['package']; $start = date("Y-m-d h:i:s"); $hint = $b2['hint']; $price = $b2['price']; } } break; Quote Link to comment Share on other sites More sharing options...
timmah1 Posted May 6, 2009 Author Share Posted May 6, 2009 I echoed out the hints on that page so if you go to it, you'll see that it does show Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 6, 2009 Share Posted May 6, 2009 Does the data possibly contain any HTML characters <, >, ", or ' that could break the HTML on your page? Well it does. You must use htmlentities() with the second parameter ENT_QUOTES when you output content that could contain HTML special characters. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 6, 2009 Share Posted May 6, 2009 ^ read above. To explain why - the single quote in Wednesday's is killing your single quote in your JavaScript. Quote Link to comment Share on other sites More sharing options...
timmah1 Posted May 6, 2009 Author Share Posted May 6, 2009 ok, I have this now <a href="#" onMouseOver="showhint('<?=htmlentities($hint, ENT_QUOTES); ?>', this, event, '200px')">[?]</a><br />THIS IS THE HINT<br /><?=$hint; ?> And it still doesn't show Quote Link to comment Share on other sites More sharing options...
Brian W Posted May 6, 2009 Share Posted May 6, 2009 Theory, 'hint' isn't the name of the field... idk, maybe way off. (remember, if its 'Hint', 'hint' wont work) while($b3 = mysql_fetch_array($w3)){ die(nl2br(print_r($b3, TRUE)));//This will kill the application and feed out the variables, copy and paste the output into a reply. $id = $b3['id']; $end = date("Y-m-d h:i:s", strtotime($b3['exp'])); $id = $b3['id']; $name = $b3['name']; $package = $b3['package']; $start = date("Y-m-d h:i:s"); $hint = $b3['hint']; $price = $b3['price']; } Quote Link to comment Share on other sites More sharing options...
timmah1 Posted May 6, 2009 Author Share Posted May 6, 2009 hint is the field name, all lowercase Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 6, 2009 Share Posted May 6, 2009 Oops, I thought ... nevermind. Overlooked his function. Use htmlspecialchars($hint, ENT_QUOTES). Quote Link to comment Share on other sites More sharing options...
timmah1 Posted May 6, 2009 Author Share Posted May 6, 2009 ok, I figured it out When it's being put in, it's inputting it normal in the database Wednesday's 2 Game Playoff Special Now, when I echo it out, I did this $hint = addslashes($b3['hint']); htmlentities($hint, ENT_QUOTES); And it works now. Thank you for your help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.