<?php

include 'dbc.php';

$query  = "SELECT  *  FROM em.tutor";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_NUM))
{
    echo "Name :{$row[0]} <br>" .
         "Subject : {$row[1]} <br>" . 
         "Message : {$row[2]} <br><br>".
          "Message1 : {$row[3]} <br><br>".
           "Message2 : {$row[4]} <br><br>".
            "Message3 : {$row[5]} <br><br>".
             "Message : {$row[6]} <br><br>".
              "Message : {$row[7]} <br><br>".
                  "Message : {$row[8]} <br><br>".
              "Message : {$row[9]} <br><br>".
                  "Message : {$row[10]} <br><br>".
              "Message : {$row[11]} <br><br>".
                     "Message : {$row[12]} <br><br>".
              "Message : {$row[13]} <br><br>".
                  "Message : {$row[14]} <br><br>".
              "Message : {$row[15]} <br><br>".
                  "Message : {$row[16]} <br><br>".        

   
               "<img src=/em/tutor/images/".
               
               
               "<br>___________________________________________________________<BR /><BR />";       
} 


?>

hi, i need some help on displaying images on my page listing.

i dun understand why the image doesn't display with the page results, there's no error in the code.

You haven't specified an image: "<img src=/em/tutor/images/". only specifies the folder that the image should be located.

commented: 10s +1

how can i move the images using PHP and mySQL to my apache web directory? initially i was trying to upload the image directly into mysql but it doesnt works.

i am stucked and got timeout error which i believe is to have come from this part of the code "move_uploaded_file". help please anyone ?

<?php 
session_start();
error_reporting (E_ALL ^ E_NOTICE);



include ('dbc.php'); 

if ($_POST['Submit'] == 'Complete Registration')

//validation
{
	
   if (strlen($_POST['email']) < 5)      
   //die string length shorter than 5    
   		{
    		die ("Incorrect email. Please enter valid email address..");
    	}
    
    
   if (strcmp($_POST['pass1'],$_POST['pass2']) || empty($_POST['pass1']) )
		{ 
			//die ("Password does not match");
			die("ERROR: Password does not match or empty..");
		}
	
	
	if (strcmp(md5($_POST['user_code']),$_SESSION['ckey']))
		{ 
			die("Invalid code entered. Please enter the correct code as shown in the Image");
  		}
  	

  		 
  	//check if username exist
	$rs_duplicates = mysql_query("select id from users where user_email='$_POST[email]'");
	$duplicates = mysql_num_rows($rs_duplicates);
	
	if ($duplicates > 0)
	
		{	
		//die ("ERROR: User account already exists.");
		header("Location: register.php?msg=ERROR: User account already exists..");
		exit();
		}
			
		$target = "images/"; 
		$target = $target . basename( $_FILES['photo']['name']); 
		$pic=($_FILES['photo']['name']); 
		
	/*
		
	  $imgtype    =$_REQUEST['imgtype'];
	  $imgdata    =$_REQUEST['imgdata'];
	  
	 $hndl  =fopen($_REQUEST["imgfile"],"r");
	 $isize =sizeof($_REQUEST["imgfile"]);

	 $imgdata="";
		while(!feof($hndl)){
		$imgdata.=fread($hndl,$isize);	
		};
				
	$imgdata=addslashes($imgdata);
	
	
	$name_box = $_REQUEST["name_box"];
		while (list ($key_check,$val_check) = @each ($name_box))
		{
			$value_check .= $val_check.",";
		}
 
	$all_value_check = substr($value_check, 0, -1);  
 
	echo $all_value_check;
	
	
	*/
	
	
		
	$md5pass = md5($_POST['pass2']);
	$activ_code = rand(1000,9999);
	$server = $_SERVER['HTTP_HOST'];
	$host = ereg_replace('www.','',$server);
	
	
	
	mysql_query("INSERT INTO tutor
	              (`user_email`,`user_pwd`,`joined`,`activation_code`,`full_name`,`imgdata`,`gender`,`race`,`commitment`,`tutoring_location`,`current_location`,`qualification`,`imgtype`)
				  VALUES
				  ('$_POST[email]','$md5pass',now(),'$activ_code','$_POST[full_name]','$_POST[imgtype]','$_POST[gender]','$_POST[race]','$_POST[commit]','$_POST[loc]','$_POST[cloc]','$_POST[qual]','$pic')") or die(mysql_error());
	

 if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) 
{ 

//Tells you if its all ok 
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; 
} 
else { 

//Gives and error if its not 
echo "Sorry, there was a problem uploading your file."; 
} 



	$message = 
"Thank you for registering an account with $server. Here are the login details...\n\n
User Email: $_POST[email] \n
Password: $_POST[pass2] \n
Activation Code: $activ_code \n
____________________________________________
*** ACTIVATION LINK ***** \n
Activation Link: http://$server/em/login/activate.php?usr=$_POST[email]&code=$activ_code \n\n
_____________________________________________
Thank you. This is an automated response. PLEASE DO NOT REPLY.
";

	
	mail($_POST['email'] , "Login Activation", $message,
    "From: \"Auto-Response\" <notifications@$host>\r\n" .
     "X-Mailer: PHP/" . phpversion());
	unset($_SESSION['ckey']);
	echo("Registration Successful! An activation code has been sent to your email address with an activation link...");	
	
	exit;
	}	

