Hi all
I started to learn PHP today and I've just finished my first page, yay me!
Can you look at my code and see if I've done it right, if theres a better way of doing it, and if there are any security risks I should worry about please?
Not sure if it matters with security, but when I added the user to the database using MySQL Databases, I set the user privileges to SELECT only.
Thanks,
Jekyll
I started to learn PHP today and I've just finished my first page, yay me!

Can you look at my code and see if I've done it right, if theres a better way of doing it, and if there are any security risks I should worry about please?
PHP:
<?php
// Make a MySQL Connection
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("DB") or die(mysql_error());
// Get all the data from the links table
$result = mysql_query("SELECT * FROM Links ORDER BY name")
or die(mysql_error());
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
if ( $row['logo'] == NULL ) {
echo "<p><a href='" . $row['link'] . "' target='_blank' title='" . $row['alt'] . "'>";
echo $row['name'];
echo "</a> - ";
} else {
echo "<p><a href='" . $row['link'] . "' target='_blank'><img border='0' src='" . $row['logo'] . "' width='" . $row['width'] . "' height='" . $row['height'] . "'";
echo " alt='" . $row['alt'] . "' title='" . $row['alt'] . "' />";
echo "</a><br />";
echo "<a href='" . $row['link'] . "' target='_blank' title='" . $row['alt'] . "'>" . $row['name'] . "</a> - ";
}
echo $row['description'];
echo "</p>";
}
?>
Not sure if it matters with security, but when I added the user to the database using MySQL Databases, I set the user privileges to SELECT only.
Thanks,
Jekyll