Page won't display items from database

HI All,

I’m having an issue with this page. It used to work, but now it’s not pulling anything from the database. Can anyone help me with what might be causing it to break? All of the code looks right to me. I’m also attaching an image of what it currently looks like on the site. It looks like it is connecting to the database, and all the queries are working…

There should be a list of cars in the table…

[code]<?php
$make=$_POST[‘make’];
$model=$_POST[‘model’];

				$conn = mysql_connect('localhost', 'dadejeep_site', '******', 'dadejeep_usedcars');
				
				if ($conn->errno) {
					printf("Unable to connect to the database:</br> %s",
					$mysqli->error);
					
					exit();
				}
					
				if (!$make) 
					{
						$query1 = "select * from usedcars order by year desc";
						$result = mysql_query($query1, $conn);
						
						
					} else {
					
					
					switch ($model)
						{
						
						case "all": 
							$query2 = "select * from usedcars where make='$make' order by year desc";
							$result = mysql_query($query2, $conn);
							
							
							break;
							
						case "certified":
							$query3 = "select * from usedcars where certified='yes'";
							$result = mysql_query($query3, $conn);
							
							break;
						
						
						default:
							
							$query4 = "select * from usedcars where make='$make' and model='$model' order by year desc";
							$result = mysql_query($query4, $conn);
							
							
							break;
						}
						}
				
					$num_results = $result->num_rows;
					
					
					echo 'Search for:<strong> '.$make.' '.$model.'</strong><p>Number of Results Found:<strong> '.$num_results.'</strong><p>';
					
					echo '
					<table cellpadding="3" cellspacing="1" border="0" bgcolor="#666666" width="744">
				<tr>
					<td bgcolor="#D2DBF6">Result</td><td bgcolor="#D2DBF6">Image</td><td bgcolor="#D2DBF6">Year</td><td bgcolor="#D2DBF6">Make</td><td bgcolor="#D2DBF6">Model</td><td bgcolor="#D2DBF6">Color</td><td bgcolor="#D2DBF6">Miles</td><td bgcolor="#D2DBF6">VIN</td><td bgcolor="#D2DBF6">Stock Number</td><td bgcolor="#D2DBF6">Certified</td>
				</tr>';
					
					for ($i=0; $i <$num_results; $i++)
						{
							$row = mysql_fetch_assoc($result);
								echo'<tr><td bgcolor="#FFFFFF">'.($i+1).'</td>';
								echo'<td bgcolor="#FFFFFF"><a href="/preowned.php?stockno='.$row['stockno'].'"><img src="'.$row['thumbnail'].'" style="border: 1px; border-style: solid; border-color: #000000;"></a></td>';
								echo'<td bgcolor="#FFFFFF">'.$row['year'].'</td>';
								echo'<td bgcolor="#FFFFFF">'.$row['make'].'</td>';
								echo'<td bgcolor="#FFFFFF">'.$row['model'].'</td>';
								echo'<td bgcolor="#FFFFFF">'.$row['color'].'</td>';
								echo'<td bgcolor="#FFFFFF">'.$row['miles'].'</td>';
								echo'<td bgcolor="#FFFFFF"><a href="/preowned.php?stockno='.$row['stockno'].'" style="text-decoration: underline;">'.$row['vin'].'</a></td>';
								echo'<td bgcolor="#FFFFFF">'.$row['stockno'].'</td>';
								echo'<td bgcolor="#FFFFFF">';
										switch ($row['certified']) {
										
										case "yes":
											
											echo '<img src="/images/certified2.jpg"></div>';
										break;
										
										default:
										    echo '<br>';
										break;
										
										}
										echo '</td></tr>';
						}
					mysql_close($conn);
					
				?>[/code]

Any help is appreciated.

Thanks,
Jen

Any errors in the Error log regarding it?

I suspect you you have “display_errors=Off” in your PHP.INI file or you have it set to Severe errors only. I would think that statements like $make = $_POST[‘make’] would throw an error if make were not passed (you would get an index error).

This makes we wonder what other errors might be suppressed or not displayed. Probably want to check your error level and then the log for any errors.

Another thing I noticed is that your mysql_connect function has 4 parameters. Although this is allowed, the FOURTH parameter is intended to be a BOOLEAN and you are passing a string.

I also noticed that you are mixing mysql with mysqli. I am not sure if this is compatible or not. Perhaps someone else might know more about that.

Lastly if you manually run your “query” directly, do you get the desired results?

Sponsor our Newsletter | Privacy Policy | Terms of Service