469,643 Members | 1,395 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,643 developers. It's quick & easy.

img script works great but almost duplicate of the code does not

tolkienarda
316 100+
hi all

i have a problem i have a script that i got working exactly the way i wanted it. and then i tried to intrigate it into the site and it totaly stopped working. below is the original code

[PHP]
<?
$host="localhost"; // Host name.
$db_user="****"; // MySQL username.
$db_password="*******"; // MySQL password.
$database="cms"; // Database name.
$cms = mysql_pconnect($host, $db_user, $db_password) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database, $cms);
$errmsg="";

// If this is the image request, send out the image
$page = "home";
$position = $_REQUEST[gim];
$locationval = $page . $position;
$gotten = mysql_query("SELECT * FROM pix WHERE location='$locationval'");
if ($row = mysql_fetch_assoc($gotten))
{
$bytes = $row[imgdata];
header("Content-type: image/jpeg");
print $bytes;
exit ();
}
?>

<html><head>
<title>Upload image</title>
<table>
<tr>
<td><img src=?gim=1 width="144" /></td>
</tr>
<tr>
<td>
<form enctype='multipart/form-data' action='uploader.php' method='post'>
<input type='hidden' name='MAX_FILE_SIZE' value='150000'>
<input type='hidden' name='completed' value='submitted'>
<input type='file' name='imagefile'>
<input type="hidden" name="location" value="home1"><br>
<input type='submit'>
</form>
</td>
</tr>
<tr>
<td><img src=?gim=2 width=144></td>
</tr>
<tr>
<td>
<form enctype='multipart/form-data' action='uploader.php' method='post'>
<input type='hidden' name='MAX_FILE_SIZE' value='150000'>
<input type='hidden' name='completed' value='submitted'>
<input type='file' name='imagefile'><br>
<input type="hidden" name="location" value="home2"><br>
<input type='submit' value="submit">
</form>
</td>
</tr>
</table>



</body>
</html>

[/PHP]

ok so the basic thought behind this is i send the number with my image tag and then that concatinates that with the name of the page and searches for the image that belongs with that location. so prety simple, the above script works but the one below one has just a small peice of php in addition to the rest of code above. but there is apparently some conflict that i cannot figure out.

[PHP]
<?
$host="localhost"; // Host name.
$db_user="****"; // MySQL username.
$db_password="*******"; // MySQL password.
$database="cms"; // Database name.
$cms = mysql_pconnect($host, $db_user, $db_password) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database, $cms);
$errmsg="";

// If this is the image request, send out the image
$page = "home";
$position = $_REQUEST[gim];
$locationval = $page . $position;
$gotten = mysql_query("SELECT * FROM pix WHERE location='$locationval'");
$in = 'not in';
if ($imgrow = mysql_fetch_assoc($gotten))
{
$bytes = $imgrow[imgdata];
header("Content-type: image/jpeg");
$in = 'in';
print $bytes;
exit ();
}
?>
</head>

<body>
<img src=?gim=1 width="144">
<table width='650' border='1'>
<tr>
<td><img src="images/header.jpg" width="650" height="88"></td>
</tr>
<tr>
<td>
<table width="100%" border='1'>
<tr>
<td width="25%"><img src="../images/image1.jpg"></td>
<td colspan="2">
<form action="scripts/update.php" method="post">
<input type='text' name='hometxt1title'>
<input type="text" name='hometxt1author'>
<textarea name='hometxt1txt' rows='5' cols="70">

<?

$result=mysql_query("SELECT id, title, author, article, location FROM atricles");
$row=mysql_num_rows($result);
$row2 = mysql_fetch_row($result);
echo $row2[3];
?>

</textarea>
<input type="hidden" name='location' value='home1'>
<br />
<input type="submit">
</form>
</td>
</tr>
<tr>
<td colspan="2">
<img src=?gim=1 width="144"><br>
<form enctype='multipart/form-data' action='uploader.php' method='post'>
<input type='hidden' name='MAX_FILE_SIZE' value='150000'>
<input type='hidden' name='completed' value='submitted'>
<input type='file' name='imagefile'>
<input type="hidden" name="location" value="home1"><br>
<input type='submit'>
</form>
</td>
<td width="25%"><img src="../images/image3.jpg"></td>
</tr>
</table>

</td>
</tr>
<tr>
<td><img src="images/footer.jpg" width="650" height="125"></td>
</tr>
</table>
<?
echo $in, '<br>', $page, '<br>', $position, '<br>', $locationval;
?>

</body>
</html>
[/PHP]

and because of my tests i know that i am not getting into my if statement
thanks

eric
Mar 6 '07 #1
3 1400
ronverdonk
4,258 Expert 4TB
So what is the difference or do we have to puzzle that out?

Ronald :cool:
Mar 6 '07 #2
tolkienarda
316 100+
um i am not sure what you mean but i will try to explain. the first script is somthing i built just to develop the code i needed to upload and display images. the second script is where i actualy need it to be. the main difference on the second script is there is a second form that allows people to change an atricle. but the code that deals with the image is copy and pasted from the previous page so i don't know what is happening here i think that maybe there is some conflict between my article form and my image script

eric
Mar 6 '07 #3
tolkienarda
316 100+
ok i just found the solution but i have no idea why it matters. what i did is move my php code to above my dtd and it fixed it. now i thought that the location of the php didn't matter but maybe i was wrong if you know why it matterd could you reply with the reason

eric
Mar 6 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by Martin Foster | last post: by
11 posts views Thread by Wentink | last post: by
17 posts views Thread by PJ | last post: by
118 posts views Thread by Chuck Cheeze | last post: by
15 posts views Thread by Lawrence Krubner | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.