By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,775 Members | 1,399 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,775 IT Pros & Developers. It's quick & easy.

image using xampp

underscore
P: 30
i use a php4 and apache2.0 b4 with mysql4 or lower in my php program.
when i use xampp every i can't view my stored image already in html...
here's my code.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $db_server   ="Localhost";
  4. $db_name     ="pass";
  5. $db_username = "root";
  6. $db_password = "";
  7.  
  8.  
  9. $dbconn = @mysql_connect($db_server,$db_username,$db_password);
  10.  
  11. if (!$dbconn)
  12. {
  13.     die ("Can't connect to a db server.");
  14. }
  15. $db=mysql_select_db($db_name);
  16.  
  17.  
  18.  
  19.     $check = @mysql_query("SELECT * FROM pix WHERE imgData ='".$_POST['picture']." '");
  20.  
  21.     $check2 = mysql_num_rows($check);
  22.     if ($check2 == 0) 
  23.  
  24.       {
  25.           // Perform insertion
  26.           $image = addslashes(fread(fopen($picture,"r"), filesize($picture)));
  27.           $image = fopen($_FILE['file']['tmp_name'], "r");
  28.  
  29.               $pjpeg="image/pjpeg";
  30.             $jpeg="image/jpeg";
  31.             $gif="image/gif";
  32.             $png="image/png";
  33.             $bmp="image/bmp";
  34.  
  35.         if ($picture_type == $pjpeg OR $picture_type == $jpeg OR $picture_type == $gif OR $picture_type == $png OR $picture_type == $bmp)
  36.             if (strlen($image) < 149000) 
  37.                 {
  38.                 $sql = "INSERT INTO pix(class,fname,lname,bplace,bdate,imgData,imgType,imgSize) 
  39.                                values('".$_POST["select"]."','".$_POST["txtfname"]."','".$_POST["txtlname"]."','".$_POST["txtbplace"]."',
  40.                                '".$_POST["txtbdate"]."','$image','$picture_type','$picture_size')";
  41.  
  42.                         $result=mysql_query($sql);    
  43.                         //include 'setup.php';
  44.  
  45.  
  46.                     } else{
  47.  
  48.                        echo "<script language='JavaScript'>";
  49.                     echo "window.alert('Not a valid picture type.')";
  50.                     echo "</script>"; 
  51.                     exit;
  52.                    }
  53.        }
  54.  
  55. }
  56.  
  57. ?>
every time i press my submit button the error is these'
***(Warning: fread(): supplied argument is not a valid stream resource)..***
please advise me where i would wrong. i bug in this problem

thnx...
Dec 14 '07 #1
Share this Question
Share on Google+
1 Reply


pbmods
Expert 5K+
P: 5,821
Heya, Underscore.

Please use CODE tags when posting source code:

[CODE=php]
PHP code goes here.
[/CODE]

This line is causing the problem:
Expand|Select|Wrap|Line Numbers
  1. $image = addslashes(fread(fopen($picture,"r"), filesize($picture)));
  2.  
Your script is unable to fopen($picture, "r"). My guess is that $picture is not a valid file path, or else no file exists at that path.
Dec 23 '07 #2

Post your reply

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