php scripts not working in xampp & browser shows no errors

Alles, was PHP betrifft, kann hier besprochen werden.

php scripts not working in xampp & browser shows no errors

Postby sugafairie » 16. March 2019 12:09

php scripts not working in xampp + browser shows no error messages

I cannot get any php script to run using xampp. I'm trying to input form data via Firefox and then connect into my database, created using phpmyadmin, to insert the data into a table.

Because in ancient times I used to work with dbIII+, I used the Shell/CLI (accessed via XAMPP Control Panel) to successfully CREATE a database with 1 simple table and INSERTed 3 records. By the way, I did this after logging in to a USER I had created earlier.

However when I took a step up to using an html + php file to do the same job, no new records get INSERTed. The very simple html file runs correctly but the php produces a blank browser screen. The php should be echoing messages like connected, not connected, successfully inserted etc as these exist in the php coding.

In case you think I have made a Schoolboy error the approach I used was to copy and paste code from good sources e.g. W3, Tutorial Republic, SQL Documentation etc which I then customised with my user name, password, column names, database and table name etc. I also experimented with Youtube suggestions e.g. see mmtuts. And I tried my own creation too.

I do understand there are 3 alternative API's/php Connectors viz. mysql (deprecated), mysqli (procedural) and PDO (object oriented). I'm sticking to the mysqli style.

In my simplistic logic I suspect there is a problem with the XAMPP installation BUT I did install it with UAC switched off in the Registry and XAMPP is letting me create Websites without any problems at all.

As I'm in the early learner phase any help pitched at that level would be very much appreciated.
sugafairie
 
Posts: 14
Joined: 16. March 2019 11:51
XAMPP version: 3.2.2
Operating System: Windows 8.1

Re: php scripts not working in xampp & browser shows no erro

Postby Altrea » 16. March 2019 16:42

Hi,

Please show us your Apache access.log for checking your request
Your Apache error.log for checking any php errors
Your browsers source code view at the time you think your php script is not working
And your source code in general.

Please provide information as detailed as possible. It is really difficult to provide help remotely without any information.

Best wishes,
Altrea
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: 9618
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: php scripts not working in xampp & browser shows no erro

Postby Nobbie » 16. March 2019 22:04

sugafairie wrote:In my simplistic logic I suspect there is a problem with the XAMPP installation BUT I did install it with UAC switched off in the Registry and XAMPP is letting me create Websites without any problems at all.


I dont think so. Far from the real problems.

Instead of guessing around without a clue, it would be far more better to provide us with valid information:

a) show us your PHP script as well as the HTML Form
b) tell us, what you enter into your browser in order to run your scripts

As long as we do not have any information, we cannot help you.

sugafairie wrote:In case you think I have made a Schoolboy error the approach I used was to copy and paste code from good sources e.g. W3, Tutorial Republic, SQL Documentation etc which I then customised with my user name, password, column names, database and table name etc. I also experimented with Youtube suggestions e.g. see mmtuts. And I tried my own creation too.


Actually i believe, that there is a very simple reason for all the problems and you are doing a schoolboy error, maybe you use "short tags" instead of full Tags ("<?" instead of "<?php"), or another slight problem which causes your script to stop without visible error message.
Nobbie
 
Posts: 10880
Joined: 09. March 2008 13:04

Re: php scripts not working in xampp & browser shows no erro

Postby sugafairie » 17. March 2019 13:09

Dear All,
Unfortunately I can't see a simple way to upload images, html or php files to the forum so sadly it's all text ...

1/ Insert.html

<!DOCTYPE html>
<html>
<head>
<title>Simple HTML Form passing data into MariaDB table called Choice_of_Fruit</title>
</head>
<body>
<!-- Input a new Diner's choice of fruit here using the 'form' element -->
<form action="inject.php" method="post">
Diner's Name: <input type="text" name="DINERS_NAME">
<br><br>
Favourite Fruit: <input type="text" name="FAV_FRUIT">
<br><br>
<input type="submit" value="insert">
</form>
</body>
</html>


2/ inject.php

<?php

// Connect to Server & Database
$conn = mysqli_connect('localhost', 'root', '');

// Am I really connected to Server ?
if(!$conn)
{
echo 'Not connected to Server';
}

// Am I really connected to Database ?
if(!mysqli_select_db($conn, 'Food'))
{
echo 'Database not selected !';
}

// Insert Form Data into Table
$Diner = $_POST['DINERS_NAME'];
$Fruit = $_POST['FAV_FRUIT'];

$sql ="INSERT INTO Choice_of_Fruit (Diner, Fruit) VALUES ('$Diner', '$Fruit');";

// Has my data been inserted into the Table ?
if(!mysqli_query($conn, $sql))
{
echo 'Your new data was not inserted into the Table';
}
else
{
echo 'A new record has been created for your latest Diner';
}

// Re-direct back to data input form
header("refresh:3; url=C:\xampp\htdocs\insert.html");

?>


3/ To run this in the browser I typed...
C:\xampp\htdocs\input.html
The form appeared to work OK but the php script simply appeared in the browser window with no error messages


4/ There are no .log files in C:\xampp\php or should I be looking for something else ?
sugafairie
 
Posts: 14
Joined: 16. March 2019 11:51
XAMPP version: 3.2.2
Operating System: Windows 8.1

Re: php scripts not working in xampp & browser shows no erro

Postby sugafairie » 17. March 2019 13:39

My apologies I looked in the wrong place
Now I can see that xampp > apache > logs
has the following files
access, error, httpd, install, ssl_request
which would you like me to upload ?
sugafairie
 
Posts: 14
Joined: 16. March 2019 11:51
XAMPP version: 3.2.2
Operating System: Windows 8.1

Re: php scripts not working in xampp & browser shows no erro

Postby sugafairie » 17. March 2019 13:54

