php script will not execute

Problems with the Windows version of XAMPP, questions, comments, and anything related.

php script will not execute

Postby super2424 » 31. July 2012 10:04

Hi everyone! I'm completely new to this. I installed xampp a few days ago. I've been trying to figure out how to get my php script to run. I've searched around
and haven't gotten anywhere. So I joined a forum :D . It worked fine when I was starting off with a basic script like localhost\phpinfo.php in my browser.
It executes just find. I know I must put everything in my htdocs in order for a php script to run. Ok now the problem... I've created a form in html. Once submitted it
executes a php script. But instead of displaying the persons name, email, comments etc.... It just displays the variables instead of the actual data it holds. That's on google chrome. On internet explorer it just displays the source code. I would very much appreciate the help..
super2424
 
Posts: 6
Joined: 31. July 2012 09:43
Operating System: windows 7 32 bit

Re: php script will not execute

Postby Altrea » 31. July 2012 11:46

Hi super2424,

please use line breaks in your threads for better readability.

super2424 wrote:I've created a form in html. Once submitted it executes a php script. But instead of displaying the persons name, email, comments etc.... It just displays the variables instead of the actual data it holds. That's on google chrome. On internet explorer it just displays the source code. I would very much appreciate the help..


Very common you don't request the file with the form the right way. SImply opening it in the browser will not work. It has to be requested with a valid URL.

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

Re: php script will not execute

Postby super2424 » 01. August 2012 06:19

Thanks for the reply. But Shouldn't it work if I have both the files in my htdocs? That's where I'm supposed to put them, correct?
super2424
 
Posts: 6
Joined: 31. July 2012 09:43
Operating System: windows 7 32 bit

Re: php script will not execute

Postby Altrea » 01. August 2012 07:36

If you request them correct, yes. If not, then no.
The whole thing depends what is showing in your browsers address bar at the time you get the sourcecode instead processed 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: 8294
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: php script will not execute

Postby super2424 » 02. August 2012 05:26

I appreciate you helping me. I've been searching all over the internet. When I load my php script(localhost/handle_form.php) I get a parse error I can't find. Here's the parse error.

Parse error: syntax error, unexpected ',' in C:\xampp\htdocs\handle_form.php on line 24

I guess this is why it's not working. It's displaying an error I can't find or seems to not exsist.

Everything looks fine. The code is excactly how it is in a php book I'm reading. Here's my script

<?php
ini_set ('display_errors', 1);
// Let me learn from my mistakes!
error_reporting (E_ALL | E_STRICT);
// Show all possible problems!

// This page receives the data from
feedback.html.
// It will receive: title, name, email,

response, comments and submit in //This is line 24.
$_POST.

// Create shorthand versions of the
variables:
$title = $_POST['title'];
$name = $_POST['name'];
$response = $_POST['response'];
$comments = $_POST['comments'];

// Print the received data:
print "<p>Thank you, $title $name,
for your comments.</p>
<p>You stated that you found this
example to be $response and
added:<br />$comments</p>";
?>


I really wanna figure it out.

Thanks! :)
super2424
 
Posts: 6
Joined: 31. July 2012 09:43
Operating System: windows 7 32 bit

Re: php script will not execute

Postby JonB » 02. August 2012 14:06

By any chance is this line 24

print "<p>Thank you, $title $name,
for your comments.</p>

8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: php script will not execute

Postby Altrea » 02. August 2012 16:21

super2424 wrote:Parse error: syntax error, unexpected ',' in C:\xampp\htdocs\handle_form.php on line 24

I guess this is why it's not working.

That is not your initial problem that the variables are displayed instead of it's content.
If that would be your initial issue, you would get this error message after sending the form too.
But i guess that you request the form the wrong way.

super2424 wrote:Here's my script

<?php
ini_set ('display_errors', 1);
// Let me learn from my mistakes!
error_reporting (E_ALL | E_STRICT);
// Show all possible problems!

// This page receives the data from
feedback.html.
// It will receive: title, name, email,

response, comments and submit in //This is line 24.
$_POST.

// Create shorthand versions of the
variables:
$title = $_POST['title'];
$name = $_POST['name'];
$response = $_POST['response'];
$comments = $_POST['comments'];

// Print the received data:
print "<p>Thank you, $title $name,
for your comments.</p>
<p>You stated that you found this
example to be $response and
added:<br />$comments</p>";
?>

Please wrap your code in code-BBTags, because:
  • Your singleline line brakes are not visible here as single lined.
  • I can't see why the line you marked should be line 24.

sorry, but i can't provide any help with that informations.

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

Re: php script will not execute

Postby super2424 » 02. August 2012 23:21

I guess I'll figure it out eventually but here is my entire code for it. Thanks!

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/
xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/
xhtml" xml:lang="en" lang="en">
 <head>
 <meta http-equiv="Content-Type"
content="text/html; charset=utf-8"/>
 <title>Your Feedback</title>
 </head>
 <body>

 <?php
 ini_set ('display_errors', 1);
// Let me learn from my mistakes!
 error_reporting (E_ALL | E_STRICT);
// Show all possible problems!

 // This page receives the data from
feedback.html.
 // It will receive: title, name, email,

response, comments, and submit in   // This is line 24
$_POST.

 // Create shorthand versions of the
variables:
 $title = $_POST['title'];
 $name = $_POST['name'];
 $response = $_POST['response'];
 $comments = $_POST['comments'];

 // Print the received data:
 print "<p>Thank you, $title $name,
for your comments.</p>
 <p>You stated that you found this
example to be $response and
added:<br />$comments</p>";
 ?>
 </body>
 </html>
super2424
 
Posts: 6
Joined: 31. July 2012 09:43
Operating System: windows 7 32 bit

Re: php script will not execute

Postby Altrea » 02. August 2012 23:39

If this is your real sourcecode (line breaks, etc) then you have a massive problem with your singleline linebreaks. Your code will not run.
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: 8294
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: php script will not execute

Postby super2424 » 03. August 2012 08:17

WOW.. I finally figured it out!!!!! :mrgreen:
super2424
 
Posts: 6
Joined: 31. July 2012 09:43
Operating System: windows 7 32 bit

Re: php script will not execute

Postby Altrea » 03. August 2012 08:43

so why don't you tell the community what the problem was so that other users can have a benefit from your thread?
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: 8294
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: php script will not execute

Postby super2424 » 03. August 2012 09:16

On my php script I deleted the extra things like the html doc type at the head of my script as well as the title etc.. Any html element that was outside the php tags

<?php---?> and just left the php itself. Not sure if it is a proper thing to do but it worked for me. Then Just put a basic html element and a body

element around the php tags and still worked. Here is my revision of my php script. Hope it helps others. Thanks!

Code: Select all
<html>

<body>

 <?php
 ini_set ('display_errors', 1);



 error_reporting (E_ALL | E_STRICT);

//variables
 $title = $_POST['title'];
 $name = $_POST['name'];
 $response = $_POST['response'];
 $comments = $_POST['comments'];

 // Print the received data:
 print "<p>Thank you, $title $name,
for your comments.</p>
 <p>You stated that you found this
example to be $response and
added:<br />$comments</p>";

 ?>
 </body>

 </html>
super2424
 
Posts: 6
Joined: 31. July 2012 09:43
Operating System: windows 7 32 bit


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 22 guests