Basic php script

hello, i am getting into the book database driven websites with php and mysql. when i test the basic “today’s date”, “hi i’m kevin”, and “hi i am kevin yank”, i get a white screen when i click on the link in the html page. nothing ‘echos’. thanks. codibel.

Hi starlion,

i am still getting white screen. how do i turn on error reporting?

my setup:

i found the WAMP site, which appeared to have downloaded everything. when i open it, a gauge like icon appears in my status bar. when clicked on, a menu named “wampserver 2.0” pops up from it. that menu is loaded with programs: localhost, phpmyadmin; folders with more stuff: an icon to my root directory, a folder each for apache, php, mysql; and 3 shortcuts to start, stop, and restart all services.

that’s how i access the mysql console to practice commands and conditions and functions to create databases; open localhost, where i select file>open_file… to test my php scripts, and html files, and where i access the back end of Joomla!, which i am also trying to gain knowledge.

all the above programs were installed automatically, if i remember correctly.

thanks so much, and i hope i provided you with useful information.

codibel

hi bishwadeepkc

i copied and pasted your code, but still i get white screen. any suggestions?

my setup:

i found the WAMP site, which appeared to have downloaded everything. when i open it, a gauge like icon appears in my status bar. when clicked on, a menu named “wampserver 2.0” pops up from it. that menu is loaded with programs: localhost, phpmyadmin; folders with more stuff: an icon to my root directory, a folder each for apache, php, mysql; and 3 shortcuts to start, stop, and restart all services.

that’s how i access the mysql console to practice commands and conditions and functions to create databases; open localhost, where i select file>open_file… to test my php scripts, and html files, and where i access the back end of Joomla!, which i am also trying to gain knowledge.

all the above programs were installed automatically, if i remember correctly.

thanks so much, and i hope i provided you with useful information.

codibel

i decided not to delete the content of your initial reply so you have your bearings. i am so new to this; i am actually struggling even with forums. i apologize in advance for any stupidities.

well, i’ll get my griping done first and last. i am confused about local hosts. one can’t really see them, like a file inside a folder somewhere, is that correct?

i had much delays installing php, local server, mysql, databases, etc. kept getting 404 messages. so it is no surprise i am stuck on my first php script.

i found the WAMP site, which appeared to have downloaded everything. when i open it, a gauge like icon appears in my status bar. when clicked on, a menu named “wampserver 2.0” pops up from it. that menu is loaded with programs: localhost, phpmyadmin; folders with more stuff: an icon to my root directory, a folder each for apache, php, mysql; and 3 shortcuts to start, stop, and restart all services.

that’s how i access the mysql console to practice commands and conditions and functions to create databases; open localhost, where i select file>open_file… to test my php scripts, and html files, and where i access the back end of Joomla!, which i am also trying to gain knowledge.

all the above programs were installed automatically, if i remember correctly.

thanks so much, and i hope i provided you with useful information.
hope to hear from you.
codibel

If you are using WAMP it should not be the case of installation problem because WAMP has its pre-configured installation for you. You just need to start all services if they are not started by default.

Once all the installations are started, then click on the icon on the task bar (bottom right in your screen) then click on ‘localhost’. This will call a page in your default browser with the project listing in WAMP document root. Normally the folder named ‘www’ inside ‘wamp’ folder in your installation drive i.e. C:\wamp\www or D:\wamp\www. If you can see the WAMP welcome page in your browser then it is for sure that your PHP is running correctly.

Now to test your own code, just create a file with .php extension and some PHP code enclosed PHP tag, i.e. your file name is: phpinfo.php


<?php phpinfo(); ?>

When you try in your browser http://localhost/phpinfo.php, then you have a page with PHP and server information in your PC.

or simply try the following code:


<?php
echo 'Hello codibel, how are you?';
?>

If you can see ‘Hello codibel, how are you?’ in the browser, then your PHP is running quite good. Otherwise come again with your other problems and your work around.

Good luck!

hi! it works! i was trying to open up my files with the file>open menu item. when i typed the file in the url field in the navigation toolbar, it worked!

thank you so much!

I don’t know what are you trying to ask here. I am posting you some suggestions and you are posting same thing again and again. Did you get phpmyadmin running ?

Do you mean you can access Joomla back end? What do you mean with Joomla back end…

To access this page write welcome1.php?name=something

thanks so much for the lead, rajug. everything you said to check works, so i am relieved that my php installation is not the issue.

i will perform the test scripts and see what results.

be in touch as soon as i find out.

i truly appreciate your help. i am getting the jist of the php, it is just perplexing when i run the script for browser display and it fails. after all, that’s what it is all about - to interact with users!

ttyl
codibel

i am figured it out! thank you very much. i need to type the file directly into the url field in the navigation toolbar. i was opening the php file with file>open in the menu bar.

cheers!
codibel

hello rajug,

have you had time to go over my information? i’d appreciate a steer in the right direction. i am kind of stuck.
thanks, codibel

i decided not to delete the content of your initial reply so you have your bearings. i am so new to this; i am actually struggling even with forums. i apologize in advance for any stupidities.

well, i’ll get my griping done first and last. i am confused about local hosts. one can’t really see them, like a file inside a folder somewhere, is that correct?

i had much delays installing php, local server, mysql, databases, etc. kept getting 404 messages. so it is no surprise i am stuck on my first php script.

i found the WAMP site, which appeared to have downloaded everything. when i open it, a gauge like icon appears in my status bar. when clicked on, a menu named “wampserver 2.0” pops up from it. that menu is loaded with programs: localhost, phpmyadmin; folders with more stuff: an icon to my root directory, a folder each for apache, php, mysql; and 3 shortcuts to start, stop, and restart all services.

that’s how i access the mysql console to practice commands and conditions and functions to create databases; open localhost, where i select file>open_file… to test my php scripts, and html files, and where i access the back end of Joomla!, which i am also trying to gain knowledge.

all the above programs were installed automatically, if i remember correctly.

thanks so much, and i hope i provided you with useful information. please don’t give up on me. i’m always very foggy in the beginning, but quickly catch up taking everything very seriously.
codibel

yes. quite right. here is the code for the page entitled “welcome1”:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>

<html xmlns=“http://www.w3.org/1999/xhtml” xml:lang=“en” lang=“en”>

<head>

<title>welcome1.php</title>

<meta http-equiv=“content-type”

content=“text/html; charset=utf-8”/>

</head>

<body>

<p>
<?php
$name = $_GET[‘name’];
echo"Welcome to our Website, $name !";
?>
</p>
</body>

</html>

thank you sitepoint enthusiast!

i appreciate your help. i copied the code, but it did the same thing. you’ll be able to see the code i am using on the response from another fine sitepoint support person. i’ll get it eventually. i saved your code in its own file for future attempts.
codibel

HI codibel,

Welcome to the Sitepoint forums!

Since you are new to PHP, I suspect that the installation could have gone wrong too. So double check if your Apache (or any web server) is running with properly installed and configured PHP.

Can you let us know what you did to install web server and how you are running your script? So that we can point you to the right direction.

Good luck!

Yes you may be right. It would be easy for us to help if codibel would post the code here.

If PHP wasnt installed, you’d see the untranslated base code.

White screen generally means you’ve got an error on your page but have error reporting turned off.

Is your php installed properly?
if it is installed properly then. Create a test.php file place it in your root folder.
then http://localhost/test.php should show the result.


<?php 
//this should work.
echo date("Y-m-d")."Hi i'm Kevin";
echo date("Y-m-d")."Hi i'm Kevin Yank";
?>

It seems that there is code error.

Put the code so that we can give you the right direction.