Please help - PHP/Apache issue

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John C

    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...[color=blue][color=green][color=darkred]
    > >> =============== =============== =============== ==
    > >> 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'];
    > >> }
    > >> =============== =============== =============== ==[/color][/color][/color]
  • Justin Koivisto

    #2
    Re: Please help - PHP/Apache issue

    John C wrote:[color=blue]
    > 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.[/color]

    <snip>
    [color=blue][color=green][color=darkred]
    >>>>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'];
    >>>> }[/color][/color][/color]

    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 - spam@koivi.com
    PHP POSTERS: Please use comp.lang.php for PHP related questions,
    alt.php* groups are not recommended.

    Comment

    • Justin Koivisto

      #3
      Re: Please help - PHP/Apache issue

      Justin Koivisto wrote:
      [color=blue]
      > John C wrote:
      >[color=green]
      >> 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.[/color]
      >
      >
      > <snip>
      >[color=green][color=darkred]
      >>>>> 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'];
      >>>>> }[/color][/color]
      >
      >
      > 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. ;)
      >[/color]

      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 - spam@koivi.com
      PHP POSTERS: Please use comp.lang.php for PHP related questions,
      alt.php* groups are not recommended.

      Comment

      Working...