XAMPP problem - php pages just show code, don't build page

  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Joined: Feb 07, 2004
  • Posts: 263
  • Loc: UK
  • Status: Offline

Post September 22nd, 2012, 3:56 pm

Firstly I should let you know that I have no idea what I am doing, so will need explanations in very simple terms.
About 7 years ago I created a website, with database, using XAMPP on my PC while I worked on it. I then had the site online for years but hosted by someone else, so I uninstalled XAMPP, but now need to make changes to the site and database while it is offline and on my computer.
I have completely forgotten how I got the site and database to run using XAMPP and I know almost nothing about php or SQL, so I need an idiot's guide (I'm sure you are shaking your head in despair by now). I know it can be done because I did it years ago when I worked on this same site.

I have Vista Home Premium and I installed XAMPP 1.8.0, then I put all my site's html and php files (e.g. index.php, library and include folders of files etc., exactly as they were when on my web hosts server) in XAMPP's htdocs folder but if I open the site and go to the index page, all I see in the browser is the php code on that file, it does not seem to extract information from the database and build the page as it did when hosted online. That is, when I go to file:///C:/xampp/htdocs/index.php all it displays in the browser is the php code that is on the index.php file.

I also tried installing XAMPP 1.5.1, as it was probably that one I used first time, but I uninstalled it and put in 1.8.0 instead, however it seems to make no difference which one I use.

I don't know where I should put my database's .sql file (mine is called shopbase.sql) or how to get the site's php files to display the pages properly using data from the database, as it did online. I have currently got that .sql file in C:/xampp/htdocs/mysql/data. I also tried it in C:/xampp/htdocs/mysql - neither place seems to work

I know the site files are fine, as the site displays and behaves as it should when uploaded to my web host and online, I just don't know how to do the same thing with them on my own PC using XMAPP. I don't know if the .sql file is in the wrong place, if I'm overlooking something or if I need to alter code or configurations somewhere to get them to work while in XAMPP's htdocs folder. I probably have to change password and user for the database but I don't think I have even got this working far enough to have even hit that problem yet.

My index.php page begins with...

Code: [ Select ]
<?php
require_once 'library/config.php';
require_once 'library/category-functions.php';
require_once 'library/product-functions.php';
require_once 'library/cart-functions.php';

$_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI'];

$catId = (isset($_GET['c']) && $_GET['c'] != '1') ? $_GET['c'] : 0;
function valid_pdId($get)
  1. <?php
  2. require_once 'library/config.php';
  3. require_once 'library/category-functions.php';
  4. require_once 'library/product-functions.php';
  5. require_once 'library/cart-functions.php';
  6. $_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI'];
  7. $catId = (isset($_GET['c']) && $_GET['c'] != '1') ? $_GET['c'] : 0;
  8. function valid_pdId($get)


My config.php file (as seen above in the line with require_once 'library/config.php') begins with...

Code: [ Select ]
<?php
ini_set('display_errors', 'On');
//ob_start("ob_gzhandler");
error_reporting(E_ALL);

// start the session
session_start();

$dbHost = 'localhost';
$dbUser = 'esite';
$dbPass = 'xintox';
$dbName = 'esite';

// setting up the web root and server root for
// this application
$thisFile = str_replace('\\', '/', __FILE__);
$docRoot = $_SERVER['DOCUMENT_ROOT'];

$webRoot = str_replace(array($docRoot, 'library/config.php'), '', $thisFile);
$srvRoot = str_replace('library/config.php', '', $thisFile);

define('WEB_ROOT', $webRoot);
define('SRV_ROOT', $srvRoot);
  1. <?php
  2. ini_set('display_errors', 'On');
  3. //ob_start("ob_gzhandler");
  4. error_reporting(E_ALL);
  5. // start the session
  6. session_start();
  7. $dbHost = 'localhost';
  8. $dbUser = 'esite';
  9. $dbPass = 'xintox';
  10. $dbName = 'esite';
  11. // setting up the web root and server root for
  12. // this application
  13. $thisFile = str_replace('\\', '/', __FILE__);
  14. $docRoot = $_SERVER['DOCUMENT_ROOT'];
  15. $webRoot = str_replace(array($docRoot, 'library/config.php'), '', $thisFile);
  16. $srvRoot = str_replace('library/config.php', '', $thisFile);
  17. define('WEB_ROOT', $webRoot);
  18. define('SRV_ROOT', $srvRoot);


