Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New to the CF scene
    Join Date
    Jul 2013
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Unhappy I am very new at PHP coding and I need some help on the code below. The Code outputs

    Hi
    I am very new at PHP coding and I need some help on the code below. The Code outputs in the firefox as below

    "John","last_name"=>"Smith"); ?>


    And the code looks like this

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/tr/jtml4/loose.dtd">


    <html lang="en">
    <head>
    <title>Associative Arrays </title>
    </head>
    <body>


    <?php $assoc=array("first_name"=>"John","last_name"=>"Smith"); ?>
    <?php echo $assoc["first_name"]; ?><br />
    <?php echo $assoc["first_name"]."".$assoc["last_name"]; ?><br />



    </body>
    </html>


    It should only output name only.

  • #2
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,916
    Thanks
    15
    Thanked 227 Times in 227 Posts
    It echos out just fine for me, you must of picked up a typo somewhere. You might want to put a little space between the names in the second line.
    Welcome to http://www.myphotowizard.net

    where you can edit images, make a photo calendar, add text to images, and do much more.


    When you know what you're doing it's called Engineering, when you don't know, it's called Research and Development. And you can always charge more for Research and Development.

  • Users who have thanked DrDOS for this post:

    newonline2013 (07-18-2013)

  • #3
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    851
    Thanks
    172
    Thanked 93 Times in 93 Posts
    Hi

    Your code works ok.

    PHP Code:
    <?php 
    $assoc 
    = array("first_name"=>"John","last_name"=>"Smith"); 
    ?>
    <?php 
    echo $assoc["first_name"]; ?>
    <br />
    <?php echo $assoc["first_name"]." ".$assoc["last_name"]; ?>
    Make sure you have saved your page with a .php extension

    and make sure your page is going through a server.

    If you are testing on your local pc and using windows, you should have something like xampp installed or similar to suit your pc environment.


    Note: you will see this if you are opening the page with a normal .html extension which I think is what you may have done.

    Code:
    "John","last_name"=>"Smith"); ?>
    LT
    Last edited by low tech; 07-18-2013 at 06:16 AM.
    "The greatest revenge is to accomplish what others say you cannot do."
    ~ Unknown

    I used to be indecisive, but now I'm not so sure.

  • Users who have thanked low tech for this post:

    newonline2013 (07-18-2013)

  • #4
    New to the CF scene
    Join Date
    Jul 2013
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    PHP Coding

    Hi

    thanks guys for your promp reply..

    I am using Wampserver and it is online and connected. (Icon is green and I think it means its ok)

    IS XAPMM the same programm type as Wampserver?
    or do i need to install XAPMM as well??

  • #5
    New to the CF scene
    Join Date
    Jul 2013
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Hi

    thanks for your promp reply..

    No Actually I am tying .php extension. Also I am writing the code using Note++ which it lets me run in firefox automatilcly.

    I am Also using Wampserver and it is online and connected. (Icon is green and I think it means its ok)

    IS XAPMM the same programm type as Wampserver?
    or do i need to install XAPMM as well??

  • #6
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    851
    Thanks
    172
    Thanked 93 Times in 93 Posts
    Hi

    You have one, that's ok.


    I think this is your problem.
    Also I am writing the code using Note++ which it lets me run in firefox automatilcly.

    From their site:

    Using wampserver
    The “www” directory will be automatically created (usually c:\wamp\www)
    Create a subdirectory in “www” and put your PHP files inside.
    Click on the “localhost” link in the WampSever menu or open your internet browser and go to the URL : http://localhost

    LT
    Last edited by low tech; 07-18-2013 at 10:17 AM.
    "The greatest revenge is to accomplish what others say you cannot do."
    ~ Unknown

    I used to be indecisive, but now I'm not so sure.

  • Users who have thanked low tech for this post:

    newonline2013 (07-18-2013)

  • #7
    New to the CF scene
    Join Date
    Jul 2013
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts
    using Note++ which it lets me run in firefox automatilcly.

  • #8
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    851
    Thanks
    172
    Thanked 93 Times in 93 Posts
    hi

    Using your browser see step 3 in post 6 might be something like

    http://localhost/aFolderName/yourFile.php

    LT
    "The greatest revenge is to accomplish what others say you cannot do."
    ~ Unknown

    I used to be indecisive, but now I'm not so sure.

  • #9
    New to the CF scene
    Join Date
    Jul 2013
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Smile

    Gr8. It works fine ( I new it was me)

    Thanaks guys

  • #10
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    851
    Thanks
    172
    Thanked 93 Times in 93 Posts
    Hi

    Well done

    Enjoy
    "The greatest revenge is to accomplish what others say you cannot do."
    ~ Unknown

    I used to be indecisive, but now I'm not so sure.


  •  

    Tags for this Thread

    Posting Permissions

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