Thanks. I now made 2 very basic pages with nothing in except this:
show.php:
again.html:Code:<?php include ("inc_connect_dbase.php"); $id=$_GET['id']; if(!isset($id) OR empty($id){ die("Select image first"); }else{ $query=myql_query("SELECT * FROM temp WHERE id='".$id."' "); $row=mysql_fetch_array($query); $content=$row['image']; $type=$row['type']; header('Content-type: image/jpeg'); echo $content; ?>
All I get now is the 'red cross' as in: no picture.Code:<html> <body> <img src="show.php?id=1" /> </body> </html>
I hope you can tell what's wrong with me... Thanks again!
You haven't created an image in your code. What about imagecreate and all the other gd functions?
Naw dude..
this does the work.. but umm..Code:header('Content-type: image/jpeg');
What to you do with this line?
Code:$type=$row['type'];
Hi,
I'm not doing anything with that line right now, I put it there cause I wanted to set the Content-type with that dynamically.
Now, it's not doing anything, deleting it doesn't make a difference either.
Still don't know what's going wrong..
Try this:
If there are any errors now.. tell me theseCode:<?php
include ("inc_connect_dbase.php");
$id = $_GET['id'];
if(!isset($id) || empty($id){
die("Select image first");
}else{
$query = myql_query("SELECT * FROM temp WHERE id='".$id."' ") or die(mysql_error());
$row = mysql_fetch_array($query);
$content = $row['image'];
header('Content-type: image/jpeg');
echo $content;
?>
in displayimage.php the assumed the pic_id is 3...and its working fiine if the number after pic_id is constant..how about making a dynamic link which if i click the text, the selected image will appear on a different page.. im having hard time displaying the $id
if i use this
its getting the image on the database.. working fine..<img src= "displayimage.php?pic_id=CONSTANT VALUE" />
<img src= "displayimage.php?pic_id=$id" />
if i use this after pic_id= <? ['$id'] ?> nothing happens
i just want to know how to call the pic id...
i dont know what to do...
any help? please...
thanks in advance![]()
Last edited by hardinera; 07-28-2009 at 11:14 PM.
Thanks Jaan, but no errors, strangely.
Found there was a ) missing after empty($id), but it didn't make a difference.
Thought maybe it had to do with my server settings(?) so uploaded the files to a different server. This also didn't work but when I tried opening just the show.php file in the browser I got a parse error:
Parse error: parse error, unexpected $ in /..../show.php on line 16
Line 16 is the line with just ?> on it
My table looks like this:
id - name - size - type - image
1 - lb.jpg - 6032 - image/jpeg - [BLOB - 5.9 KiB]
Dude! my god that was stupid of me!
I didn't put the closing } at the end!
It's working now! thanks for the help!
And for Hardinera, try this:
or:Code:<?php echo("<img src=\"show.php?id=$id\" />"); ?>assuming that you have set $id somewhereCode:<img src="show.php?id=<?php echo($id);?>" />
Hello all
I am new to PHP and probably a slow learner.
I have to thank you all for all the help... this really works ( TESTE OK ).
My problem ( theory):
- Login/Register form Working ok
- Pic Upload ( from here ) working ok
I have a Login/Register app working and i need to attache a "image" per user.
When the user registers, he upload one "image".
This Image will pop once the user logs in ( for exemple: his photo )
My Problem ( practical )
Together ---- nothing works **** hope you guys can help me
This a modifeid version of you Add.php (register-form.php)
This is a modifeid version of your Insert.php (register-exec.php)Code:<?php
session_start();
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Login Form</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
if( isset($_SESSION['ERRMSG_ARR']) && is_array($_SESSION['ERRMSG_ARR']) && count($_SESSION['ERRMSG_ARR']) >0 ) {
echo '<ul class="err">';
foreach($_SESSION['ERRMSG_ARR'] as $msg) {
echo '<li>',$msg,'</li>';
}
echo '</ul>';
unset($_SESSION['ERRMSG_ARR']);
}
?>
<form id="loginForm" name="loginForm" method="post" action="register-exec.php">
<table width="300" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<th>First Name </th>
<td><input name="fname" type="text" class="textfield" id="fname" /></td>
</tr>
<tr>
<th>Last Name </th>
<td><input name="lname" type="text" class="textfield" id="lname" /></td>
</tr>
<tr>
<th width="124">Login</th>
<td width="168"><input name="login" type="text" class="textfield" id="login" /></td>
</tr>
<tr>
<th> </th>
<td> </td>
</tr>
<tr>
<th>Password</th>
<td><input name="password" type="password" class="textfield" id="password" /></td>
</tr>
<tr>
<th>Confirm Password </th>
<td><input name="cpassword" type="password" class="textfield" id="cpassword" /></td>
</tr>
<tr>
<td> </td>
<td><input name="signature" accept="image/jpeg" type="file" id="signature" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Register" /></td>
</tr>
</table>
</form>
</body>
</html>
My problem is, as it is the register go ok but no image is uploaded.Code:<?php
//Start session
session_start();
//Include database connection details
require_once('config.php');
//Array to store validation errors
$errmsg_arr = array();
//Validation error flag
$errflag = false;
//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
//Function to sanitize values received from the form. Prevents SQL injection
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
//Sanitize the POST values
$fname = clean($_POST['fname']);
$lname = clean($_POST['lname']);
$login = clean($_POST['login']);
$password = clean($_POST['password']);
$cpassword = clean($_POST['cpassword']);
$signature = clean($_FILES['signature']);
//Input Validations
if($fname == '') {
$errmsg_arr[] = 'First name missing';
$errflag = true;
}
if($lname == '') {
$errmsg_arr[] = 'Last name missing';
$errflag = true;
}
if($login == '') {
$errmsg_arr[] = 'Login ID missing';
$errflag = true;
}
if($password == '') {
$errmsg_arr[] = 'Password missing';
$errflag = true;
}
if($cpassword == '') {
$errmsg_arr[] = 'Confirm password missing';
$errflag = true;
}
if( strcmp($password, $cpassword) != 0 ) {
$errmsg_arr[] = 'Passwords do not match';
$errflag = true;
}
// if($signature == '') {
// $errmsg_arr[] = 'No signature file selected';
// $errflag = true;
// }
//Check for duplicate login ID
if($login != '') {
$qry = "SELECT * FROM members WHERE login='$login'";
$result = mysql_query($qry);
if($result) {
if(mysql_num_rows($result) > 0) {
$errmsg_arr[] = 'Login ID already in use';
$errflag = true;
}
@mysql_free_result($result);
}
else {
die("Query failed");
}
}
//If there are input validations, redirect back to the registration form
if($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
session_write_close();
header("location: register-form.php");
exit();
}
//Create INSERT query
$qry = "INSERT INTO members(firstname, lastname, login, passwd, signature) VALUES('$fname','$lname','$login','".md5($_POST['password'])."','$signature')";
$result = @mysql_query($qry);
//Check whether the query was successful or not
if($result) {
header("location: register-success.php");
exit();
}else {
die("Query failed");
}
?>
Can anyone help a NooooB
Thank u all in advance
Xmodpt
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks