what is wrong in this php code?It is just fetching "area"

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dinku33
Forum Newbie
Posts: 10
Joined: Thu Jan 17, 2008 4:43 pm

what is wrong in this php code?It is just fetching "area"

Post 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']; 
?>
User avatar
mikemike
Forum Contributor
Posts: 355
Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK

Re: what is wrong in this php code?It is just fetching "area"

Post 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...
dinku33
Forum Newbie
Posts: 10
Joined: Thu Jan 17, 2008 4:43 pm

Re: what is wrong in this php code?It is just fetching "area"

Post 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?
User avatar
mikemike
Forum Contributor
Posts: 355
Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK

Re: what is wrong in this php code?It is just fetching "area"

Post 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.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: what is wrong in this php code?It is just fetching "area

Post by McInfo »

Keep in mind that strings are case-sensitive.

Code: Select all

$row['City']
is not the same as

Code: Select all

$row['city']
Edit: This post was recovered from search engine cache.
Post Reply