[Sat Mar 16 02:03:38.114319 2019] [ssl:warn] [pid 7136:tid 420] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 02:03:38.192454 2019] [ssl:warn] [pid 7136:tid 420] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 02:03:38.223714 2019] [mpm_winnt:notice] [pid 7136:tid 420] AH00455: Apache/2.4.38 (Win32) OpenSSL/1.1.1a PHP/7.3.2 configured -- resuming normal operations
[Sat Mar 16 02:03:38.223714 2019] [mpm_winnt:notice] [pid 7136:tid 420] AH00456: Apache Lounge VC15 Server built: Jan 18 2019 12:31:19
[Sat Mar 16 02:03:38.223714 2019] [core:notice] [pid 7136:tid 420] AH00094: Command line: 'c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Sat Mar 16 02:03:38.223714 2019] [mpm_winnt:notice] [pid 7136:tid 420] AH00418: Parent: Created child process 5464
[Sat Mar 16 02:03:38.848742 2019] [ssl:warn] [pid 5464:tid 448] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 02:03:38.926828 2019] [ssl:warn] [pid 5464:tid 448] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 02:03:38.942453 2019] [mpm_winnt:notice] [pid 5464:tid 448] AH00354: Child: Starting 150 worker threads.
[Sat Mar 16 02:04:18.286607 2019] [ssl:warn] [pid 4972:tid 424] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 02:04:18.349145 2019] [core:warn] [pid 4972:tid 424] AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Sat Mar 16 02:04:18.349145 2019] [ssl:warn] [pid 4972:tid 424] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 02:04:18.380370 2019] [mpm_winnt:notice] [pid 4972:tid 424] AH00455: Apache/2.4.38 (Win32) OpenSSL/1.1.1a PHP/7.3.2 configured -- resuming normal operations
[Sat Mar 16 02:04:18.380370 2019] [mpm_winnt:notice] [pid 4972:tid 424] AH00456: Apache Lounge VC15 Server built: Jan 18 2019 12:31:19
[Sat Mar 16 02:04:18.380370 2019] [core:notice] [pid 4972:tid 424] AH00094: Command line: 'c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Sat Mar 16 02:04:18.380370 2019] [mpm_winnt:notice] [pid 4972:tid 424] AH00418: Parent: Created child process 6816
[Sat Mar 16 02:04:19.177295 2019] [ssl:warn] [pid 6816:tid 424] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 02:04:19.271009 2019] [ssl:warn] [pid 6816:tid 424] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 02:04:19.286634 2019] [mpm_winnt:notice] [pid 6816:tid 424] AH00354: Child: Starting 150 worker threads.
[Sat Mar 16 13:12:10.620700 2019] [ssl:warn] [pid 10392:tid 472] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 13:12:10.714504 2019] [core:warn] [pid 10392:tid 472] AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Sat Mar 16 13:12:10.714504 2019] [ssl:warn] [pid 10392:tid 472] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 13:12:10.745701 2019] [mpm_winnt:notice] [pid 10392:tid 472] AH00455: Apache/2.4.38 (Win32) OpenSSL/1.1.1a PHP/7.3.2 configured -- resuming normal operations
[Sat Mar 16 13:12:10.745701 2019] [mpm_winnt:notice] [pid 10392:tid 472] AH00456: Apache Lounge VC15 Server built: Jan 18 2019 12:31:19
[Sat Mar 16 13:12:10.745701 2019] [core:notice] [pid 10392:tid 472] AH00094: Command line: 'C:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Sat Mar 16 13:12:10.745701 2019] [mpm_winnt:notice] [pid 10392:tid 472] AH00418: Parent: Created child process 10356
[Sat Mar 16 13:12:11.355097 2019] [ssl:warn] [pid 10356:tid 336] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 13:12:11.417584 2019] [ssl:warn] [pid 10356:tid 336] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 13:12:11.448863 2019] [mpm_winnt:notice] [pid 10356:tid 336] AH00354: Child: Starting 150 worker threads.
[Sat Mar 16 13:30:51.057875 2019] [mpm_winnt:notice] [pid 10392:tid 472] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Sat Mar 16 13:30:53.089204 2019] [mpm_winnt:notice] [pid 10356:tid 336] AH00364: Child: All worker threads have exited.
[Sat Mar 16 13:30:58.337646 2019] [mpm_winnt:notice] [pid 10392:tid 472] AH00430: Parent: Child process 10356 exited successfully.
[Sat Mar 16 13:52:42.196746 2019] [ssl:warn] [pid 2124:tid 476] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 13:52:42.618661 2019] [ssl:warn] [pid 2124:tid 476] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 13:52:48.679164 2019] [mpm_winnt:notice] [pid 2124:tid 476] AH00455: Apache/2.4.38 (Win32) OpenSSL/1.1.1a PHP/7.3.2 configured -- resuming normal operations
[Sat Mar 16 13:52:48.679164 2019] [mpm_winnt:notice] [pid 2124:tid 476] AH00456: Apache Lounge VC15 Server built: Jan 18 2019 12:31:19
[Sat Mar 16 13:52:48.679164 2019] [core:notice] [pid 2124:tid 476] AH00094: Command line: 'C:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Sat Mar 16 13:52:48.772863 2019] [mpm_winnt:notice] [pid 2124:tid 476] AH00418: Parent: Created child process 3900
[Sat Mar 16 13:52:54.132305 2019] [ssl:warn] [pid 3900:tid 384] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 13:52:54.272914 2019] [ssl:warn] [pid 3900:tid 384] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 13:52:54.304164 2019] [mpm_winnt:notice] [pid 3900:tid 384] AH00354: Child: Starting 150 worker threads.
[Sat Mar 16 14:14:32.575913 2019] [mpm_winnt:notice] [pid 2124:tid 476] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Sat Mar 16 14:14:34.607183 2019] [mpm_winnt:notice] [pid 3900:tid 384] AH00364: Child: All worker threads have exited.
[Sat Mar 16 14:14:34.669652 2019] [mpm_winnt:notice] [pid 2124:tid 476] AH00430: Parent: Child process 3900 exited successfully.
[Sat Mar 16 14:37:22.793613 2019] [ssl:warn] [pid 2204:tid 468] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 14:37:22.934242 2019] [ssl:warn] [pid 2204:tid 468] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 14:37:25.106140 2019] [mpm_winnt:notice] [pid 2204:tid 468] AH00455: Apache/2.4.38 (Win32) OpenSSL/1.1.1a PHP/7.3.2 configured -- resuming normal operations
[Sat Mar 16 14:37:25.106140 2019] [mpm_winnt:notice] [pid 2204:tid 468] AH00456: Apache Lounge VC15 Server built: Jan 18 2019 12:31:19
[Sat Mar 16 14:37:25.106140 2019] [core:notice] [pid 2204:tid 468] AH00094: Command line: 'C:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Sat Mar 16 14:37:25.106140 2019] [mpm_winnt:notice] [pid 2204:tid 468] AH00418: Parent: Created child process 2416
[Sat Mar 16 14:37:25.684255 2019] [ssl:warn] [pid 2416:tid 416] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 14:37:25.762383 2019] [ssl:warn] [pid 2416:tid 416] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 14:37:25.793603 2019] [mpm_winnt:notice] [pid 2416:tid 416] AH00354: Child: Starting 150 worker threads.
[Sat Mar 16 17:57:54.108910 2019] [mpm_winnt:notice] [pid 2204:tid 468] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Sat Mar 16 17:57:56.140226 2019] [mpm_winnt:notice] [pid 2416:tid 416] AH00364: Child: All worker threads have exited.
[Sat Mar 16 17:57:56.187046 2019] [mpm_winnt:notice] [pid 2204:tid 468] AH00430: Parent: Child process 2416 exited successfully.
[Sat Mar 16 21:21:54.764728 2019] [ssl:warn] [pid 1588:tid 460] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 21:21:54.996138 2019] [ssl:warn] [pid 1588:tid 460] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 21:21:55.027161 2019] [mpm_winnt:notice] [pid 1588:tid 460] AH00455: Apache/2.4.38 (Win32) OpenSSL/1.1.1a PHP/7.3.2 configured -- resuming normal operations
[Sat Mar 16 21:21:55.060966 2019] [mpm_winnt:notice] [pid 1588:tid 460] AH00456: Apache Lounge VC15 Server built: Jan 18 2019 12:31:19
[Sat Mar 16 21:21:55.060966 2019] [core:notice] [pid 1588:tid 460] AH00094: Command line: 'C:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Sat Mar 16 21:22:00.720772 2019] [mpm_winnt:notice] [pid 1588:tid 460] AH00418: Parent: Created child process 8492
[Sat Mar 16 21:22:01.333266 2019] [ssl:warn] [pid 8492:tid 408] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 21:22:01.407175 2019] [ssl:warn] [pid 8492:tid 408] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Mar 16 21:22:01.442199 2019] [mpm_winnt:notice] [pid 8492:tid 408] AH00354: Child: Starting 150 worker threads.
[Sat Mar 16 22:05:45.785932 2019] [mpm_winnt:notice] [pid 1588:tid 460] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Sat Mar 16 22:05:47.817259 2019] [mpm_winnt:notice] [pid 8492:tid 408] AH00364: Child: All worker threads have exited.
[Sat Mar 16 22:05:47.848471 2019] [mpm_winnt:notice] [pid 1588:tid 460] AH00430: Parent: Child process 8492 exited successfully.
[Sun Mar 17 01:13:30.078753 2019] [ssl:warn] [pid 2272:tid 472] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sun Mar 17 01:13:30.422505 2019] [ssl:warn] [pid 2272:tid 472] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sun Mar 17 01:13:43.863916 2019] [mpm_winnt:notice] [pid 2272:tid 472] AH00455: Apache/2.4.38 (Win32) OpenSSL/1.1.1a PHP/7.3.2 configured -- resuming normal operations
[Sun Mar 17 01:13:43.863916 2019] [mpm_winnt:notice] [pid 2272:tid 472] AH00456: Apache Lounge VC15 Server built: Jan 18 2019 12:31:19
[Sun Mar 17 01:13:43.863916 2019] [core:notice] [pid 2272:tid 472] AH00094: Command line: 'C:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Sun Mar 17 01:13:43.879540 2019] [mpm_winnt:notice] [pid 2272:tid 472] AH00418: Parent: Created child process 5720
[Sun Mar 17 01:13:44.707672 2019] [ssl:warn] [pid 5720:tid 380] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sun Mar 17 01:13:44.895192 2019] [ssl:warn] [pid 5720:tid 380] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sun Mar 17 01:13:44.926424 2019] [mpm_winnt:notice] [pid 5720:tid 380] AH00354: Child: Starting 150 worker threads.
sugafairie
 
