newbie problem

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
User avatar
simplypixie
php-forum Active User
php-forum Active User
Posts: 300
Joined: Sun Dec 11, 2011 12:51 am
Location: Shrewsbury, Shropshire
Contact:

Thu Nov 22, 2012 11:42 pm

All your Print references should be echo

User avatar
simplypixie
php-forum Active User
php-forum Active User
Posts: 300
Joined: Sun Dec 11, 2011 12:51 am
Location: Shrewsbury, Shropshire
Contact:

Fri Nov 23, 2012 3:29 am

So your code now looks like this

Code: Select all

<html>
   <head>
   </head>
   <body>
      <?php
       mysql_connect("localhost", "root", "eucenje") or die(mysql_error());
       mysql_select_db("conquer_the_world") or die(mysql_error());
       
       $data = mysql_query("SELECT * FROM country") or die(mysql_error());
       echo "<table border='1'>";
       
       while($info = mysql_fetch_array( $data )) {
          echo "<tr>";
          echo "<th>Name:</th> <td>".$info['name'] . "</td> ";
          echo "<th>Pet:</th> <td>".$info['idCountry'] . " </td></tr>";
       }
       echo "</table>";
       ?>
   </body>
</html>
And you are still getting the while loop php printing in the browser? That doesn't make any sense as there is nothing wrong with this code.

User avatar
simplypixie
php-forum Active User
php-forum Active User
Posts: 300
Joined: Sun Dec 11, 2011 12:51 am
Location: Shrewsbury, Shropshire
Contact:

Sat Nov 24, 2012 1:55 am

That code should not be printing out your php code. Is your file definitely a .php not .html? Is there anything else on the page that you aren't showing?

Post Reply
  • Information
  • Who is online

    Users browsing this forum: Bing [Bot] and 2 guests