planetsim
here is my test_imagedb.php code
<body>
<?
if (!isset($_REQUEST["submit"])) {
?>
<form method="POST" action="<?= $_SERVER["PHP_SELF"] ?>" enctype="application/x-www-form-
urlencoded">
<table>
<tr><td>Type</td><td><select name="imgtype"><option value="image/gif">GIF</option><option
value="image/jpeg">JPEG</option></select></td></tr>
<tr><td>File</td><td><input type="file" name="imgfile"></td></tr>
<tr><td></td><td><input type="submit" name="submit" value="upload"><input type="reset"></td></tr>
</table>
</form>
<?
//-- save image to db --
} else {
/*
the code below is a suggestion from California Strong...
*/
$hndl=fopen($_REQUEST["imgfile"],"r");
$isize=sizeof($_REQUEST["imgfile"]);
$imgdata="";
while(!feof($hndl)){
$imgdata.=fread($hndl,$isize);
};
/*
my code was...
$hndl=fopen($_REQUEST["imgfile"],"r");
$imgdata=fread($hndl,filesize($_REQUEST["imgfile"]));
*/
$imgdata=addslashes($imgdata);
$dbconn = @mysql_connect($localhost,$myhotspot_crazy,$159995) or exit("SERVER Unavailable");
@mysql_select_db($myhotspot_lol,$dbconn) or exit("DB Unavailable");
$sql = "INSERT INTO tblimage VALUES(NULL,'". $_REQUEST["imgtype"] ."','". $imgdata ."')";
@mysql_query($sql,$dbconn) or exit("QUERY FAILED!");
mysql_close($dbconn);
fclose($hndl);
echo "<a href=\"test_imagedb_view.php\">view image</a>";
};
?>
</body>
and i have got this error when opeing the page
Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in /www/obxhost.net/m/y/h/myhotspot/htdocs/test_imagedb.php on line 37
but line 37contain the dbconnection???😕
others pages code is
test_imagedb_create.php
<?php
$dbconn = @mysql_connect($localhost,$myhotspot_crazy,$159995) or exit("SERVER Unavailable");
@mysql_select_db($myhotspot_lol,$dbconn) or exit("DB Unavailable");
$sql = "SELECT imgtype,imgdata FROM tblimage WHERE imgid=". $_GET["imgid"];
$result = @mysql_query($sql,$dbconn) or exit("QUERY FAILED!");
$contenttype = @mysql_result($result,0,"imgtype");
$image = @mysql_result($result,0,"imgdata");
header("Content-type: $contenttype");
echo $image;
mysql_close($dbconn);
?>
and test_imagedb_view.php
is as follow
<body>
<?
$dbconn = @mysql_connect($localhost,$myhotspot_crazy,$159995) or exit("SERVER Unavailable");
@mysql_select_db($myhotspot_lol,$dbconn) or exit("DB Unavailable");
$sql = "SELECT imgid,imgtype FROM tblimage ORDER BY imgid";
$result = @mysql_query($sql,$dbconn) or exit("QUERY FAILED!");
echo "<table border=1>\n";
echo "<tr><th>imgid</th><th>imgtype</th><th>imgdata</th></tr>\n";
while ($rs=mysql_fetch_array($result)) {
echo "<tr><td>".$rs[0]."</td>";
echo "<td>".$rs[1]."</td>";
echo "<td><img src=\"test_imagedb_create.php?imgid=".$rs[0]."\"></td></tr>\n";
};
echo "</table>\n";
mysql_close($dbconn);
?>
</body>