I've been trying to create a database-driven site, am new to this, have looked it up on Google and tried for myself, but need a bit of help.

<?php
// Connects to your Database
mysql_connect("localhost", "root", "PASSWORDREMOVED") or die(mysql_error());
mysql_select_db("epguides") or die(mysql_error());
$data = mysql_query("SELECT * FROM epguides)
or die(mysql_error());
Print "<table border cellpadding=3>";
while($info = mysql_fetch_array( $data ))
{
Print "<tr>";
Print "<td><b>".$info['programdata'] </b>" </td>";
Print " showing on ";
Print ".$info['channel'] ";
Print "<td>".$info['airdate'] </td>";
Print "<td>".$info['episode'] </td>";
Print "<td>"<img src="exclamationmark.gif" height="16" width="22">";
Print "<a href="http://mylocalhostsite/setreminder">Set Reminder</a>"</td></tr>";
}
Print "</table>";
?>

I used this code and it gave the following errors:

Parse error: syntax error, unexpected T_STRING in C:\www\vhosts\mytvsite\testguide.php on line 7

How would I fix these for myself, since I'm new to this sort of thing?

Recommended Answers

All 6 Replies

Quite a lot of inconsistencies with the quotes is the problem. If you're putting quotes inside a string, they need to be single quotes, not double ones. Try this code.

<?php
// Connects to your Database
mysql_connect("localhost", "root", "PASSWORDREMOVED") or die(mysql_error());
mysql_select_db("epguides") or die(mysql_error());
$data = mysql_query("SELECT * FROM epguides)
or die(mysql_error());
Print "<table border cellpadding=3>";
while($info = mysql_fetch_array( $data ))
{
Print "<tr>";
Print "<td><b>" . $info['programdata'] . "</b></td>";
Print " showing on ";
Print $info['channel'];
Print "<td>" . $info['airdate'] . "</td>";
Print "<td>" . $info['episode'] . "</td>";
Print "<td><img src='exclamationmark.gif' height='16' width='22'>";
Print "<a href='http://mylocalhostsite/setreminder'>Set Reminder</a></td></tr>";
}
Print "</table>";
?>

I'm now getting this error:

Parse error: syntax error, unexpected T_STRING in C:\www\vhosts\mylocalhostsite\test1.php on line 5

I tried your code and got the above error...

Line 5 is just missing one it's quotes. It should look like this:

$data = mysql_query("SELECT * FROM epguides")
$data = mysql_query("SELECT * FROM epguides");

missing double quotes and semicolon.
try above code.

Good point to not forget about the semicolon, it's a very common mistake ... however if you leave line 6 or die(mysql_error()); the way it is you won't need to add it.

Ah, sorry for forgetting that! It should work now, as the others have said. Have you tried it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.