473,503 Members | 11,783 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please help - PHP/Apache issue

Hello all,
First off thanks for reading this...

The following code works fine on my redhat linux box at home, however
it does not work when running on my webhost, whose server is also
apache.
I realize that they have some aspects of the server disabled for
security, but
after looking at my code, their representative said it should work
fine.

The idea of the code is to upload images from the client, store them
as strings in the mysql db then return them upon request.
As I mentioned, this works fine at home (with no restrictions from my
apache)
but will not work on my hosts server.
The images render fine at home, but they do not display when running
from hostica host.

What could I be overlooking?

thanks, the code is below...
===============================================
Here is the storing logic:
($eflag is the picture data)

$ffile = fopen($_FILES['form_data']['tmp_name'],"rb");
$contents = fread($ffile,$_FILES['form_data']['size']);
$eflag = mysql_escape_string($contents);
$sql = "INSERT INTO items(itemId, itemName, itemDesc, itemPrice,
item_key_words, photo_data)" ."VALUES
('','$name','$form_description','$price','$keyword s','$eflag') ";
===============================================
Here is the retrieval logic:

header("Content-type: image/jpg");

$sql = "SELECT photo_data FROM items WHERE itemId ='$dns'";
$result = mysql_query($sql);
$nrows = mysql_num_rows($result);

if($nrows == 1) {
$row = mysql_fetch_array($result);
echo $row['photo_data'];
}
===============================================

Jul 17 '05 #1
2 1626
John C wrote:
The following code works fine on my redhat linux box at home, however
it does not work when running on my webhost, whose server is also
apache.


<snip>
Here is the storing logic:
($eflag is the picture data)

$ffile = fopen($_FILES['form_data']['tmp_name'],"rb");
$contents = fread($ffile,$_FILES['form_data']['size']);
$eflag = mysql_escape_string($contents);
$sql = "INSERT INTO items(itemId, itemName, itemDesc, itemPrice,
item_key_words, photo_data)" ."VALUES
('','$name','$form_description','$price','$key words','$eflag') ";
============================================== =
Here is the retrieval logic:

header("Content-type: image/jpg");

$sql = "SELECT photo_data FROM items WHERE itemId ='$dns'";
$result = mysql_query($sql);
$nrows = mysql_num_rows($result);

if($nrows == 1) {
$row = mysql_fetch_array($result);
echo $row['photo_data'];
}


The problem may be the field type for photo_data. When I *used* to use
mysql for storing binary images, I found that some images would cut off
and/or not render unless I was using the LONGBLOB field type.

Since then, I've wised up and stored the file names in the database and
the files in a directory. ;)

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
Jul 17 '05 #2
Justin Koivisto wrote:
John C wrote:
The following code works fine on my redhat linux box at home, however
it does not work when running on my webhost, whose server is also
apache.

<snip>
> Here is the storing logic:
> ($eflag is the picture data)
>
> $ffile = fopen($_FILES['form_data']['tmp_name'],"rb");
> $contents = fread($ffile,$_FILES['form_data']['size']);
> $eflag = mysql_escape_string($contents);
> $sql = "INSERT INTO items(itemId, itemName, itemDesc, itemPrice,
> item_key_words, photo_data)" ."VALUES
> ('','$name','$form_description','$price','$keyword s','$eflag') ";
> ===============================================
> Here is the retrieval logic:
>
> header("Content-type: image/jpg");
>
> $sql = "SELECT photo_data FROM items WHERE itemId ='$dns'";
>
>
> $result = mysql_query($sql);
> $nrows = mysql_num_rows($result);
>
> if($nrows == 1) {
> $row = mysql_fetch_array($result);
> echo $row['photo_data'];
> }

The problem may be the field type for photo_data. When I *used* to use
mysql for storing binary images, I found that some images would cut off
and/or not render unless I was using the LONGBLOB field type.

Since then, I've wised up and stored the file names in the database and
the files in a directory. ;)


One other thing that I seem to remember... you may want to check the
settings for magic_quotes_gpc and magic_quotes_runtime on both servers
to see if you are using equal systems...

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1568
by: bruce | last post by:
Hi... A mysql/Apache issue: I get the following when I'm trying to run a test web site on an Apache 2.0/RH8.0 setup. -------------------------------- Warning: Access denied for user:...
0
2014
by: bruce | last post by:
Hi... Update.... We have the following setup in our httpd.conf file. We've tried to give what's related to the issue. We're trying to set up a virtual host for a test project. The behavior...
4
3714
by: Patrick Masson | last post by:
Hello, Our configuration : Apache 2.0.53 PHP 5.0.4 PC Windows 2000 MATLAB 6.1 We work on a consulting project in France which involves MATLAB Web server,
14
2715
by: Jim Carlock | last post by:
I have a couple easy questions possibly. 1) Is there a default.php page? The webserver seems to support default.htm, default.html, index.htm and index.html. It's an Apache server, I'd like to...
19
5210
by: Alex Madon | last post by:
Hello, I am testing a web application (using the DBX PHP function to call a Postgresql backend). I have 375Mb RAM on my test home box. I ran ab (apache benchmark) to test the behaviour of the...
1
9584
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
0
1791
by: alexsink | last post by:
I am trying to get apache content negotiation to redirect only zh-CN(mainland China, where Simplified Chinese translations are available) language types to Chinese web pages, and have all other...
5
3088
by: m.banaouas | last post by:
Hi, bonjour, witch versions are suitable to use for apache & mod_python ? Can i install and use "Apache 2.2.3" & "mod_python 3.2.10" (most recent versions) without facing any known major...
3
3100
by: bluedogsd | last post by:
I have a new server RHE4 and I am having an issue I have never had before and it's kind of urgent. Running Apache 2.0 I need the web server to have writable access and getting denied - I'm pretty...
1
2783
by: karthikpallavi | last post by:
Hi Everyone, I am battling an issue and I figured one of you guys on this forum may be able to help. I have a developed an application in java to access Microsoft Dynamics 10.0 through Web...
0
7194
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7070
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6976
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5566
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4993
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
372
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.