?> 

<link href="styles.css" rel="stylesheet" type="text/css">

<?php if (isset($_GET['msg'])) { echo "<div class=\"msg\"> $_GET[msg] </div>"; } ?>



<table align=center width="80%" border="0" cellpadding="3" cellspacing="10">

  	<td width=30% bgcolor="e5ecf9" class="forumposts"><form name="form1" method="post" action="register.php" style="padding:5px;">
	<tr> 
    		<th colspan=3 bgcolor="d5e8f9" class="mnuheader"><strong><font size="5">Music Instructor Registration Form</font></strong></th>
 			
	</tr>
	
    		
     	
    <tr>
    
    Photo: <input type="file" name="photo"><br> 
    
 
	
	</tr>
    	
    	
	<tr>
			<td align=right>Name:</td>
			<td colspan=2><input name="full_name" type="text" id="full_name"> &nbsp&nbsp&nbsp&nbsp&nbsp Ex. Stanley Tan
			
			
	</tr>
	
	<tr>
	
			<td align=right>Email: </td>
			<td><input name="email" type="text" id="email"> </td>
     
	</tr>
          	
    <tr> 
    	 	<td align=right>Password:</td>
         	<td><input name="pass1" type="password" id="pass1"> Min 8 chars &nbsp&nbsp&nbsp&nbsp&nbsp          
          
    </tr>
    
   	<tr>
   			<td align=right>Retype Password:</td> 
   			<td><input name="pass2" type="password" id="pass2"></td>
   	</tr>
    
//blah blah..........more similar code removed.

    
    <tr>
    	<td align=right>Enter code on right:</td>
    	<td><input name="user_code" type="text" size="10">&nbsp&nbsp<img src="pngimg.php" align="middle">&nbsp; </td>
    </tr>
    

    
    <tr>
    	<td colspan=3><input type="submit" name="Submit" value="Complete Registration" style="height: 35px; width: 100%"></td>
    </tr>
    
   		
</table>

</body>
</html>

The problem i am having is that when i insert the image to the database, the blob image stay at 9kb no matter what filesize i am using...when i try to display the image from MySQL database, nothing comes out....

anyone can help me pls ?

<?php 

session_start();
error_reporting (E_ALL ^ E_NOTICE);

include ('dbc.php'); 

if ($_POST['Submit'] == 'Complete Registration')