Posts: 14
Joined: 16. March 2019 11:51
XAMPP version: 3.2.2
Operating System: Windows 8.1

Re: php scripts not working in xampp & browser shows no erro

Postby sugafairie » 17. March 2019 14:03

Dear Altrea,
My apache access log has too many characters to upload!
Can I make it blank somehow and re-run the html-php to get a shorter output?
sugafairie
 
Posts: 14
Joined: 16. March 2019 11:51
XAMPP version: 3.2.2
Operating System: Windows 8.1

Re: php scripts not working in xampp & browser shows no erro

Postby Altrea » 17. March 2019 15:28

Thats okay.

This is your issue:
sugafairie wrote:3/ To run this in the browser I typed...
C:\xampp\htdocs\input.html
The form appeared to work OK but the php script simply appeared in the browser window with no error messages


Of course your html form is working okay, because it contains full html only. HTML can be displayed by your browser correctly. It gets accessed locally, you did not request it from your Apache webserver.
The time you send your form your php file is accessed locally too, but your browser is not able to process php code, so it simply ignore it.

You need to request your html form from your webserver too by URL http://localhost/input.html
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: 9618
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: php scripts not working in xampp & browser shows no erro

Postby Nobbie » 17. March 2019 19:45

sugafairie wrote:C:\xampp\htdocs\input.html


