Forum Moderators: coopster
Iam using Dreamweaver CS4
I need to display the images from my database into a table and my images are in the this folder
C:\webserver\Apache2\abc_Images\images
but in the code this line is not working
$cimage="/images/".$obj->path;
if i give the complete path like this
$cimage="C:\webserver\Apache2\abc_Images\images\".$obj->path;
then i can see the images in the table
please tell me what wrong iam doing
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?php
function connect()
{
$dbhost='localhost';
$dbuser='root';
$dbpass='';
$conn= mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'.mysql_error());
$dbname='abc';
mysql_select_db($dbname);
return $conn;
}
?>
<body>
<table border="1" align="center" height="290" width="533" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<?php
$c=connect();
$query2="select style from styles";
$sql=mysql_query($query2);
$result2=mysql_num_rows($sql);
$query="select path from styles";
$result=mysql_query($query);
echo mysql_num_rows($result);
echo '<table align="center" width="55%" height="60%" BORDERCOLOR="#C6C6C6" >'; for($r=1;$r<=3;$r++)
{
echo '<tr>';
for($d=1;$d<=3;$d++)
{
$obj=mysql_fetch_object($result);
$imageSrc=$obj->path;
$cimage="/images/".$obj->path;
echo '<td border="2" width="15px" height="25px" name="img1"><img width="187px" height="109px"
src='.$cimage.'></td>';
}
echo '</tr>';
}
echo '</table>';
?>
</td>
</tr>
</table>
</body>
</html>
[edited by: eelixduppy at 12:26 pm (utc) on Nov. 14, 2008]
[edit reason] db specifics [/edit]
can you tell me
When i click on the Sign in image then it should open this particular page called Spry_styles.page
which i am calling the page in the Header Function here it goes like this header("Location:spry_styles.php?uname=".$cusername);
but here the page is not being opend don't know why ...
please tell what wrong iam i doing
here is my code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?php
function connect()
{
$dbhost='localhost';
$dbuser='root';
$dbpass='';
$conn= mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'.mysql_error());
$dbname='hakman';
mysql_select_db($dbname);
return $conn;
}
function IsEmpty($cuser,$cpass)
{
$str1=strlen($cuser);
$str2=strlen($cpass);
$nRes=min($str1,$str2);
echo "$nres";
if ($nRes==0)
{
echo "<font size='4' face='Garamond' color='red'><b> Missing user Id / Password! </b></font> </br>";
}
return $nRes;
}
?>
<body bgcolor="#0a1936">
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" name="form1" id="form1">
<label><input type="image" name="signin" id="signin" src="/hdr_signin1.PNG" /></label>
<br /><br />
<label><input type="image" name="access" id="access" src="/access_acc2.PNG" /></label>
<br /><br />
<label style="color:#FFFFFF">Email Id: </label>
<input type="text" name="cname" id='cname' height="14px" width="177px"/><br />
<br />
<label style="color:#FFFFFF">Password:</label>
<input type="text" name="cpass" id='cpass' height="14px" width="177px"/>
<p>
<input name="checkme" type="image" id="checkme" src="/sign_in_off1.PNG" />
<?php
if (!empty($_POST))
{
$cusername=$_POST['cname'];
$cpassword=$_POST['cpass'];
$check=IsEmpty($cusername,$cpassword);
if ($check>0)
{
$cloginuser=$cusername;
$c=connect();
$query = "SELECT user_id,password FROM users where user_id='".$cusername."' AND password='".$cpassword."'";
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
if (mysql_num_rows($result) > 0)
{
//echo"<font size='4' face='Garamond' color='white'><b>hello swetha</b></font></br>";
header("Location:spry_styles.php?uname=".$cusername);
}
else
{
echo "<font size='4' face='Garamond' color='white'><b>Oouchh.. you failed to Log In </b></font></br>";
}
}
}
?>
</p>
</span>
<p><label><font color="#FFFFFF" face="Monotype Corsiva" size="+2">Forgot Password : </font></label>
<a href="">click here </a></p>
<label><font color="#FFFFFF" face="Monotype Corsiva" size="+2">New Account:</font></label>
<label><input type="image" name="newacc" id="newacc" src="/create_new_account_off1.PNG" /></label>
</form>
</td>
</tr>
</table>
</body>
</html>
please reply me soon
thanks in advance
[edited by: eelixduppy at 12:27 pm (utc) on Nov. 14, 2008]
[edit reason] db specifics [/edit]
As you can see there is allot of html being sent to the browser before you are calling header() function that's why it is not working.
Although the solution to that is to call the header first but as in your case it wont work, so try this
instead of
header("Location:spry_styles.php?uname=".$cusername);
Try this
echo "<script language='Javascript'>location.href='spry_styles.php?uname=$cusername';</script>";
[edited by: Anyango at 12:04 pm (utc) on Nov. 14, 2008]
thanks for the reply
i tried it with this line as u said
echo "<script language='Javascript'>location.href='spry_styles.php?uname=$cusername';</script>";
it is giving me the error like
Line: 84
Char:1
Error:Object Expected
code:0
URL:http://localhost/retail.php
I mentioned a statement near line 84 to get it u
but near the line 84 above the <body> tag in my code (there is nothing it is empty then y it is showing the error there )
please tell me here is my code
wating for the reply
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<!--<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />-->
</head>
<?php
function connect()
{
$dbhost='localhost';
$dbuser='root';
$dbpass='';
$conn= mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'.mysql_error());
$dbname='hakman';
mysql_select_db($dbname);
return $conn;
}
function IsEmpty($cuser,$cpass)
{
$str1=strlen($cuser);
$str2=strlen($cpass);
$nRes=min($str1,$str2);
echo "$nres";
if ($nRes==0)
{
echo "<font size='4' face='Garamond' color='red'><b> Missing user Id / Password! </b></font> </br>";
}
return $nRes;
}
?>
(Here is the 84 line here it is showing the error )
<body bgcolor="#0a1936">
<table width="533" height="290" border="1" align="center" bgcolor="#000000">
<tr><td width="533" height="290">
<form method="post" action="<?php $_SERVER['PHP_SELF'] ?>" name="form1" id="form1">
<label><input type="image" name="signin" id="signin" src="/hdr_signin1.PNG" /></label>
<br /><br />
<label><input type="image" name="access" id="access" src="/access_acc2.PNG" /></label>
<br /><br />
<label style="color:#FFFFFF">Email Id: </label>
<input type="text" name="cname" id="cname" height="14px" width="177px"/><br /><br/>
<label style="color:#FFFFFF">Password:</label>
<input type="text" name="cpass" id="cpass" height="14px" width="177px"/><br/><br/>
<input type="image" id="checkme" name="checkme" src="/sign_in_off1.PNG" onclick="test()" />
<?php
function test()
{
if (!empty($_POST))
{
$cusername=$_POST['cname'];
$cpassword=$_POST['cpass'];
$check=IsEmpty($cusername,$cpassword);
if ($check>0)
{
$c=connect();
$query = "SELECT user_id,password FROM users where user_id='".$cusername."' AND password='".$cpassword."'";
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
if (mysql_num_rows($result) > 0)
{
//echo"<font size='4' face='Garamond' color='white'><b>hello swetha</b></font></br>";
//header('Location:spry_styles.php');
echo "<script language='Javascript'>location.href='spry_styles.php?uname=$cusername';</script>";
}
else
{
echo "<font size='4' face='Garamond' color='white'><b>Oouchh.. you failed to Log In </b></font></br>";
}
}
}
}
?>
<p><label><font color="#FFFFFF" face="Monotype Corsiva" size="+2">Forgot Password : </font></label>
<a href="">click here </a></p>
<label><font color="#FFFFFF" face="Monotype Corsiva" size="+2">New Account:</font></label>
<label><input type="image" name="newacc" id="newacc" src="/create_new_account_off1.PNG" /></label>
</form>
</td>
</tr>
</table>
</body>
</html>
[edited by: eelixduppy at 12:31 pm (utc) on Nov. 14, 2008]
[edit reason] specifics [/edit]