PHP - Unable To Display My Images
Hi all,
Newbie here, i am having a problem to get my images to show which are stored in mysql database as a mediumblob. I get id number to print in table ut am just getting empty square with red cross in where my image should be. Is my code incorrect or is it something else? Appreciate your help with this. I have included both of the pages codes i am using. Thanks Tony image2.php <?php include("common.php"); error_reporting(E_ALL); $link = mysql_connect(host,username,password) or die("Could not connect: " . mysql_error()); mysql_select_db(db) or die(mysql_error()); $sql = "SELECT id FROM photos"; $result = mysql_query("$sql") or die("Invalid query: " . mysql_error()); ?> <table border="1"><tr><td>id</td><td>image</td></tr> <?php while($row=mysql_fetch_assoc($result)){ print '<tr><td>'.$row['id'].'</td><td>'; print '<img src="image1.php?id='.$row['id'].'height="75" width="100"">'; } echo '</td></tr></table>' ?> image1.php <?php ob_start(); include("common.php"); mysql_connect(host,username,password) or die(mysql_error()); mysql_select_db(db) or die(mysql_error()); $query = mysql_query("SELECT imgage FROM photos WHERE id={$_GET['image_id']}"; $row = mysql_fetch_array($query); $content = $row['image']; header('Content-type: image/jpg'); echo $content; } ob_end_flush(); ?> Similar Tutorials==> MySQL version 5.0.91-community So once upon a time I was working on a CMS. I worked on it for 3 months, had to wipe my computer - but didn't worry about it because I backed up the files on a flash drive... which got smushed by some boxes when I moved <.< awesome -.- Anyway, a year later (ie: today), I've decided to start again from scratch. For me - for whatever reason - the simplest things always seem to give me the most trouble. I decided to start with a "user" table - naturally - and began working on the first page: user_view.php and added an include file that connects to the database (connectDB.php). Since I started today, everything is simple - no design elements yet - just good 'ol code. The View Users Page is simply a page that grabs all the rows from Table: users and prints the information to the screen, as if you were viewing a Members page on a forum. This Page works fine. No complaints, does everything I need it to, prints all the rows and cols from Table Users. Then I created the Edit User Page. When I did this a year ago, and I wanted to print out all the data from the table, I used the while loop. When I wanted to only grab certain variables from a table, I just created a new set of variables, as show below. Using the same method from a year ago, I started working on printing various data to the screen (such as "Welcome $username"). 5 minutes of typing... refresh page... nada. So I stripped away just about every tag but the essentials and it still wouldn't work Code: [Select] <?php ... $userID = 3; $sql = "SELECT * FROM users WHERE userID='$userID'"; $result = mysql_query($sql); $rows = mysql_fetch_row($result); echo $rows['username']; ... ?> Normally, this would just grab the username from a row in Table users where the userID = 3 But instead - it does nothing. I just see a blank page. It's a simple 5 lines of code and it's like "im just gonna do w.e the fk i wanna do mmmk thxforplaying" PS: Keep in mind there is nothing wrong with the connection to the database, and as already stated I'm able to print ALL values from the Users Table using this same method: Code: [Select] <?php ... $user_sql = "SELECT * FROM users ORDER BY username ASC"; $user_result = mysql_query($user_sql); while ( $user_rows = mysql_fetch_array($user_result) ) ... ?> I am doing simple program to display text entered by user.. Following is my code but its display 'error msg' instate of txtbox contents <html> <head><title>Date</title></head> <body> <form action="" enctype="multipart/form-data"> Enter Date: <input type="text" name="txtdate"/> <input type="submit" value="Display"/> </form> </body> </html> <?php if(isset($_POST['txtdate'])) { $display =$_POST['txtdate']; echo 'You have entered'.$display; } else { echo 'Error msg'; } ?> Hi, I am a newbie to this forum and php as well. I have a script which inserts data and image file into mysql database. Now I want to display this image on web page but unable to do it. I tried a lot but couldn't find out any solution. I would appreciate your help. <?php $con = mysql_connect("localhost", "root", "xx"); if(!$con) { die('Could not connect:' .mysql_error()); } mysql_select_db("yyy",$con); $memberid = '$_POST[memberid]'; $fname = '$_POST[fname]'; $lname = '$_POST[lname]'; $gender= '$_POST[gender]'; $add1 = '$_POST[add1]'; $add2 = '$_POST[add2]'; $city = '$_POST[city]'; $state = '$_POST[state]'; $zip = '$_POST[zip]'; $country = '$_POST[country]'; $photo1 = '$_FILES[image][name]'; echo "$photo1"; //if ($memberid= $_GET['memberid']){ $query="select memberid,fname,lname,gender,add1,add2,city,state,zip,country,photo1 from vadhuvar_member where memberid =(select max(memberid)from vadhuvar_member)"; $result=mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { $memberid = $row['memberid']; $fname = $row['fname']; $lname = $row['lname']; $gender = $row['gender']; $add1 = $row['add1']; $add2 = $row['add2']; $city = $row['city']; $state = $row['state']; $zip = $row['zip']; $country = $row['country']; //$photo1=chunk_split(base64_encode($photo1)); $photo1 = $row['photo1']; //echo base64_encode($photo1); echo "Name:$fname $lname<br>"; //echo "Name:$_POST[fname]$_POST[lname]<br>"; echo "Gender:$gender<br>"; echo "Address:$add1 $add2<br>"; echo "$city $state $zip<br>"; echo "$country<br>"; //echo "<img src=".upload/$photo1 ." alt="" width="200" height="300" /><br />"; } //} ?> <!--img src="<?php echo '.upload/$_FILES[image][name]?memberid=$row[memberid]'?>"alt="" width="200" height="300"/-->; <?php echo "<img src=". upload/$row[photo1]" alt="" width="200" height="300">";?> <!--img src="<?php echo ".\upload\$photo1" ?>" alt="" width="200" height="300"/-->; <? set_magic_quotes_runtime(1); // turn back on ?> Thanks Smita This is my code is display my database (member_details) after user sign up but when a user register first name = <script>window.location="google.com"</script> This error occur=(The requested URL /yy2/html/google.com was not found on this server) Code: [Select] <?php session_start(); include ('includes/database_connection.inc.php'); $conn = connectDatabase(); if($_SESSION['uid'] == ''){ // redirect unauthenticate user to login page. header('Location: login.php'); } if($_GET['task'] == 'delete' && $_GET['id'] != ''){ // delete function here $sql="DELETE FROM Newest Where ID='".mysql_real_escape_string($_GET['id'])."'"; mysql_query($sql,$conn); header('Location: member_list.php'); } if($_POST['Logout']){ session_destroy(); header('Location: login.php'); } ?> <html><head><title>Member Details</title> </head> <body> <div style=" margin: 350px "> <?php $sql="SELECT * FROM Newest"; $rs = mysql_query($sql,$conn) or die( mysql_error() ); $list = "<table border=\"1\" cellpadding= \"2\">"; $list .= "<tr><th>First Name</th>"; $list .="<th>Last Name</th>"; $list .= "<th>User Name</th>"; $list .= "<th>Email</th>"; $list .= "<th>Edit User</th>"; $list .= "<th>Delete User</th>"; $list .= "<th>Change Password</th>"; While( $row = mysql_fetch_array($rs) ) { $list .= "<tr>"; $list .= "<td>".$row["name"]."</td>"; $list .= "<td>".$row["last"]."</td>"; $list .= "<td>".$row["user"]."</td>"; $list .= "<td>".$row["email"]."</td>"; $list .= "<td><a href='member_details.php?id=".$row['ID']."'>Edit</a></td>"; $list .= "<td><a onclick='return confirm(\"Are you sure to delete ".$row["name"]." \")' href='member_list.php?id=".$row["ID"]."&task=delete'>Delete</a></td>"; $list .= "<td><a href='Password.php?id=".$row['ID']."'>Click Here</a></td> </tr>"; } $list .= "</table>"; echo ( $list ); ?> <form method="post" action="member_list.php"><br> <div style="margin : 0px 600px"> <style type="text/css"> body {background:#F5F5F5 url('http://images.apple.com/downloads/dashboard/travel/images/traveltodolist_20070724165034.jpg') no-repeat top;; }</style> <input type="submit" name="Logout" value="logout" /> </form> </body> </html> MOD EDIT: [code] . . . [/code] BBCode tags added. how do i get the image to show as the code i have is echoing what i have been told is binary, not confirmed. and not the images. all images are .jpg Code: [Select] $allowed_types = array('png','jpg','jpeg','gif'); $imgdir = '/home/mysite/ftpfolder'; $imgFilesArray = scandir($imgdir); foreach ($imgFilesArray as $imgkey => $imgvalue) { $imgInfo = pathinfo($imgdir . '/' . $imgvalue); $imgExtension = $imgInfo['extension']; if(in_array($imgExtension, $allowed_types)) { readfile($imgdir . '/' . $imgvalue); //echo '<img src = "'. $imgdir .'/'. $imgInfo['basename'].'" alt="" />'; } } images are FTP'd to the ftpfolder and can not be placed anywhere else but this folder due to security reasons. I have searched around and found this code that suggests that I should be able to read an image file and echo it directly in to the page without hyperlinking to the file that is outside the public folder, but i get the error message that it is not there even though the file is. Warning: getimagesize() [function.getimagesize]: Unable to access "/home/****/upload/AAABBBCCC.JPG" in /home/****/public_html/client.php on line 40 Code: [Select] $image = "AAABBBCCC.JPG"; $path= "/home/****/upload/"; $details = getimagesize($path . $image); header ('Content-Type: ' . $details['mime']); echo file_get_contents($path . $image); I'm working on creating a Realtors website. Currently mysql DB has 4 tables. 3 of them are needed in this script to show up as 1 item. Table called Listings has 2 fields that call on 2 other tables. one is MLS which calls on the Images Table the other agent calls on the Agents table. I'm trying to see why I can't While loop all 3 tables together? How can I connect all 3? <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } //mysql_select_db($database_CarneyRealty, $CarneyRealty); //$query_Update1 = "SELECT * FROM listings"; //$Update1 = mysql_query($query_Update1, $CarneyRealty) or die(mysql_error()); //$rrows = mysql_fetch_assoc($Update1); //$totalRows_Update1 = mysql_num_rows($Update1); include 'dbc.php'; page_protect(); $err = array(); $msg = array(); $page_limit =4; //CHANGE FOR THE NUMBER OF LISTINGS PER PAGE! $page_num_limit =10; $ret = $_SERVER['HTTP_REFERER']; $host = $_SERVER['HTTP_HOST']; $host_upper = strtoupper($host); $login_path = @ereg_replace('admin','',dirname($_SERVER['PHP_SELF'])); $path = rtrim($login_path, '/\\'); // filter GET values foreach($_GET as $key => $value) { $get[$key] = filter($value); } foreach($_POST as $key => $value) { $post[$key] = filter($value); } $rs_all = mysql_query("select count(*) as total_all from listings") or die(mysql_error()); $rs_active = mysql_query("select count(*) as total_active from listings where status='ACTIVE'") or die(mysql_error()); $rs_total_contingent = mysql_query("select count(*) as tot2 from listings where status='CONTINGENT'"); $rs_total_pending = mysql_query("select count(*) as tot from listings where status='PENDING'"); $rs_total_sold = mysql_query("select count(*) as tot1 from listings where status='SOLD'"); $rs_resall = mysql_query("select count(*) as res from listings where class='Resident'") or die(mysql_error()); $rs_comall = mysql_query("select count(*) as com from listings where class='Commerical'"); $rs_farmall = mysql_query("select count(*) as farm from listings where class='Farmland'"); $rs_otherall = mysql_query("select count(*) as other from listings where class='Other'"); list($all) = mysql_fetch_row($rs_all); list($active) = mysql_fetch_row($rs_active); list($total_contingent) = mysql_fetch_row($rs_total_contingent); list($total_pending) = mysql_fetch_row($rs_total_pending); list($total_sold) = mysql_fetch_row($rs_total_sold); list($resall) = mysql_fetch_row($rs_resall); list($comall) = mysql_fetch_row($rs_comall); list($farmall) = mysql_fetch_row($rs_farmall); list($otherall) = mysql_fetch_row($rs_otherall); /////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// $sqlagents = mysql_query("select * from agents where id='$_SESSION'"); //$agentname= mysql_query($sqlagents) or die(mysql_error()); $sqllistings = mysql_query("select * from listings where id='$_SESSION'"); $sqlimages = mysql_query("select * from images where id='$_SESSION'"); //////////////////////////////////////////////////////////////////////////////////////////////////////// ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Search CarneyRealty Listings</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" href="../css/mm_brochure.css" type="text/css"> <style type="text/css"> <!-- body { background-image: url(http://www.carneyrealty.com/newsite/images/IMG_0161a.jpg); } .style1 { font-size: 16px } .style2 { font-family: Geneva, Arial, Helvetica, sans-serif } .style10 { font-size: 13px; font-weight: bold; color: #FF0000; } .style7 { color: #FF0000; font-weight: bold; } .style8 { color: #0000FF; font-weight: bold; } --> </style> </head> <body bgcolor="#bcbc85" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <div align="center"> <table width="81%" border="0" cellspacing="0" cellpadding="0"> <tr bgcolor="#999966"> <td width="25" nowrap="nowrap"><center> <img src="../images/mm_spacer.gif" alt="" width="15" height="1" border="0" /></td> <td height="60" colspan="3" class="logo" nowrap="nowrap"><div align="center"><img src="images/Carney_Logo1_000.jpg" width="630" height="158" /><br /> </div></td> <td width="4"></td> </tr> <tr bgcolor="#797947"> <td width="25" nowrap="nowrap"></td> <td colspan="3" valign="top"><div align="center"> <table width="460" border="0" cellpadding="0" cellspacing="0" id="navigation"> <tr> <td width="59" align="center" nowrap="nowrap"><div align="center"><a href="../index.htm" class="style1"><strong>HOME</a></div></td> <td width="127" align="center" nowrap="nowrap"><div align="center"><strong><a href="../SearchCarneyRealtyListings.php" class="style5">LISTINGSEARCH</a></strong></div></td> <td width="94" align="center" nowrap="nowrap"><div align="center"><strong><a href="../Aboutus.html" class="style5">ABOUT US</a></strong></div></td> <td width="10" align="center" nowrap="nowrap"><div align="center"></div></td> <td width="95" align="center" nowrap="nowrap"><div align="center"><strong><a href="../Community.htm" class="style5">COMMUNITY </a></strong></div></td> <td width="81" align="center" nowrap="nowrap"><div align="center"><strong><a href="../Login.php" class="style5">LOGIN</a></strong></div></td> </tr> </table> <table width="307" border="0" cellpadding="0" cellspacing="0" id="navigation"> <tr> <td width="84" align="center" nowrap="nowrap"><div align="center"><a href="http://www.carneyrealty.com/newsite/listingsearch.php?doSearch=MLS+Search&q=Resident" class="style1">Residential</a></div></td> <td width="103" align="center" nowrap="nowrap"><div align="center"><strong><a href="http://www.carneyrealty.com/newsite/listingsearch.php?doSearch=MLS+Search&q=Commerical" class="style5">Commercial</a></strong></div></td> <td width="102" align="center" nowrap="nowrap"><div align="center"><strong><a href="http://www.carneyrealty.com/newsite/listingsearch.php?doSearch=MLS+Search&q=Farmland" class="style5">Farms & Land</a></strong></div></td> <td width="18" align="center" nowrap="nowrap"><div align="center"></div></td> </tr> </table> <table width="573" border="0" cellpadding="0" cellspacing="0" id="navigation"> <tr> <td width="72" align="center" nowrap="nowrap"><div align="center"><a href="residental0-60.php" class="style1">$0-$60K</a></div></td> <td width="80" align="center" nowrap="nowrap"><div align="center"><strong><a href="residental61-85.php" class="style5">$61K-$85K</a></strong></div></td> <td width="87" align="center" nowrap="nowrap"><div align="center"><strong><a href="residental86-115.php" class="style5">$86K-$115K</a></strong></div></td> <td width="1" align="center" nowrap="nowrap"><div align="center"></div></td> <td width="103" align="center" nowrap="nowrap"><div align="center"><strong><a href="residental116-160.php" class="style5">$116K-$160K</a></strong></div></td> <td width="93" align="center" nowrap="nowrap"><div align="center"><strong><a href="residental161-230.php" class="style5">$161K-230K</a></strong></div></td> <td width="126" align="center" nowrap="nowrap"><div align="center"><strong><a href="residential231up.php" class="style5">$231K-And Up</a></strong></div></td> <td width="11" align="center" nowrap="nowrap"> </td> </tr> </table> </div></td> </tr> <td width="25" valign="top"><?php /*********************** MY MLS MENU **************************** This code shows MLS account menu only to logged in users. Copy this code till END and place it in a new html or php where you want to show myaccount options. This is only visible to logged in users *******************************************************************/ ?> <?php if(!empty($msg)) { echo $msg[0]; } ?> <? //$row_settings1=mysql_fetch_array($sqllistings1);?> <?php while ($row_settings1 = mysql_fetch_array($sqllistings)){ $row_settings2=mysql_fetch_array($sqlimages); $row_settings3=mysql_fetch_array($sqlagents); ?> <?php } ?> </table> <table width="81%" border="0" align="center" cellpadding="10" cellspacing="0" style="background-color: #FF9933;padding: 2px 5px;border: 1px solid #F90;" > <tr> <td height="44" align="center"><form name="form1" method="get" action="listingsearch.php"> <p> <input name="doSearch" type="submit" id="doSearch2" value="MLS Search" /> <input name="q" type="text" id="q" size="40"> <strong> S CARNEY& ASSOCIATES INC 800-757-5783</strong> <br> </p> </form></td> </tr> </table> </td> </tr> </table> </div> <p> <?php if ($get['doSearch'] == 'MLS Search') { $cond = ''; if($get['qoption'] == 'active') { $cond = "where `status`='ACTIVE' order by date desc"; } if($get['qoption'] == 'contingent') { $cond = "where `status`='CONTINGENT' order by date desc"; } if($get['qoption'] == 'pending') { $cond = "where `status`='PENDING' order by date desc"; } if($get['qoption'] == 'sold') { $cond = "where `status`='SOLD' order by date desc"; } if($get['qoption'] == 'resident') { $cond = "where `class`='Resident' order by price desc"; } if($get['qoption'] == 'farmland') { $cond = "where `class`='Farmland' order by price desc"; } if($get['qoption'] == 'commerical') { $cond = "where `class`='Commerical' order by price desc"; } if($get['qoption'] == 'other') { $cond = "where `class`='Other' order by price desc"; } //if($get['qoption'] == '') { if($get['q'] == '') { $sql = "select * from listings order by price asc"; // $sql = "select * from listings $cond"; // } } else { $sql = "select * from listings where `price` = '$_REQUEST[q]' or `mls`='$_REQUEST[q]' or `seller`='$_REQUEST[q]' or `class`='$_REQUEST[q]' or `status`='$_REQUEST[q]' order by `price` asc"; //$sql1="select * from images where `mls`='$sql'"; //$sql2="select * from agents where `tag`='$sql'"; // $sql = "select * from listings where `mls`='$_REQUEST[q]' or `price`='$_REQUEST[q]'"; } //$rs_total1=mysql_query($sql1) or die(mysql_error()); $rs_total = mysql_query($sql) or die(mysql_error()); $total = mysql_num_rows($rs_total); // $total1=mysql_num_rows($rs_total1); if (!isset($_GET['page']) ) { $start=0; } else { $start = ($_GET['page'] - 1) * $page_limit; } $rs_results = mysql_query($sql . " limit $start,$page_limit") or die(mysql_error()); $total_pages = ceil($total/$page_limit); // $rs_results1 = mysql_query($sql1 ."limit $start,$page_limit") or die (mysql_error()); ?> <?php // outputting the pages if ($total > $page_num_limit) { echo "<table width='81%' border='0' align='center' cellpadding='2' cellspacing='0' background='#fcfcdd'><span class='subHeader'><center>Pages: "; $i = 0; while ($i < $page_num_limit) { $page_no = $i+1; $qstr = ereg_replace("&page=[0-9]+","",$_SERVER['QUERY_STRING']); echo "<a href=\"listingsearch.php?$qstr&page=$page_no\">$page_no</a> "; $i++; } echo "</span></td></table>"; } ?> <? //while ($rrows3 = mysql_fetch_array($rrows3)){ ?> <form name "searchform" action="listingsearch.php" method="post"> </form> </table> <?php ////////////////////////////////////////////////////////////////////////////// while ($rrows = mysql_fetch_array($rs_results)) { $rrows2=mysql_fetch_array($sqlimages); $rrows3=mysql_fetch_array($sqlagents); /////////////////////////////////////////////////////////////////////////////// //$imagenamevar=($rrows['mls']=$rrows2['mls']); //echo $rrows3['id']; //$agentpicvar=($rrows['seller']=$rrow3['tag']); ?> <tr> <table width="81%" border="0" align="center" cellpadding="2" cellspacing="0" background="#fcfcdd"> <? echo $rrows['agents'.'seller_id'];?> <td width="161" height="211" align="center" valign="top" bgcolor="#fcfcdd"><div align="center"><img src="http://www.carneyrealty.com/newsite/uploads/<?php echo $rrows['mls'];?>/<? echo $mainimagevar; ?> width="214" height="160" /> </p> </div> <p class="tagline">Click for Additional Pictures</p></td> <td width="568" align="center" valign="top" bgcolor="#fcfcdd" class="calendarText"><div align="left"> <table width="592" height="180" border="1"> <tr valign="top"> <td width="74" height="27" bgcolor="#fcfcdd" class="tagline">Location </td> <td width="249" bgcolor="#fcfcdd"><strong><?php echo $rrows['location'];?> <br> <? echo $rrows['location1'];?> <br> <? echo $rrows3['tag'];?> </strong></td> <td width="180" rowspan="2" bgcolor="#fcfcdd" class="tagline"><div align="center"> <table width="180" height="62" border="1"> <tr valign="top"> <td width="70" rowspan="2" class="tagline"><a href="http://www.carneyrealty.com/newsite/upload/<?php echo $rrows['mls'];?>/<? echo "SD_disp.pdf";?>"><img align="absbottom" src="http://www.carneyrealty.com/newsite/Listing_pages/images/datasheet_018.jpg" width="58" height="50" /></a></td> <td width="50" class="tagline"><div align="left">Status </div></td> <td width="68"><div align="right" class="subHeader"><?php echo $rrows['status']; ?></div></td> </tr> <tr valign="top"> <td height="24" class="tagline"><div align="left">PRICE</div></td> <td align="center" valign="top"><div align="right"><strong class="subHeader"><?php echo $rrows['price']; ?></strong></div></td> </tr> </table> <span style="color: #fcfcdd"><strong><a href="mailto:<? echo $rrows['selleremail'];?>"><img src="http://www.carneyrealty.com/newsite/Listing_pages/images/mail_004.gif" width="14" height="15" /><? echo $rrows['seller'];?></a></strong></span></div></td> <td width="61" rowspan="2" bgcolor="#fcfcdd" class="tagline"><div align="right"></div> <span style="color: #fcfcdd"><img src="<? ///////////////////////////////////////////////////////////// while ($rrows3=($rrows['seller']=$rrows3['seller_id'])){ echo $rrows3['agentimage']; } ////////////////////////////////////////////////////////////// ?>" width="60" height="91" /></a></span></td> </tr> <tr valign="top"> <td height="64" bgcolor="#fcfcdd" class="tagline">Specs</td> <td bgcolor="#fcfcdd"><strong><?php echo $rrows['specs']; ?></strong></td> </tr> <tr valign="top"> <td height="77" bgcolor="#fcfcdd" class="tagline">Description</td> <td colspan="3" bgcolor="#fcfcdd" ><strong>MLS #<?php echo $rrows['mls'];?><br> <? echo $rrows['description'];?></strong> <p><strong>Call <? echo $rrows['seller'];?> at <? echo agentnumbervar;?> to view or for more information.</strong></p></td> </tr> </table> <tr> <td height="18" colspan="2" align="center" valign="top" bgcolor="#FF9933"><span class="bodyText style2" style="color: #fcfcdd"></span><span class="bodyText style2">S Carney & Associates Real Estate Brokerage 800 757 5783 </span></td> </tr> </div></td> </tr> </span> <? } ?> <td height="4"></td> </table> <? } ?> <? //} ?> </tr> <?php // outputting the pages if ($total > $page_limit) { echo "<table width='81%' border='0' align='center' cellpadding='2' cellspacing='0' background='#fcfcdd'><span class='subHeader'><center>Pages: "; $i = 0; while ($i < $page_num_limit) { $page_no = $i+1; $qstr = ereg_replace("&page=[0-9]+","",$_SERVER['QUERY_STRING']); echo "<a href=\"listings.php?$qstr&page=$page_no\">$page_no</a> "; $i++; } echo "</span></td></table>"; } ?> </td> </tr> <tr> <td height="22" class="bodyText"><? include 'footer1.shtml'; ?> </td> </tr> <tr> <td height="194" class="bodyText"><div align="center"> <table width="513" border="0"> <tr valign="top"> <th width="94" scope="col"><div align="center"><a href="http://www.realtor.org/technology/crt_secure/home?opendocument"><img src="images/index.1.gif" width="43" height="42" border="0" /></a></div></th> <th width="46" scope="col"><div align="center"></div></th> <th width="100" valign="middle" scope="col"><div align="center" class="style7"> <div align="center"><a href="http://www.nacogdochesmls.com/nag/passwd.php"><img src="images/MLS_a_94-50.gif" width="92" height="51" alt="Multiple Listing Service" /></a></div> </div></th> <th width="119" scope="col"><div align="center"><a href="http://www.hud.gov/offices/fheo/FHLaws/"><img src="http://www.habitatwhitley.org/equal_housing_logo.jpg" alt="Equal Housing Opportunity" width="60" height="62" border="0" /></a></div></th> <th width="129" scope="col"><div align="center"></div></th> </tr> <tr valign="top"> <td height="32"><div align="center" class="style8"><a href="http://www.realtor.org/technology/crt_secure/home?opendocument">REALTOR.ORG</a></div></td> <td><div align="center"></div></td> <td valign="middle"><div align="center"><span class="style10"><a href="http://www.nacogdochesmls.com/nag/passwd.php">Multiple Listing System</a></span></div></td> <td><div align="center"><strong><a href="http://www.hud.gov/offices/fheo/FHLaws/">Equal Housing Opportunity</a></strong></div></td> <td><div align="center"><a href="http://www.bbb.org/">BETTER BUSINESS BUREAU</a></div></td> </tr> </table> </div></td> </tr> </table> <div align="left"> <br /> </div> </div> </td> <td valign="top"><div align="left"></div></td> <td width="4"><div align="left"></div></td> </tr> <tr> <td width="15"> </td> <td width="35"> </td> <td width="698"><div align="center"> <?php include 'footer.shtml'; ?> </div> </td> <td width="1"><div align="center"></div></td> <td width="4"> </td> </tr> </table> </table> </table> </div> </body> </html> This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=321950.0 Hi I have been trying to populate my data from 3 tables and display like this: DATE $acronym1 $acronym2 POSTS 1/9/2011 10 (this is no of posts) 3 POSTS 31/8/2011 20 10 and so on. the threads and user table will be similar as well. I am not able to populate the distinct dates since the dateline contains time as well. So when I try to print out the just dates(without time) , it prints with the dates repeated. it prints something like this: 1/9/2011 1 1/9/2011 1 and so on.. How can populate and print the the date and number of posts in the above format. Here is my complete code below: Code: [Select] <?php error_reporting(-1); //ini_set('display_errors',1); include("db.php"); //$thirty_days_ago = strtotime("-30 days"); $limit = strtotime("-1 month"); $sql=mysql_query(("SELECT * from new_site"),$con) or die(mysql_error()); while($row=mysql_fetch_assoc($sql)) { $include=$row['include']; $forumurl=$row['forumurl']; $url=$row['url']; $acronym=$row['acronym']; include("$include"); //echo $include."<br>"; $configdbname=$config['Database']['dbname']; $configdbconport=$config['MasterServer']['servername'].":".$config['MasterServer']['port']; $configusername=$config['MasterServer']['username']; $configpassword=$config['MasterServer']['password']; $configprefix=$config['Database']['tableprefix']; /* Connect to the required database */ $con2=mysql_connect($configdbconport, $configusername, $configpassword); if (!$con2) { die('Could not connect: ' . mysql_error()); } mysql_select_db($configdbname, $con2); $postdate=mysql_query("SELECT DISTINCT dateline,postid from post WHERE dateline >='$limit' ORDER by dateline DESC") or die(mysql_error()); while($postdate_results=mysql_fetch_assoc($postdate)) { $postdate_record=$postdate_results['dateline']; // echo $postdate."<br>"; $postdate_formatted=date('M dS Y ',$postdate_results['dateline']); $post_count=mysql_query("SELECT * from post WHERE dateline >='$postdate_record'"); while($post_count_results=mysql_fetch_assoc($post_count)) { //$postdate_formatted=date('M dS Y ',$post_dateline_results['dateline']); $posts=mysql_num_rows($post_count) or die(mysql_error()); //echo $acronym.":POSTS:".$posts."<br>"; echo '<table border="1">'; echo "<tr>"; echo "<th>Category</th>"; echo "<th>".$acronym."</th>"; echo "</tr>"; echo "<tr>"; echo "<td>POSTS:DATE:".$postdate_formatted."</td>"; echo "<td>".$posts."</td>"; echo "</tr>"; } $threaddate=mysql_query("SELECT * from thread WHERE dateline >='$limit' ORDER by dateline DESC") or die(mysql_error()); while($threaddate_results=mysql_fetch_assoc($threaddate)) { $threaddate_record=$threaddate_results['dateline']; $threaddate_formatted=date('M dS Y ',$threaddate_results['dateline']); $thread_count=mysql_query("SELECT * from thread WHERE dateline='$threaddate_record'"); while($thread_count_results=mysql_fetch_assoc($thread_count)) { $threads=mysql_num_rows($thread_count) or die(mysql_error()); //echo $acronym.":THREADS:".$threads."<br>"; echo "<tr>"; echo "<td>THREADS:DATE:".$threaddate_formatted."</td>"; echo "<td>".$threads."</td>"; echo "</tr>"; $userdate=mysql_query("SELECT * from user WHERE joindate >='$limit' ORDER by joindate DESC") or die(mysql_error()); while($userdate_results=mysql_fetch_assoc($userdate)) { $userdate_record=$userdate_results['joindate']; $userdate_formatted=date('M dS Y ',$userdate_results['joindate']); $user_count=mysql_query("SELECT * from user WHERE joindate='$userdate_record'"); while($user_count_results=mysql_fetch_assoc($user_count)) { $users=mysql_num_rows($user_count) or die(mysql_error()); //echo $acronym.":USERS REGISTERED:".$users."<br>"; echo "<tr>"; echo "<td>REGISTERED USERS::DATE:".$userdate_formatted."</td>"; echo "<td>".$users."</td>"; echo "</tr>"; } } } } } } echo "</table>"; ?> hi there, the code below is suppose to display something like the attachement "code2" but instead it displays something like attachement "code1" please assist in find what is wrong with my echo lines.
<?php $counter = 2; $sqlq="select * from state WHERE status = 0 "; $categorysqlq = mysql_query($sqlq); $varq = mysql_num_rows($categorysqlq); while($catfetchq = mysql_fetch_array($categorysqlq)) { $cnty = $catfetchq[0]; $sqllq="select * from vehicle WHERE country = '$cnty' "; $categorysqllq = mysql_query($sqllq); $numsql = "select * from branchaddr WHERE state = '$cnty' "; $numquery = mysql_query($numsql); $varqa = mysql_num_rows($numquery); $cntyfetchq= mysql_fetch_array($numquery); if($varq != 0){ if($counter == 2){ echo "<tr><td><a href=\"transport2.php?id=".$cntyfetchq['state'].">".$catfetchq[1]."(<span style=\"color:red\">".$varqa."</span>)</a></td>"; $counter--; } else{ echo "<td><a href=\"transport2.php?id=".$cntyfetchq['state'].">".$catfetchq[1]."(<span style=\"color:red\">".$varqa."</span>)</a></td></tr>"; $counter = 2; } } } ?>Attached Files code1.png 12.65KB 0 downloads code2.png 25.34KB 0 downloads I have this script from http://lampload.com/...,view.download/ (I am not using a database) I can upload images fine, I can view files, but I want to delete them. When I press the delete button, nothing happens
http://www.jayg.co.u...oad_gallery.php
<form>
<?php $dir = dirname(__FILENAME__)."/images/gallery" ; $files1 = scandir($dir); foreach($files1 as $file){ if(strlen($file) >=3){ $foil = strstr($file, 'jpg'); // As of PHP 5.3.0 $foil = $file; $pos = strpos($file, 'css'); if ($foil==true){ echo '<input type="checkbox" name="filenames[]" value="'.$foil.'" />'; echo "<img width='130' height='38' src='images/gallery/$file' /><br/>"; // for live host //echo "<img width='130' height='38' src='/ABOOK/SORTING/gallery-dynamic/images/gallery/ $file' /><br/>"; } } }?> <input type="submit" name="mysubmit2" value="Delete"> </form>
any ideas please?
thanks
I read everywhere where it says not to stoe images in MYSQL but I have a code where I'm trying to display the images. They are all jpegs that are stored in the table. Here is the code Code: [Select] <?php include "dbaptsConfig.php"; include "searchaptsstyle.css"; // test id, you need to replace this with whatever id you want the result from $id = "1"; // what you want to ask the db $query = "SELECT * FROM `apartments` WHERE `id` = ".$id; // actually asking the db $res = mysql_query($query, $ms); // recieving the answer from the db (you can only use this line if there is always only one result, otherwise will give error) $result = mysql_fetch_assoc($res); // if you uncomment the next line it prints out the whole result as an array (prints out the image as weird characters) // print_r($result); // print out specific information (not the whole array) echo "<br/>"; echo "<div id='title'>".$result['title']."<br/></div>"; echo "<br/>"; echo "<div id='description'>".$result['description']."<br /></div>"; echo "<br/>"; echo "<div id='table'><tr>"; echo "<td bgcolor='#FFFFFF' style='color: #000' align='center'> Provider's Phone Number: ".$result['phone']."<br /></td>"; echo "<td bgcolor='#FFFFFF' style='color: #000' align='center'> Provider: ".$result['service']."<br /></td>"; echo "<td bgcolor='#FFFFFF' style='color: #000' align='center'> Borough: ".$result['county']."<br /></td>"; echo "<td bgcolor='#FFFFFF' style='color: #000' align='center'> Town: ".$result['town']."<br /></td>"; echo "<td bgcolor='#FFFFFF' style='color: #000' align='center'> Bedrooms: ".$result['rooms']."</td>"; echo "<td> </td>"; echo "<td bgcolor='#FFFFFF' style='color: #000' align='center'> Bathrooms: ".$result['bath']."<br /></td>"; echo "<td bgcolor='#FFFFFF' style='color: #000' align='center'> Square Footage: ".$result['square']."<br /></td>"; echo "<td bgcolor='#FFFFFF' style='color: #000' align='center'> Rent: ".$result['rent']."<br /></td>"; echo "<td bgcolor='#FFFFFF' style='color: #000' align='center'> Listed On: ".$result['time']."<br /></td>"; echo "</tr></div>"; header("Content-type: image/jpeg"); echo "<td bgcolor='#FFFFFF' style='color: #000' align='center'> Listed On: ".$result['image1']."<br /></td>"; ?> Thanks I'm creating a funeral home site and on the side of the page I would like to display the last 5 funeral obituaries that are in mySQL database (name and certain sized image (images are in "image" field) w/ a link to an "obituaries detail page for the individual deceased person"). I am able to do this successfully listing only the names....how can I list the image associated with the name? This is what I have so far: Code: [Select] <?php include("connect.php"); ?> Code: [Select] <?php $query = "SELECT id, deceased_name, deceased_date, DATE_FORMAT(deceased_date, '%M %D, %Y') as datetext"; $query .= " FROM scales_obits ORDER BY deceased_date DESC LIMIT 5"; $listings = mysql_query($query); if (!listings) { echo("<p>Error retrieving listings from lookup table<br>". "Error: " . mysql_error()); exit(); } echo("<table border=\"0\" width=\"100%\" class=\"obit\">"); while ($listing = mysql_fetch_array($listings)) { $deceased_name = $listing["deceased_name"]; $deceased_date = $listing["datetext"]; $id = $listing["id"]; echo("<tr><td width=\"100%\"><a href=\"obitdetail.php?id=".$id."\"><strong>".$deceased_name."</strong></a></td><td> </td>"); } echo("</table>"); ?> I want to display thumbnails for a picture gallery and when user clicks on image the larger image opens in a new window. I can't find a straight answer on the php.net website. Can someone help? I am looking to display image paths in a row separated by commas. There are 6 images that goes to each user and I would like only the 6 images at be in each " " Like this: "images/listings/listing_516013019A-only.jpg,images/listings/listing_848813453A-1.jpg,images/listings/listing_664613453A-2.jpg,images/listings/listing_520313453A-3.jpg,images/listings/listing_690513453A-4.jpg,images/listings/listing_125113453A-5.jpg,images/listings/listing_641013453A-6.jpg," "images/listings/listing_736913186A-1.jpg,images/listings/listing_822713186A-2.jpg,images/listings/listing_136513186A-3.jpg,images/listings/listing_700313186A-4.jpg,images/listings/listing_716013186A-5.jpg,images/listings/listing_213113186A-6.jpg," "images/listings/listing_292113254A..-1.jpg,images/listings/listing_854413254A..-2.jpg,images/listings/listing_446013254A..-3.jpg,images/listings/listing_676313254A..-4.jpg,images/listings/listing_563413254A..-5.jpg,images/listings/listing_341513254A..-6.jpg," Right now it is displaying them like this "images/listings/listing_516013019A-only.jpg," "images/listings/listing_848813453A-1.jpg," "images/listings/listing_664613453A-2.jpg," "images/listings/listing_520313453A-3.jpg," "images/listings/listing_690513453A-4.jpg," "images/listings/listing_125113453A-5.jpg," "images/listings/listing_641013453A-6.jpg," "images/listings/listing_736913186A-1.jpg," "images/listings/listing_822713186A-2.jpg," "images/listings/listing_136513186A-3.jpg," "images/listings/listing_700313186A-4.jpg," "images/listings/listing_716013186A-5.jpg," "images/listings/listing_213113186A-6.jpg," "images/listings/listing_292113254A..-1.jpg," "images/listings/listing_854413254A..-2.jpg," "images/listings/listing_446013254A..-3.jpg," "images/listings/listing_676313254A..-4.jpg," "images/listings/listing_563413254A..-5.jpg," "images/listings/listing_341513254A..-6.jpg," Here is the code I have: Code: [Select] <?php // Make a MySQL Connection mysql_connect("localhost", "xxxxxxxx", "xxxxxxxx") or die(mysql_error()); mysql_select_db("xxxxxxxx") or die(mysql_error()); $result = mysql_query("SELECT * FROM listimages ORDER BY listimages.listingid DESC ") or die(mysql_error()); while($row = mysql_fetch_array($result)) { echo "\""; echo "$row[imagepath],"; echo "\""; echo "<br>"; } ?> My tables for the images is "listimages" and the columns a id (which are the auto_increments) imagepath (which shows the path/image1.jpg) mainimage (which just shows 0 or 1 depending on the picture that is the default for that listing, 1 being default) listingid (shows numbers 1 2 3 etc corresponding to the Id in the listings table to show what images go with what listing) There are up to 6 images for each listing. Any idea how to fix this? Hi I tried to write a script: 1) to locate all directories in a directory (1 level) 2) with the function GetImages() I try to display the image(s) in the subfolder there are only images in the subfolder I guess I'm doing something wrong in the GetImages() with the glob function, can anyone check this ? Thanks in advance function GetImages($map) { $files = glob('$map/*.jpg'); //$files = glob("$map/*.*"); for ($i=0; $i<count($files); $i++) { $num = $files[$i]; echo '<img height="50" width="50" src="'.$num.'" />'." <br />"; } } if ($handle = opendir('mystuff')) { /* loop through directory. */ while (false !== ($dir = readdir($handle))) { if($dir != ".." && $dir != "."){ echo '<option value='.$dir.'>'.$dir.'</option><br>'; GetImages($dir); } } closedir($handle); } Hi everyone!! I have looked into how the upload script works and this is what i have: Code: [Select] <?php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } ?> Which is un-tested at the moment, but let's just say for talking sake it worked 100% what elements of this script would i be looking at to display the files uploaded on to another page, in my case my homepage? ive found as to yet, that the uploads have to be stored on a file somewhere on my server, which i've set up. But i thought it would be just as easy to have a field in my table named upload and display it within the table next to the other results? instead i just get whatever the file name is named.jpg. Any help in looking towards the answer? many thanks in advance guys! How can i display all the images in a certain directory and echo the image names. So if a new image is uploaded, it will still display without edited the gallery.php file. Cheers. I want to retrieve an image id from a db and show the images. I cant get the syntax right for the image tag.Any help appreciated. Code: [Select] function display_covers() { global $wpdb; $query = "select * from wp_cover"; $result = mysql_query($query)or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); echo mysql_error(); if (!$result) return false; echo'<div class="wrap"><p>choose from one of the covers below</p></div>'; echo'<div id="main">'; echo'<table class="main" cellpadding="2">'; //echo"<caption>Please choose a book cover</caption>"; ?> <thead><tr><td colspan="5" ><h6 class="main">Book Covers</h6></td></tr> </thead> <?php $i=0; $size=3; echo "<tbody>"; echo "<tr>"; while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { /* display picture */ ?> <td class="main"> <?php echo"<img src="/Applications/MAMP/htdocs/wordpress_3/wp-content/plugins/Authors2/jackets/"{.$row['pix'].}""/>"; echo"</td>"; $i++; if($i==$size) { echo "</tr><tr>"; $i=0; } } } |