Php doesn't work

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

Php doesn't work

Postby 12strings » 08. September 2016 07:11

Hi, My problem is that my php doesn't work. I have reinstalled XAMPP-win32-1.8.0-exe several times with same result. I have copied code from a working file that was coded some time ago & pasted it to a new PHP file and executing it just displays code. I have no problem accessing databases, my control shows Apache, Mysql and Filezilla working. I'm at a loss. Help?
12strings
 
Posts: 31
Joined: 04. April 2013 17:56
Operating System: win 7 32 bit

Re: Php doesn't work

Postby Nobbie » 08. September 2016 12:55

1) Does the Xampp Splash Screen show up on http://localhost ? If yes, PHP is up and running

2) How to you start your own Script? Which action do you take i.e. what do you enter into the browser?

3) Did you use so called "short tags" in your PHP code? That means, instead of "<?php" in the beginning, did you use "<?" only? If yes, fix that and then try again.
Nobbie
 
Posts: 13182
Joined: 09. March 2008 13:04

Re: Php doesn't work

Postby 12strings » 09. September 2016 03:47

I had no problem with setup. I got all confirmations, when I click "admin" I get password page & go through standard procedure and get access to my tables.
---------------------------------------------------------------------
For testing purpose, I used the below html which is in a folder in htdocs to open php file.

Code: Select all
<html><body><center>
<a href="avisit.php">load avisit.php</a>
</center></body></html>

-------------------------------------
Below is php code. It blows up when it gets to php.

Code: Select all
<!DOCTYPE html><html>
<head>
<title>test 3</title>
</head>
<body><center>
 <form id="testform" name="testform" action="" method="post" accept-charset="UTF-8">

  <table border=1 cellpadding=2 cellspacing=2 bgcolor="#D4FFAA">
 <tr>
    <th>url</th><th>username</th><th>password</th><th>purpose</th>
    <th>emailused</th><th>date-time</th><th>count</th><th>saved</th>
 </tr>
<?php
$connect=mysql_connect("localhost", "root", "cookie") or die("error");
mysql_select_db("homedb", $connect);
$sql="SELECT * from emailtbl";
$result=mysql_query($sql, $connect);
$url='';;
while($res=mysql_fetch_assoc($result))
{
echo "<tr>";
echo "<td>"; echo '<input type="radio" name="url" >'; echo "</td>";
echo "<td>"; echo $res['username']>'; echo "</td>";
echo "<td>"; echo $res['password']; echo "</td>";
echo "<td>"; echo $res['purpose']; echo "</td>";
echo "<td>"; echo $res['emailused']; echo "</td>";
echo "<td>"; echo $res['date-time']; echo "</td>";
echo "<td>"; echo $res['count']; echo "</td>";
echo "<td>"; echo $res['saved']; echo "</td>";
echo "</tr>";
}
?>
  </table> </form></body></html>

-----------------------------------
Instead of going through screen shot, below is copied result:

connect_error) die ( 'Database connection failed: ' . $db->connect_error ); $emailStmt = $db->prepare(' SELECT * FROM emailtbl WHERE id = ? '); $emailStmt->bindParam('s', $id); $emailStmt->execute(); if ($email = $emailStmt->fetch()) { echo 'Last date accessed was ', $email['date-time']; $lastStmt = $db->prepare(' UPDATE emailtbl SET date-time = NOW() WHERE id = ? '); $lastStmt->bindParam('s', $id); $lastStmt->execute(); } else die( 'No rows returned matching id ' . $id ); ?> connect_error) die ( 'Database connection failed: ' . $db->connect_error ); if (isset($_POST['url'])) { $emailStmt = $db->prepare(' SELECT url, username, password, purpose, emailused, date-time, count, saved FROM emailtbl WHERE url = ? '); $emailStmt->bindParam('s', $_POST['url']); $emailStmt->execute(); if ($email = $emailStmt->fetch()) { echo ' '; do { echo ' '; } while ($email = $emailStmt->fetch()); echo '
Email menu url username password purpose emailused date-time count saved
', $email['url'], ' ', $email['username'], ' ', $email['password'], ' ', $email['purpose'], ' ', $email['emailused'], ' ', $email['date-time'], ' ', $email['count'], ' ', $email['saved'], '
'; } else echo 'No Matches found!
'; } else echo 'You failed to fill out a required field

------------------------------------------------------------------------------
As you see, I don't use "short open" tags.
12strings
 
Posts: 31
Joined: 04. April 2013 17:56
Operating System: win 7 32 bit

Re: Php doesn't work

Postby Altrea » 09. September 2016 06:21

It is not possible to doubleclick a local html file to load a php file with relative paths.
You will always need to use the correct URL of that php file in your html file or need to request the html file itself with it's correct URL.
Otherwise your browser does not have any idea that you want to request a file from a webserver and not only want to open a local file.
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: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Php doesn't work

Postby Nobbie » 09. September 2016 11:55

Will you please answer all my questions? Especially question 2 is still open.
Nobbie
 
Posts: 13182
Joined: 09. March 2008 13:04

Re: Php doesn't work

Postby 12strings » 11. September 2016 03:25

1) Does the Xampp Splash Screen show up on http://localhost ? If yes, PHP is up and running --- I thought I stated, but now: Nothing looks awry I get a "Welcome to phpMyAdmin", click GO and databases, etc, are displayed

    2) How to you start your own Script? Which action do you take i.e. what do you enter into the browser? --- All my folders are in "htdocs". If all files used in an app. are in the same folder why should I need to include them in my navigation file?

    Following is code for file "invoicenav.html". when I click on "Payables Paid" I get a proper report from my database table.