I also tried a very simple test file which isn't displaying properly...
Code: [ Select ]
<html>
<head>
<title>PHP Test 1</title>
</head>
<body>
<p>This is an html line</p>
<?php echo "this is a php line"; phpinfo();
?>
</body></html>
  1. <html>
  2. <head>
  3. <title>PHP Test 1</title>
  4. </head>
  5. <body>
  6. <p>This is an html line</p>
  7. <?php echo "this is a php line"; phpinfo();
  8. ?>
  9. </body></html>

When I open it in the browser, all it shows is the line 'This is an html line'.
It does not show the line saying 'This is a PHP line'.

Is there something I should have done to make XAMPP display php?

Please bear in mind that I have virtually no knowledge of mysql or php. I didn't originally write the php or create the database, I only added to the database using the ready made files with XAMPP on my PC. The person who helped me then is no longer available to help again. I need the site to display offline exactly as it did when it was online and to have access to the database so that I can add and remove things while it is offline.

Grateful for any help that can be provided.

Regards,
Cerio
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post September 22nd, 2012, 3:56 pm

  • Zealous
  • Guru
  • Guru
  • User avatar
  • Joined: Apr 15, 2011
  • Posts: 1195
  • Loc: Sydney
  • Status: Offline

Post September 23rd, 2012, 5:17 am

o.k here is what you do

install xampp

open control panel and start apache mysql

localhost/phpmyadmin to load the sql if you need the easy way or use cmd to login and well i don't think i am going into detail just use phpmyadmin.

then your going to need to change the database/config.php file to align to the sql so localhost is where your connecting too.

if you did not go through xampp security page when first installed then username is root and no password.

should be able to connect then

but you should really look over a setup guide if a wordpress site, there could be 20 different more settings depending which software and if not custom build.
  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Joined: Feb 07, 2004
  • Posts: 263
  • Loc: UK
  • Status: Offline

Post September 23rd, 2012, 9:39 am

Thank you so much for your reply, Zealous Professor. I really appreciate it.

I have put my .sql file into the xampp/phpMyAdmin folder.
I suspect that may not be what you meant, as you said "load the sql", not copy it to there but I don't know how to load it.

Now you say, "then you're going to need to change the database/config.php file to align to the sql so localhost is where your connecting too."

I am assuming it is my config.php file, stored in the library folder, which is now in xampp htdocs folder.

To do that, do I just change
Code: [ Select ]
$dbHost = 'localhost';
$dbUser = 'esite';
$dbPass = 'xintox';
$dbName = 'esite';
  1. $dbHost = 'localhost';
  2. $dbUser = 'esite';
  3. $dbPass = 'xintox';
  4. $dbName = 'esite';


to...

Code: [ Select ]
$dbHost = 'localhost';
$dbUser = 'root';
$dbPass = '';
$dbName = 'esite';
  1. $dbHost = 'localhost';
  2. $dbUser = 'root';
  3. $dbPass = '';
  4. $dbName = 'esite';


I fear I may be wrong in that, as, when I open the index.php file (I tried it by opening one of the html files of my site, then opening the home/index.php page via the link to it on the menu on that html page) and all I see in the browser is the php code on the index.php file.

