SitePoint Sponsor

User Tag List

Results 1 to 19 of 19

Thread: basic php script

  1. #1
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face 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.

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2010
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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 Code:
    <?php 
    //this should work.
    echo date("Y-m-d")."Hi i'm Kevin";
    echo 
    date("Y-m-d")."Hi i'm Kevin Yank";
    ?>
    Last edited by bishwadeepkc; Jul 29, 2010 at 20:32. Reason: missed the php tag

  3. #3
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,539
    Mentioned
    31 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2010
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by StarLion View Post
    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.
    Yes you may be right. It would be easy for us to help if codibel would post the code here.

  5. #5
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,004
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by codibel View Post
    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 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!

  6. #6
    SitePoint Zealot RishikeshJha's Avatar
    Join Date
    Mar 2009
    Location
    INDIA
    Posts
    146
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by codibel View Post
    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.

    It seems that there is code error.

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

  7. #7
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb

    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

  8. #8
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    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!

  9. #9
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

    Quote Originally Posted by rajug View Post
    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!

  10. #10
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  11. #11
    SitePoint Zealot RishikeshJha's Avatar
    Join Date
    Mar 2009
    Location
    INDIA
    Posts
    146
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by codibel View Post
    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!
    To access this page write welcome1.php?name=something

  12. #12
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,004
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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 Code:
    <?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 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!

  13. #13
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  14. #14
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face

    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

    Quote Originally Posted by bishwadeepkc View Post
    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 Code:
    <?php 
    //this should work.
    echo date("Y-m-d")."Hi i'm Kevin";
    echo 
    date("Y-m-d")."Hi i'm Kevin Yank";
    ?>

  15. #15
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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


    Quote Originally Posted by StarLion View Post
    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.

  16. #16
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,004
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by codibel View Post
    ..... 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.
    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 ?

    Quote Originally Posted by codibel View Post
    ....
    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.
    Do you mean you can access Joomla back end? What do you mean with Joomla back end....

  17. #17
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

    Quote Originally Posted by rajug View Post
    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 Code:
    <?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 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!

  18. #18
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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!

  19. #19
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •