Jump to content

PHP code showing on webpage.....not getting DB info. HELP!


punkcrib

Recommended Posts

Hello.  I am extremely new to php.  In fact I don't know much about it.  I usually code in c#, vb, .net, etc (Please dont hold that agaisnt me!  It isnt by choice...)

 

Anyway, I've been asked to move a company's site to our webserver.  But their site is Php/MySQL, and we only had MSSQL/.Net installed on the server.  So I found a few tutorials on installing PHP/MySQL on a Windows IIS system (WIMP, right?).  I got their DB imported into MySQL and I can see/access the data fine through MySQL Administrator.  I have set up the database using the same name, user & password as was previously used for the site (so that I do not have to change any of that on the pages).

 

The problem I am having is that whenever I click on a link to a .php page on the site, the page will display but there is a bunch of code also being displayed, and not the data that should be.  For example, this code will produce the image attached to this post:

 

<div align="center">
  <center>
  
  <p>
				  <?php
$count = 0;
$db = mysql_pconnect("localhost", "bayouboard", "bayou396");
mysql_select_db("bayouboard",$db);
$result = mysql_query("SELECT * FROM link_category ORDER BY category",$db);
if ($myrow = mysql_fetch_array($result)) {
	do {
		if ($count == 0) {
		?>
            <div align="center"></div>
            <table width="75%" border="1" cellspacing="0" cellpadding="5" bordercolor="#545454" align="center">
              <tr> 
                            
        <td align="left" valign="top" bgcolor="#000099"> 
          <p> </p>
                              
          <font face="Arial, Helvetica, sans-serif" size="3"><b><font color="#FFFFFF"> 
          <?
 printf("<font face=\"Arial, Helvetica, sans-serif\" size=\"3\" color=\"#ffffff\"><b>%s</b></font><br>", $myrow["category"]); 
 ?>
          </font></b></font></td>
              </tr>
              <tr> 
                
        <td height="13" align="left" valign="top" bgcolor="#FFFFCC"> 
          <div align="left"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"> 
            <? 
   $title = $myrow["category"];
      include("links_include.php");
	  ?>
            </font></div>
                </td>
              </tr>
            </table>
            <br>
            <br>
            <?
$count = 1;
		} else {
?>
                    
                  <table width="75%" border="1" cellspacing="0" cellpadding="5" bordercolor="#545454" align="center">
                    <tr> 
                            
        <td align="left" valign="top" bgcolor="#000099"> 
          <p> </p>
                              
          <font face="Arial, Helvetica, sans-serif" size="2"><b><font color="#FFFFFF"> 
          <?
 printf("<font face=\"Arial, Helvetica, sans-serif\" size=\"3\" color=\"#ffffff\"><b>%s</b></font><br>", $myrow["category"]); 
 ?>
          </font></b></font></td>
              </tr>
              <tr> 
                
        <td height="13" align="left" valign="top" bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"> 
          <? 
   $title = $myrow["category"];
      include("links_include.php");
	  ?>
          </font></td>
              </tr>
            </table>
            <br>
            <br>
    <?
$count=0;
		}
} while ($myrow = mysql_fetch_array($result));
}else {
                echo "Sorry we don't have any links up at this time, please check back later." ;   
}
?></p>
    
  </center>
</div>

 

I have not changed any of this code, and it was working fine on their old (Linux) server.  Perhaps one of you gurus will know exactly what is wrong here and why, but I am stumped.  I do not see how or why the code is being displayed instead of the data supposed to be retreived from the DB.  Other pages php pages are exactly the same, with some actually showing whole sections of code instead of just a snippet like this.

 

Can anyone offer some help?  I really need to get this stuff working correctly.  I haven't changed and of the default settings in php if that is any help.  I'm sure I need to, but like I said I am a noob.  thanks!

 

 

[attachment deleted by admin]

Thanks for the help, I wasn't aware of that feature.  Like I said, I'm really new to php. 

 

However, after I went into php.ini and set short_open_tag to "on", I rebooted the server and pulled up the page again, and I still receive the same results.  The php code is getting displayed, not the DB info.

 

Any other ideas?  I can post more examples if you want.  This is happening on every php page.  Some show more code than others (several lines in fact).  Thanks!

Is ANY php code being processed? Don't trust what you see in the browser, do a View Source on the webpage to see the actual output. When you do that View Source, is any of the PHP code evaluated, or does it look identical to the real source code on the server?

 

If NO php code is being processed, then we have to back up to the configuration of the server.

Linux or Windows?

PHP version?

Two things, make sure the file has a .php file extension.  If it does, then it sounds like PHP is not properly installed.

 

Take Rhodesa's advice, create a new simple file, use <?php echo "hello"; ?> and see if it works.

When I view the source it is identical to the php file.  I know this should not be the case, but I do not know what this means.  I know when I installed php I did a little test page w/ <?php phpinfo();?> and I remember it worked.  Now it is not though.  if I double click on my test.php (with that phpinfo() call) it opens in notepad.  I created an html page w/ a link to test.php and it asks me to download the .php file.......

 

PHP version 5.2.6

Windows 2003 server

 

 

So I'm not sure how php stopped working but what do I do to get it back up and running?  Thanks for the help again!

That would be an Installation issue and not code related.

 

Really?!? Seriously?!?  Wow, thanks, I would have never guessed that, Captian Obvious! ::)

 

Thanks for taking the 30 seconds out of your busy day to type that extremely helpful post.

That would be an Installation issue and not code related.

 

Really?!? Seriously?!?  Wow, thanks, I would have never guessed that, Captian Obvious! ::)

 

Thanks for taking the 30 seconds out of your busy day to type that extremely helpful post.

 

Let me respond on behalf of revraz...YOU'RE WELCOME. Now to determine if you worthy of 60 second post....

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.