//validation
{
	
   if (strlen($_POST['email']) < 5)      
   //die string length shorter than 5    
   		{
    		die ("Incorrect email. Please enter valid email address..");
    	}
    
    
   if (strcmp($_POST['pass1'],$_POST['pass2']) || empty($_POST['pass1']) )
		{ 
			//die ("Password does not match");
			die("ERROR: Password does not match or empty..");
		}
	
	
	if (strcmp(md5($_POST['user_code']),$_SESSION['ckey']))
		{ 
			die("Invalid code entered. Please enter the correct code as shown in the Image");
  		}
  	
	
  		 
  	//check if username exist
	$rs_duplicates = mysql_query("select id from users where user_email='$_POST[email]'");
	$duplicates = mysql_num_rows($rs_duplicates);
	
	if ($duplicates > 0)
	
		{	
		//die ("ERROR: User account already exists.");
		header("Location: register.php?msg=ERROR: User account already exists..");
		exit();
		}
			
	  $imgtype    =$_REQUEST['imgtype'];
	  $imgdata    =$_REQUEST['imgdata'];
	  
	 $hndl  =fopen($_REQUEST["imgfile"],"r");
	 $isize =sizeof($_REQUEST["imgfile"]);

	 $imgdata="";
		while(!feof($hndl)){
		$imgdata.=fread($hndl,$isize);	
		};
				
	$imgdata=addslashes($imgdata);
	
	
	$name_box = $_REQUEST["name_box"];
		while (list ($key_check,$val_check) = @each ($name_box))
		{
			$value_check .= $val_check.",";
		}
 
	$all_value_check = substr($value_check, 0, -1);  
 
	echo $all_value_check;
	
	
	
		
	$md5pass = md5($_POST['pass2']);
	$activ_code = rand(1000,9999);
	$server = $_SERVER['HTTP_HOST'];
	$host = ereg_replace('www.','',$server);

	
	mysql_query("INSERT INTO tutor
	              (`user_email`,`user_pwd`,`joined`,`activation_code`,`full_name`,`imgdata`,`gender`,`race`,`commitment`,`tutoring_location`,`current_location`,`qualification`,`test`,`imgtype`)
				  VALUES
				  ('$_POST[email]','$md5pass',now(),'$activ_code','$_POST[full_name]','$_POST[imgtype]','$_POST[gender]','$_POST[race]','$_POST[commit]','$_POST[loc]','$_POST[cloc]','$_POST[qual]','$all_value_check','$_POST[imgtype]')") or die(mysql_error());
	
	$message = 
"Thank you for registering an account with $server. Here are the login details...\n\n
User Email: $_POST[email] \n
Password: $_POST[pass2] \n
Activation Code: $activ_code \n
____________________________________________
*** ACTIVATION LINK ***** \n
Activation Link: http://$server/em/login/activate.php?usr=$_POST[email]&code=$activ_code \n\n
_____________________________________________
Thank you. This is an automated response. PLEASE DO NOT REPLY.
";


	mail($_POST['email'] , "Login Activation", $message,
    "From: \"Auto-Response\" <notifications@$host>\r\n" .
     "X-Mailer: PHP/" . phpversion());
	unset($_SESSION['ckey']);
	echo("Registration Successful! An activation code has been sent to your email address with an activation link...");	
	
	exit;
	}	

?> 

<link href="styles.css" rel="stylesheet" type="text/css">

<?php if (isset($_GET['msg'])) { echo "<div class=\"msg\"> $_GET[msg] </div>"; } ?>



<table align=center width="80%" border="0" cellpadding="3" cellspacing="10">

  	<td width=30% bgcolor="e5ecf9" class="forumposts"><form name="form1" method="post" action="register.php" style="padding:5px;">
	<tr> 
    		<th colspan=3 bgcolor="d5e8f9" class="mnuheader"><strong><font size="5">Music Instructor Registration Form</font></strong></th>
 			
	</tr>
	
    		
     	
    <tr>
       
    		<td align=right>Upload Your Photo:<br /> (Filesize must not exceed 500kb)</td>
			<td><input type="file" id='imgfile' name="imgfile">&nbsp&nbsp&nbsp&nbsp&nbsp
			<select name="imgtype">
			<option value="image/gif">GIF</option>
			<option value="image/jpeg">JPEG</option></select></td>
	
	</tr>
    	
    	
	<tr>
			<td align=right>Name:</td>
			<td colspan=2><input name="full_name" type="text" id="full_name"> &nbsp&nbsp&nbsp&nbsp&nbsp Ex. Stanley Tan
			
			
	</tr>
	
	<tr>
	
			<td align=right>Email: </td>
			<td><input name="email" type="text" id="email"> </td>
     
	</tr>
          	
    <tr> 
    	 	<td align=right>Password:</td>
         	<td><input name="pass1" type="password" id="pass1"> Min 8 chars &nbsp&nbsp&nbsp&nbsp&nbsp          
          
    </tr>
    
   	<tr>
   			<td align=right>Retype Password:</td> 
   			<td><input name="pass2" type="password" id="pass2"></td>
   	</tr>
    
  // all the get info from user stuffs here ommitted.

    
    <tr>
    	<td colspan=3><input type="submit" name="Submit" value="Complete Registration" style="height: 35px; width: 100%"></td>
    </tr>
    
   		
</table>

</body>
</html>

Don't store images in a database. Is it a picturebase or a database???
Seriously, store the path to the pic in the db, store the pic on the server. The db is designed to store data. The server is designed to store everything else. Don't use a water jug to store gasoline. Put it in a gas jug.
If your' script is decent, then you can use the path to pull the pic. If not, you should probably go study @ www.php.net.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.