Ouch!

That hurts, its totally wrong.

Did you ever enter a drive letter for a server in the internet (I.e. c:/www/google.de or so)?? You have to apply a valid URI (see Wikipedia about URI), in your case its http://localhost/input.html

P.S.: Thats exactly the "Schoolboy" thing....
Nobbie
 
Posts: 10880
Joined: 09. March 2008 13:04

Re: php scripts not working in xampp & browser shows no erro

Postby sugafairie » 17. March 2019 19:49

Dear Altrea,
Many thanks for your solution.
BOTH http://localhost:81/insert.html AND http://127.0.0.1:81/insert.html work.
Also from your detailed explanation I can see that I forgot that php is processed server side.
I'm an early learner and you just helped me climb over a brick wall that nearly had me giving up on learning php.
Once again, Thanks !
Cheerio,
Zenon
sugafairie
 
Posts: 14
Joined: 16. March 2019 11:51
XAMPP version: 3.2.2
Operating System: Windows 8.1

Re: php scripts not working in xampp & browser shows no erro

Postby sugafairie » 17. March 2019 19:51

Dear Nobbie,
Thanks for taking an interest,
Zenon
sugafairie
 
Posts: 14
Joined: 16. March 2019 11:51
XAMPP version: 3.2.2
Operating System: Windows 8.1


Return to PHP

Who is online

Users browsing this forum: No registered users and 2 guests