Help with php-mysql retreive script

Hey, I don’t know whats wrong…
I have checked everywhere, but all i get when I run the script is a white screen???

Please review the following script and tell me whats wrong with it, thanks.

[php]<?php
require (‘connect.php’);
$vehicles = mysql_query(“SELECT*FROM vehicles”) or die (mysql_error());
while($info = mysql_fetch_array($vehicles)){
?>

body,td,th { font-family: Verdana, Geneva, sans-serif; font-size: xx-large; color: #000; }
<? echo $info['id']; ?> <? echo $info['make']; ?> <? echo $info['model']; ?> <? echo $info['year']; ?>
<?php } mysql_close() or die (mysql_error()); ?>[/php]

xxPIRANHAxx

first put that outside your query it actually goes in your tags

put these

<? echo $info['id']; ?> <? echo $info['make']; ?> <? echo $info['model']; ?> <? echo $info['year']; ?>
outside your query also see what happens

and what does your connect.php have in it

Assuming your connect.php is working, you only want to loop through the html table rows:[php]

body,td,th {font:normal xx-large Verdana,Geneva,sans-serif;} <?php require ('connect.php'); $vehicles = mysql_query("SELECT * FROM `vehicles`") or die (mysql_error()); while($info = mysql_fetch_array($vehicles)){ ?> <?php } mysql_close() or die (mysql_error()); ?>
<? echo $info['id']; ?> <? echo $info['make']; ?> <? echo $info['model']; ?> <? echo $info['year']; ?>
[/php]

Vision Hive, I have tried what you posted, but still all i get is a blank page…:frowning:
This is what i have for my connect.php
I you think it is out of date, tell me what i need to change please…

<?php $host="localhost"; $username="root"; $password=""; $db_name="daytonaspeed"; mysql_connect("$host","$username","$password") or die (mysql_error()); mysql_select_db("$db_name") or die (mysql_error()); ?>

and this is the script that i modified

[code]

body,td,th { font-family: Verdana, Geneva, sans-serif; font-size: xx-large; color: #000; } <?php require ('connect.php'); $vehicles = mysql_query("SELECT*FROM vehicles") or die (mysql_error()); while($info = mysql_fetch_array($vehicles)){ ?> <?php } mysql_close() or die (mysql_error()); ?>
<? echo $info['id']; ?> <? echo $info['make']; ?> <? echo $info['model']; ?> <? echo $info['year']; ?>
[/code]

I was thinking about this, might it be because I am only trying to display select information from my database, for example:
In my database I have Make, Model, Price, Year, Style, Interior color, Exterior color etc…
I am only trying to display the stuff in my code though, I dont know if it will cause problems like this.
thanks for the help

does the database contain at least 1 record?
also maybe the ini set has a default value for not showing notice for underfind index

put this at the top of your script
[php]
error_reporting(E_ALL);
ini_set(‘display_errors’, ‘1’);
[/php]

your code works i dont think your code

  1. is not connecting to the database
  2. doesnt have anything in database
Sponsor our Newsletter | Privacy Policy | Terms of Service