As you can tell, I have no idea what I am doing. Fortunately, I only need this up and running so I can make some alterations to my website, therefore I need it so I can access and change the stuff in the database (which, when the site was online, I could change via the phpMyAdmin page and my webhost's Plesk Panel) and view the website offline, I don't need it for anything more complex or long term than that.

My website isn't a Wordpress site.

Regards,
Cerio
  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Joined: Feb 07, 2004
  • Posts: 263
  • Loc: UK
  • Status: Offline

Post September 23rd, 2012, 3:20 pm

I don't know if this tells you anything useful but if I go to localhost/index.php (or just localhost) in my browser I get only...
Cannot select database. Unknown database 'esite'

Regards,
Cerio
  • Zealous
  • Guru
  • Guru
  • User avatar
  • Joined: Apr 15, 2011
  • Posts: 1195
  • Loc: Sydney
  • Status: Offline

Post September 23rd, 2012, 8:33 pm

o.k run through a phpmyadmin reference tutorial and follow;

create database esite

import sql into database


then change your config file to db name 'xintox'

username root
password

unless u changed in xampp security.

should work.

this is web server 101 really
  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Joined: Feb 07, 2004
  • Posts: 263
  • Loc: UK
  • Status: Offline

Post September 23rd, 2012, 9:15 pm

Thank you

Where can I find the phpmyadmin reference tutorial to learn how to create a database and then import my .sql file?

Found some in a Google search but do you recommend a specific one?

I haven't changed anything in xampp security.

Regards,
Cerio
  • Zealous
  • Guru
  • Guru
  • User avatar
  • Joined: Apr 15, 2011
  • Posts: 1195
  • Loc: Sydney
  • Status: Offline

Post September 24th, 2012, 5:03 am

go to phpmyadmin > click SQL from menu

CREATE DATABASE esite

in Left sidebar click your esite database

once you are in the database back to top menu and click import

Import the SQL file from the dump and click go which should execute the import.

then check your site as long as the database username is root and no password.

If you need the job done quick, i can put someone from my programming team on the job.
  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Joined: Feb 07, 2004
  • Posts: 263
  • Loc: UK
  • Status: Offline

Post September 24th, 2012, 8:27 am

Thanks for your help and patience with me.

When importing my .sql file into the newly created database, I got this...

Quote:
Warning: POST Content-Length of 21009913 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
localhost
You probably tried to upload too large file. Please refer to documentation for ways to workaround this limit.


Is their any solution to this? I don't know where the documentation is, to try to find the workaround mentioned, and may be too much of a novice to follow it anyway.


Regards,
Cerio
  • Zealous
  • Guru
  • Guru
  • User avatar
  • Joined: Apr 15, 2011
  • Posts: 1195
  • Loc: Sydney
  • Status: Offline

Post September 24th, 2012, 8:40 am

see
  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Joined: Feb 07, 2004
  • Posts: 263
  • Loc: UK
  • Status: Offline

Post September 24th, 2012, 8:44 am

see?

Please check my previous post, it may have changed since you first read it. I got so far with your instructions then hit a problem importing the .sql file, due to its size.
  • Zealous
  • Guru
  • Guru
  • User avatar
  • Joined: Apr 15, 2011
  • Posts: 1195
  • Loc: Sydney
  • Status: Offline

Post September 24th, 2012, 8:59 am

when i checked earlier all the reply was "I" then i added "see"

"i see" lol

then you edited your post.

anyway have you checked php.ini on file upload limits?

(No i am not giving instructions this time, Merry-Googling :))

You sure you don't just wana let someone else make the changes for you who is up to date? i am sure i got a programmer who is doing sweet f/a lol somewhere.
  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Joined: Feb 07, 2004
  • Posts: 263
  • Loc: UK
  • Status: Offline

Post September 24th, 2012, 9:13 am

I had already just Googled and found that :-). I changed it from 8M to 25M but it hasn't helped. Also tried changing it to 0 but still same problem as below.

Now getting.

Quote:
No data was received to import. Either no file name was submitted, or the file size exceeded the maximum size permitted by your PHP configuration. See FAQ 1.16.


I clicked the See FAQ 1.16. link and what it said meant nothing to me at all; it was this...
Quote:
1.16 I cannot upload big dump files (memory, HTTP or timeout problems).

