Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
CoolAsCarlito
Forum Contributor
Posts: 192 Joined: Sat May 31, 2008 3:27 pm
Contact:
Post
by CoolAsCarlito » Sun Jun 08, 2008 11:55 am
Without showing my database info when I run this script it says this error message:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Show Archives' at line 1
Code: Select all
<?php
// Connects to your Database
$data = mysql_query("SELECT * FROM Show Archives")
or die(mysql_error());
Print "<table border cellpadding=3>";
while($info = mysql_fetch_array( $data ))
{
Print "<tr>";
Print "<th>Show Name</th> <td>".$info['showname'] . "</td> ";
Print "<th>Date</th> <td>".$info['date'] . " </td></tr>";
Print "<th>Main Event</th> <td>".$info['mainevent'] . " </td></tr>";
}
Print "</table>";
?>
califdon
Jack of Zircons
Posts: 4484 Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA
Post
by califdon » Sun Jun 08, 2008 1:50 pm
You should not use spaces in the name of a table. The error message is telling you that SQL syntax does not allow several "words" (characters separated by spaces) following the keyword FROM.
CoolAsCarlito
Forum Contributor
Posts: 192 Joined: Sat May 31, 2008 3:27 pm
Contact:
Post
by CoolAsCarlito » Sun Jun 08, 2008 1:54 pm
Okay got that fixed now how do I get them aligned correctly with just the headings and then after the headings it inserts the regular record rows:
This is what I have:
Code: Select all
<?php
// Connects to your Database
$data = mysql_query("SELECT * FROM Show_Archives")
or die(mysql_error());
Print "<table border cellpadding=3>";
while($info = mysql_fetch_array( $data ))
{
Print "<tr>";
Print "<th>{$row['showname']}</th> <th>{$row['date']}</th> <th>{$row['mainevent']}</th> </tr> ";
while($info = mysql_fetch_array( $data ))
{
Print " <td>".$info['showname'] . "</td> <td>".$info['date'] . " </td> <td>".$info['mainevent'] . " </td>";
Print " </tr>";
}
Print "</table>";
?>
califdon
Jack of Zircons
Posts: 4484 Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA
Post
by califdon » Sun Jun 08, 2008 2:14 pm
CoolAsCarlito wrote: This is what I have:
If that's what you have, what is your question?