473,569 Members | 2,752 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_st ring($contents) ;
$sql = "INSERT INTO items(itemId, itemName, itemDesc, itemPrice,
item_key_words, photo_data)" ."VALUES
('','$name','$f orm_description ','$price','$ke ywords','$eflag ') ";
=============== =============== =============== ==
Here is the retrieval logic:

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

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

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

Jul 17 '05 #1
2 1638
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_st ring($contents) ;
$sql = "INSERT INTO items(itemId, itemName, itemDesc, itemPrice,
item_key_wo rds, photo_data)" ."VALUES
('','$name' ,'$form_descrip tion','$price', '$keywords','$e flag') ";
=========== =============== =============== ======
Here is the retrieval logic:

header("Con tent-type: image/jpg");

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

if($nrows == 1) {
$row = mysql_fetch_arr ay($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_st ring($contents) ;
> $sql = "INSERT INTO items(itemId, itemName, itemDesc, itemPrice,
> item_key_words, photo_data)" ."VALUES
> ('','$name','$f orm_description ','$price','$ke ywords','$eflag ') ";
> =============== =============== =============== ==
> Here is the retrieval logic:
>
> header("Content-type: image/jpg");
>
> $sql = "SELECT photo_data FROM items WHERE itemId ='$dns'";
>
>
> $result = mysql_query($sq l);
> $nrows = mysql_num_rows( $result);
>
> if($nrows == 1) {
> $row = mysql_fetch_arr ay($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_gp c and magic_quotes_ru ntime 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
1572
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: 'apache@localhost' (Using password: YES) in /var/www/html/dbid/mysql/database.php on line 17
0
2020
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 that we're seeing is that we can type: http://foo.com but the url that gets displayed is
4
3715
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
2735
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 know if a default.php exists, or how to set it. 2) I'm getting some some strange results... My doctype.php file contains:
19
5222
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 application under heavy load. When increasing the number of requests, all my memory is filled, and the Linux server begins to cache and remains...
1
9606
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 and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the...
0
1794
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 variants of Chinese language tags(ie zh-TW) point to English-suffix pages. Our site currently has content negotiation set up for several other...
5
3091
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 issue ? thanks for any help.
3
3104
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 sure my users/groups/permissions/etc are all good. Apache is running as user apache group ftpusers. server root for default server is at the...
1
2788
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 Services. I post a SOAP request to DynamicsGPWebService.asmx web services and get a SOAP response that is handled in my java program using simple XML...
0
7921
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7666
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6278
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2107
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.