1

I am going to retrieve some data from database and display it in php file.

It seems like it can connect to my localhost's database,because code like:

<?php foreach($goods as item ):?>

haven't occur any errors.

but when it comes to the codes like,

<?php echo $item->logo;?>

on my browser, it simply display

 logo;?> 

what's wrong with my codes or setting. As the file is quite big and I think the system config problem(I have reinstalled wampserver), I just show a little bit my code:

<?php echo sizeof($goods);?>
<td class="td_f"><a href="" target="_blank"><IMG src="http://127.0.0.1:8020/UB_real//public/photos/frontimg/<?php echo $item->logo?>"> </a></td>
<?php endforeach; ?>
wonderland
  • 11
  • 3
  • will u post your php code ? – liyakat Jul 05 '13 at 10:20
  • When you say localhost do you mean you are trying to run this on your PC? – Styphon Jul 05 '13 at 10:22
  • There are small syntax errors in these snippets. Is this your real code? –  Jul 05 '13 at 10:22
  • 1
    Where you said `` you must say `` – Lan Jul 05 '13 at 10:24
  • Are you running a webserver on localhost? PHP web pages have to be run through a server, not as local files. – Barmar Jul 05 '13 at 10:26
  • what do you mean by pointer? – Yousuf Memon Jul 05 '13 at 10:29
  • I am running wampapache on my computer and I put the codes into the designed file Apache Version : 2.2.8 PHP Version :5.2.6 MYSQL :5.0.51b – wonderland Jul 05 '13 at 10:31
  • I think we are going to need to see more of the code to be able to make any sensible suggestions – RiggsFolly Jul 05 '13 at 10:33
  • Your webserver is showing php pure code as text/html. it's not executing php. check your apache config. – Mohebifar Jul 05 '13 at 10:35
  • And also this is completely wrong in php and reason of not showing error is that there is a start for a tag and there is an end. andyour browser recognize it as a HTML tag. but the second one is closed after $item->. IT IS A HTML TAG : and this is after your tag and is ready to show logo;?> – Mohebifar Jul 05 '13 at 10:37

1 Answers1

0

You have an error in your code:

Where you said:

<?php foreach($goods as item ):?>

Must be:

<?php foreach($goods as $item ); ?>

Note the missing $ before item, and the semicolon ; not the :

If you need to list all the returned values in $goods (for testing purposes), you can always do:

echo '<pre>';
print_r($goods);
echo '</pre>';
Lan
  • 709
  • 1
  • 8
  • 16
  • if I cannot do your codes ,does that mean my php is not config properly ? – wonderland Jul 05 '13 at 11:26
  • To check if your php is running, just create a file named info.php and paste the code: ``, save and access to that file. If you see the code, you don't have php properly installed or running. If you see php information, it works. – Lan Jul 05 '13 at 11:55