473,320 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 1686
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

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

Similar topics

9
by: Martin Foster | last post by:
Hi. I would like to be able to mimic the unix tool 'uniq' within a Perl script. I have a file with entries that look like this 4 10 21 37 58 83 111 145 184 226...
1
by: Les Juby | last post by:
A year or two back I needed a search script to scan thru HTML files on a client site. Usual sorta thing. A quick search turned up a neat script that provided great search results. It was fast,...
11
by: Wentink | last post by:
Does anybody have a simple script that let's me popup a picture from a thumbnail? The ones i found are all very very complicated and messy in the source... Thanks, Tintin
5
by: zaw | last post by:
Hi I am working on implementing this script to shopping cart. Basically, it copies fill the shipping address from billing automatically. I believe one or more syntax is not netscape compatible....
4
by: Jake j | last post by:
To those of you who sent me working examples of js include routines, much thanks. I see from them examples that what I'm trying to get to requires a higher level of js knowledge than I've got. ...
17
by: PJ | last post by:
Greetings... I have stumbled upon a small problem. I use Ajax to retrieve part of a page I need to update. I update a DIV element with the HTML contents I get from another page. It works...
118
by: Chuck Cheeze | last post by:
This might be in the wrong group, but... Here is an example of my data: entry_id cat_id 1 20 2 25 3 30 4 25 5 35
15
by: Lawrence Krubner | last post by:
Does anything about this script look expensive, in terms of resources or execution time? This script dies after processing about 20 or 25 numbers, yet it leaves no errors in the error logs. This is...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.