Hi
I'm relatively new to PHP and I was just wondering if someone could help me with a problem i'm having. I have the following code:
Code: Select all
<?php
function myEscape($string)
{
$con = mysql_connect("localhost");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
$var = get_magic_quotes_gpc() ? stripslashes($string) : $string;
return mysql_real_escape_string($var);
}
$cid = myEscape($_GET['cid']);
$cn = myEscape($_GET['cn']);
$cm = myEscape($_GET['cm']);
$sql = "SELECT * FROM `clubs` WHERE `ClubID`='$cid' AND `ClubName`='$cn' AND `ClubManager`='$cm'";
$result = mysql_query($sql) OR DIE (mysql_error());
if (mysql_num_rows($result) > 0)
{
while ($row = mysql_fetch_array($result))
{
echo "<table border='1'>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>";
echo "<tr>";
echo "<td>" . $row['ClubName'] . "</td>";
echo "<td>" . $row['ClubManager'] . "</td>";
echo "</tr>";
}
}
else
{
echo "Houston? We have a problem.";
}
?>What this is doing for me is getting information from a database using an id that has been set. But i want to be able to have an image for each club too. So my questions are:
1) How do you save an image in a database?
2) How do you access the image to display it?
All help would be much appreciated.
Thanks
Colm
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: