Localhost, Open PHP file, Returns PHP Code

Alles, was PHP betrifft, kann hier besprochen werden.

Localhost, Open PHP file, Returns PHP Code

Postby Viper75 » 25. June 2020 22:31

Hello,

I have read a few of the posts regarding the PHP script not running correctly, but have not been able to determine the exact issue or cause that affects my problem. I have php 7.4.7, i have the SQL drivers installed for MS SQL Server, x64, thread safe. I am using Firefox and Chrome.

I can start Apache, open the Admin screen, open PHP Info to verify the drivers are listed.

The PHP file I want to open/execute is xampp/htdocs/phpCon/index.php. I type "localhost/phpCon/" into the browser, and I see all the PHP code starting with the database name.

This is the total code in "index.php":

Code: Select all
<? php
   $serverName = "TWCGIMDT01\SQLEXPRESS";
   $connectionInfo = array( "Database"=>"MainDB");
   $conn = sqlsrv_connect( $serverName, $connectionInfo);
   
   if( $conn ) {
         echo "Connection established.<br />";
   }
   else {
      echo "Connection could not be established.<br />";
      die( print_r(sqlsrv_errors(), true));
   }
?>


This is from the Apache access log when I open the index.php file:

Code: Select all
::1 - - [25/Jun/2020:14:26:35 -0700] "GET /phpCon/ HTTP/1.1" 200 335 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0"


This are the last couple of entries to the Apache Error log:

Code: Select all
[Thu Jun 25 14:24:42.494398 2020] [ssl:warn] [pid 55224:tid 552] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Thu Jun 25 14:24:42.585401 2020] [ssl:warn] [pid 55224:tid 552] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Thu Jun 25 14:24:42.635396 2020] [mpm_winnt:notice] [pid 55224:tid 552] AH00354: Child: Starting 150 worker threads.


I get the same results with Chrome.

I understand that it may not have anything to do with the browser, but rather Apache being able to run the PHP. Correct?

Where do I go from here?
Viper75
 
Posts: 4
Joined: 25. June 2020 17:49
XAMPP version: 3.2.4
Operating System: Win10, x64

Re: Localhost, Open PHP file, Returns PHP Code

Postby Altrea » 26. June 2020 08:37

Wrong
Code: Select all
<? php


Correct
Code: Select all
<?php
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 10333
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Localhost, Open PHP file, Returns PHP Code

Postby Viper75 » 28. July 2020 22:12

Thanks!
Viper75
 
Posts: 4
Joined: 25. June 2020 17:49
XAMPP version: 3.2.4
Operating System: Win10, x64


Return to PHP

Who is online

Users browsing this forum: No registered users and 4 guests