Page 1 of 1

Testing PHP/MySql without a server?

Posted: Sat Mar 19, 2011 1:21 pm
by Orsen
Hello,

I recently got dreamweaver cs5 and was wondering if its possible to test php/mysql within the program without having a server?

If this is not possible, where is the cheapest place for servers? I won't be using much space just practicing.

Re: Testing PHP/MySql without a server?

Posted: Sat Mar 19, 2011 4:10 pm
by greyhoundcode
If you mean that you don't want to purchase hosting then perhaps you should look at a package like Xampp which, simply put, will allow you to test out code and run web apps on your local machine.

Other similar packages also exist, depending on your personal preference and what sort of OS you are running.

Wamp
Mamp
EasyPHP

You could also get hold of and install individual parts of the stack separately.

Re: Testing PHP/MySql without a server?

Posted: Sat Mar 19, 2011 4:13 pm
by McInfo
PHP and MySQL servers are necessary; however, expense is not. Web programmers typically install an HTTP server (Apache, IIS, etc.) on a local machine along with a database server (MySQL, etc.). Together, that locally-installed software makes up the development environment. When the developed application is ready for public use, it is uploaded to a production environment.

It is possible to create a development environment with no-cost software. As greyhoundcode mentioned, the quickest and easiest way to set up a server is to install a bundle like XAMPP. If the HTTP server lives on the same machine as your browser, it is known to your browser as "http://localhost/" or "http://127.0.0.1/".

Re: Testing PHP/MySql without a server?

Posted: Sun Mar 20, 2011 3:32 pm
by Orsen
I've installed Apache 2.2 and my server is running fine.

Only problem is that some of the php commands do not work, echo for example is fine but getting information from a text file does not want to work.. Im trying to create a listing system that basically has all my possessions and once someone borrows one of my items, I can change it to "Lent out" while giving it a time limit too, so in 2 weeks time I'll either email them or send an SMS text message.

Thanks for the recommendations.

Re: Testing PHP/MySql without a server?

Posted: Sun Mar 20, 2011 3:43 pm
by Jonah Bron
What do you mean "does not want to work"? Do you get an error? Do you have errors enabled? If you don't, you should. A development environment should always have errors enabled.

http://nucleussystems.com/blog/enable-error-reporting

Re: Testing PHP/MySql without a server?

Posted: Sun Mar 20, 2011 3:54 pm
by McInfo
If you want help with a particular script, please post the code. Also state where the files are located.

You may be better off using a database instead of a text file.

Re: Testing PHP/MySql without a server?

Posted: Sun Mar 20, 2011 5:58 pm
by Orsen

Code: Select all

<?
$data=file_get_contents('list.txt'); 
$dat=explode("\r\n",$data); 
echo '<table border=1 cellpadding=3 cellspacing=0>';
foreach ($dat AS $val) { 
echo '<tr><td>'.$val.'</td></tr>'; 
}echo '</table>';
?>
The file is located in the same folder as the php file.

When I load the php file all it shows is

Code: Select all

}echo '</table>';?>
No error messages : / They are enabled I checked.

Re: Testing PHP/MySql without a server?

Posted: Sun Mar 20, 2011 6:19 pm
by Jonah Bron
That means that PHP isn't being executed. Try using full <?php ?> tags instead of the short <? ?> tags. That's a best practice anyway.

Re: Testing PHP/MySql without a server?

Posted: Tue Mar 22, 2011 12:46 pm
by Orsen
I tried it, but to no such luck.

Its definitely not recognising PHP anymore, it was working fine a few weeks back but it's packed up and I have no idea how to fix it... : /

Definitely need a server thats reliable and not installed by myself :DD

Re: Testing PHP/MySql without a server?

Posted: Tue Mar 22, 2011 12:56 pm
by social_experiment
How are you running the file i.e http://localhost/your_file.php ? Paste the following into a file name file.php then execute it (and report your results :) )
Hth

Code: Select all

<?php phpinfo(); ?>