简体   繁体   中英

New to PHP and I'm getting an error that I can't seem to solve

I'll just go ahead and get it out of the way and say that I'm pretty much completely new to PHP and MySQL. I'm still in the learning process and reading everything I can. The only real way to help you understand my issue is to give you visuals.

Here's a screencap with the error circled on the right screen:

http://i.imgur.com/Rkzj4q3.png

And here's the script:

<?php
$con  = mysql_connect("localhost", "********", "*********");
if (!con){
die("Cannot connect to database: " . mysql_error());
}
mysql_select_db("*********",$con);
$sql = "SELECT * FROM broken";
$myData = mysql_query($sql,$con);
echo "<table>
<tr>
<th>SYSTEM</th>
<th>TITLE</th>
<td>
</td>
</tr>";
while($record = mysql_fetch_array($myData)){
echo "<tr class="tr5">";
echo "<td class="td5">" . $record['SYSTEM'] . "</td>";
echo "<td class="td5">" . $record['TITLE'] . "</td>";
echo "</tr>";
}
echo "</table>";

mysql_close($con);

?>

I appreciate any and all help!

That's not an error. That's your PHP code being displayed on the screen. This is happening because you are mixing up your quotes in your strings causing the strings to terminate at unexpected times:

echo "<tr class="tr5">";
echo "<td class="td5">" . $record['SYSTEM'] . "</td>";
echo "<td class="td5">" . $record['TITLE'] . "</td>";

should be

echo '<tr class="tr5">';
echo '<td class="td5">' . $record['SYSTEM'] . '</td>';
echo '<td class="td5">' . $record['TITLE'] . '</td>';

Also use if ($con) instead of if (con) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM