Page 1 of 1
what is wrong in this php code?It is just fetching "area"
Posted: Tue Jun 02, 2009 5:40 am
by dinku33
Code: Select all
<?
ob_start();
session_start();
include "inc/conf.php";
?>
<?
if(strlen(trim($row['Add1']))>0)
echo $row['Add1']." ";
if(strlen(trim($row['Add2']))>0)
echo $row['Add2'].", ";
elseif(strlen(trim($row['Add1']))>0)
echo ",";
if(strlen(trim($row['landmark']))>0)
echo $row['landmark'].", ";
if(strlen(trim($row['area']))>0)
echo $row['area'].", ";
if(strlen(trim($row['City']))>0)
echo $row['City'].", ";
if(strlen(trim($row['Country']))>0)
echo $row['Country'].", ";
if(strlen(trim($row['Pin']))>0)
echo $row['Pin'];
?>
Re: what is wrong in this php code?It is just fetching "area"
Posted: Tue Jun 02, 2009 9:09 am
by mikemike
Have you tried some basic debugging like printing $row?
Can we see the contents of $row?
Can you give us some more details on the page? Are you getting any errors? Is error reporting on? etc
Help us help you...
Re: what is wrong in this php code?It is just fetching "area"
Posted: Wed Jun 03, 2009 5:05 pm
by dinku33
This is the page.
http://www.wewillbook.com/world-hotel-d ... search.php. If you see the 5th hotel (Belmonte Guesthouse), you will find "Paarl" under the name of hotel. This is the area fetched from database. I would like to have Street, Area, City, Country and Pin number instead of just Area. Any suggestion?
Re: what is wrong in this php code?It is just fetching "area"
Posted: Wed Jun 03, 2009 5:38 pm
by mikemike
Again, we need to see what the contents of $row. Also, put braces around your if-statements. I know if's will still work without them but it can sometimes be miss-leading.
Also, on a side note from your code, you're making a textbook error on your search results. You're relying on HTML to resize your images client-size. This both looks ugly due to pixelation and increases loadtime and bandwidth. Use something like Imagemagick or GD-lib to resize the images serverside.
Re: what is wrong in this php code?It is just fetching "area
Posted: Wed Jun 03, 2009 6:52 pm
by McInfo
Keep in mind that strings are case-sensitive.
is not the same as
Edit: This post was recovered from search engine cache.