MySQLi won't display database information

Codes here !

Moderators: gesf, Michalio

Post Reply
BelowZero

Trying to update an old website from MySQL to MySQLi. Connection to database is fine but the site won't display any information from the database. Probably a typo somewhere but my weary eyes aren't seeing it. Can anyone check the coding for mistakes? Thanks.

www.beat-the-spread.net

Code: Select all

<?php include("opendatabase.php"); ?>

							<?php

							for ($i = 1; $i <= 8; $i++) 
							{
								echo "<div class='gameholder'><div class ='textholder2'>";
								$result = mysqli_query($con, "
								SELECT * 
								FROM schedule
								JOIN teams ON schedule.team = teams.team_id
								WHERE week_id ='10'
								AND game_id ='$i'");
 
								echo "<table class='schedule'>\n";

								while($row = mysqli_fetch_array( $result )) 
								{
									if($row['pt_spread'] == 0)
									{
										$row['pt_spread'] = "";
									}
									if(empty($row['pt_spread'] ))
									{
									$row['pt_spread'] = "";
									}

									if (empty($row['bye']))
									{
									echo "</td><td class='schedule' width='51%'>"; echo $row['alt_name'];
									echo "</td><td class='schedule' width='25%' style='color:#ffffff;'>"; echo $row['pt_spread'];
									echo "</td><td class='schedule' width='16%'>"; echo $row['team_pts'];
									echo "</td></tr>";
									}
								}
		
								echo "</table>";
								echo "<br />";
								echo "</div> <!-- textholder2 --></div><!-- gameholder -->";
							}

							mysqli_close($con);
							?>
hyper

Please don't take this the wrong way, but, you've missed the point of changing from mysql_***, not all mysql_ calls translate to mysqli_ calls.

The point was to allow time to get used to using prepared statements for security reasons. What I suggest you do is learn PDO instead of MySQLi, it offers many benefits over the old, outdated and deprecated functions that you have been using. It's not that hard to learn and removes the potential SQL injections and might offer an increase in execution speed in the looped example you have shown.
Post Reply