Code: Select all
<html><body bgcolor="#ccffff"><center><p>
<table bgcolor=pink width="180" border=0><tr>
<td><a href="http://localhost/invoice/apdue.php">Payables Due</a><br></td>
<tr><td><a href="http://localhost/invoice/appaid.php">Payables Paid</a><br></td>
<tr><td><a href="http://localhost/invoice/ardue.php">Receivables Due</a><br></td>
<tr><td><a href="http://localhost/invoice/arpaid.php">Receivables Paid</a><br></td>
</tr></table>
</center></body</html>
"

    Following is code for file "appaid.php":
Code: Select all
<html><body><center>
<?php
error_reporting(0);
mysql_connect('localhost','root','cookie');
mysql_select_db('homedb') or die("Unable to select database");
$query=" SELECT * FROM oocust WHERE payrec = 'P' AND datepaid !='' ORDER BY duedate ASC";
$result=mysql_query($query);
$num=mysql_numrows($result);
echo date('m/d/y');
echo "<font size=+1><b><center> Accounts Payable Paid Report</font></center></b></b><br />";
?>
<table cellspacing=1 cellpadding=1 border=1>
<thead>
<tr>     
<th colspan=4></th>
<th colspan=2 bgcolor="#ccffff">date</th>
<th bgcolor="#ccffff">days</th>
<th colspan=3 bgcolor="#ccffff">amt</th>
<tr>
<th bgcolor="#ccffff">recur?</th>
<th bgcolor="#ccffff">acct#</th>
<th bgcolor="#ccffff">creditor</th>
<th bgcolor="#ccffff">purpose</th>
<th bgcolor="#ccffff">d
<th bgcolor="#ccffff">paid</th>
<th bgcolor="#ccffff">late</th>
<th bgcolor="#ccffff">payable</th>
<th bgcolor="#ccffff">paid</th>
<th bgcolor="#ccffff">due</th>
</tr>
<?php
while($row = mysql_fetch_array($result))
   {
$dueamt += $row['amtdue'];
$totdue += $row['amtdue'];
        $totpaid += $row['paidamt'];         
        echo '
            <tr>
                <td>', $row['recur'], '</td>
                <td>', $row['acctno'], '</td>
                <td>', $row['bname'], '</td>
                <td>', $row['purpose'], '</td>
                <td>', $row['duedate'], '</td>
                <td>', $row['datepaid'], '</td>
                 <td align=right>', $row['dayslate'], '</td>
          <td align=right class="currency">$'.number_format($row['amtdue'],2).'</td>
         <td align=right class="currency">$'.number_format($row['paidamt'],2).'</td>
         <td align=right class="currency">$'.number_format($row['dueamt'],2).'</td>     
            </tr>';
    }     
    echo '
            <tr>
            <th bgcolor="#ccffff" scope="row" colspan="7">Grand Total:</th>
                <td bgcolor="#FFD4D4" class="currency">$'.number_format($totdue, 2, '.', ''), '</td>
                <td bgcolor="#FFFFAA" class="currency">$'.number_format($totpaid, 2, '.', ''), '</td>
                <td bgcolor="##FFD4D4" class="currency">$'.number_format($totdue-$totpaid, 2, '.', ''), '</td>               
            </tr>
        </table>';
mysql_close();
?>
</body></html>


    3) Did you use so called "short tags" in your PHP code? That means, instead of "<?php" in the beginning, did you use "<?" only? If yes, fix that and then try again.-- always use"<?php".
12strings
 
Posts: 31
Joined: 04. April 2013 17:56
Operating System: win 7 32 bit

Re: Php doesn't work

Postby Nobbie » 11. September 2016 16:33

12strings wrote:All my folders are in "htdocs". If all files used in an app. are in the same folder why should I need to include them in my navigation file?


What???? What is meant by "used in an app"??? What is meant by "navigation file"?? What is wrong with you? Why cant you simply answer, how you trigger a call to the desired file? Do you click with your mouse somewhere (if yes, where exactly?)? Do you double click with your mouse anywhere? Do you use your keyboard to enter a command somewhere (if yes, what do you enter and where)? Or do you enter a filename somewhere? My God, simply answer what you are doing. I dont want to know anything about any app and any navigation. I want to know, WHAT YOU ARE DOING.

This is what i have to know, i think you are doing something wrong there, but as long you are unable to describe, WHAT YOU ARE DOING, i cannot help you on that.
Nobbie
 
Posts: 13182
Joined: 09. March 2008 13:04


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 56 guests