Starting with version 2.7.0, the import engine has been re–written and these problems should not occur. If possible, upgrade your phpMyAdmin to the latest version to take advantage of the new import features.

The first things to check (or ask your host provider to check) are the values of upload_max_filesize, memory_limit and post_max_size in the php.ini configuration file. All of these three settings limit the maximum size of data that can be submitted and handled by PHP. One user also said that post_max_size and memory_limit need to be larger than upload_max_filesize.

There exist several workarounds if your upload is too big or your hosting provider is unwilling to change the settings:

Look at the $cfg['UploadDir'] feature. This allows one to upload a file to the server via scp, ftp, or your favorite file transfer method. PhpMyAdmin is then able to import the files from the temporary directory. More information is available in the Configuration section of this document.
Using a utility (such as BigDump) to split the files before uploading. We cannot support this or any third party applications, but are aware of users having success with it.
If you have shell (command line) access, use MySQL to import the files directly. You can do this by issuing the "source" command from within MySQL: source filename.sql.


I also tried changing ';enable_post_data_reading = OFF' to ON but it didn't help, so I changed it back.

I also tried changing
Quote:
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit

memory_limit = 128M' to -1M but it didn't help either.
I really have no idea what I am doing in there. I have now restored the original php.ini file for now.

I don't want a programmer to make the site and database changes for me but wish I knew one to hire to get xampp set up so I can do it myself.

(In that earlier post, I had typed just "I" because I wrote the post, then wanted to delete it but couldn't work out how to, so reduced it to one character, then re-edited it shortly after that.)

Regards,
Cerio
  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Joined: Feb 07, 2004
  • Posts: 263
  • Loc: UK
  • Status: Offline

Post September 24th, 2012, 10:33 am

I have now managed to install the .sql file as a zipped file (.sql.zip), so I can now access the database via phpMyAdmin, but when I open my site's home page (stored in the xampp htdocs folder), I still only get the site's index.php file's php code showing in the browser, the home page (and all other non static pages) is not being created.

My site's cofig.php file now has
Quote:
$dbHost = 'localhost';
$dbUser = 'root';
$dbPass = '';
$dbName = 'esite';


originally, when on my webhost's server, it was...
Quote:
$dbHost = 'localhost';
$dbUser = 'esite';
$dbPass = 'xintox';
$dbName = 'esite';


How do I get the pages to display properly instead of just displaying their code?
I'm one step closer, now the database is set up, but what am I overlooking now?

Regards,
Cerio
  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Joined: Feb 07, 2004
  • Posts: 263
  • Loc: UK
  • Status: Offline

Post September 26th, 2012, 4:35 pm

I've been Googling like mad for days now but can't find an answer.

If anyone can tell me how to get the site's php files (in xampp's htdocs folder) to display as web pages when I open them in a browser instead of just showing the actual php code, I'd be eternally grateful.

I'm sure I am incorrectly doing something that is very basic.

Regards,
Cerio
  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Joined: Feb 07, 2004
  • Posts: 263
  • Loc: UK
  • Status: Offline

Post September 27th, 2012, 12:48 am

Aha.
I have just discovered something, it fixes one problem but shows up another.

I was using Chrome browser and now realise that if I open the php files in Firefox, they work (sort of), but if I open them in Chrome, they don't, they just display the code typed on the file. I have no idea why but at least I can use Firefox instead.

However, now that the index.php file opens, it displays an error stating...
Quote:
you have an error in your SQL syntax. Check the manual that corresponds to your MySQL server for the right syntax to use near " at line 3

and does not assemble the page completely.

I don't have a manual but, even if I did, I'm not sure I'd work out the problem.

I can't see what is wrong. Please tell me what code to show you to see if you can help. I am not sure if it is code in the index.php file, my config.php file or perhaps my database.php file.

I'll check back here tonight, as I have to stop for now.

Regards,
Cerio
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post September 27th, 2012, 12:48 am

Post Information

  • Total Posts in this topic: 23 posts
  • Users browsing this forum: No registered users and 176 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.