Page 1 of 1

MySQL error

Posted: Sun Jun 08, 2008 11:55 am
by CoolAsCarlito
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>";
?>
 

Re: MySQL error

Posted: Sun Jun 08, 2008 1:50 pm
by califdon
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.

Re: MySQL error

Posted: Sun Jun 08, 2008 1:54 pm
by CoolAsCarlito
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>"; 
?> 
 

Re: MySQL error

Posted: Sun Jun 08, 2008 2:14 pm
by califdon
CoolAsCarlito wrote:This is what I have:
If that's what you have, what is your question?