Announcement

Collapse
No announcement yet.

n00b is trying to make his first ever .php script...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • funmasti
    replied
    try to make more advance script

    Leave a comment:


  • .:.RG.:.
    replied
    If you know other languages, you will probably also enjoy getting PHP to run as a CLI (Command Line Interface) and making programs that output to a console and such.

    In more advanced programming, you can try making all your bash scripts in PHP :P

    Leave a comment:


  • Anseur
    replied
    Thanks again for your help. I went on to try a few other things, like pulling/pushing data from a database, and then read up on vb.org about integrating your own php into vBulliten. I might even have a go at writing a (very basic!) mod at some point. But regardless, learning the PHP is a lot of fun!

    Leave a comment:


  • Anseur
    replied
    Thanks for the pointer!

    I shal continue to play.

    Also I think using notepad2 instead of windows notepad is probably for the best.

    Leave a comment:


  • BBR-APBT
    replied
    You have a ' in that line either put a \ slash before the ' or use " for the enclosing brackets.

    Below is a working version.
    Code:
    <?php
    
    // define some stuff
    $name = 'Bob';
    $job = 'the builder';
    $canhefixit = '1';
    $question = 'Can he fix it?'; 
    
    
    // check if bob can fix it or not
    if ($canhefixit == '1')
    {
    $answer ="yes he can!";
    }
    else
    {
    $answer = "no sorry Bob can't fix this it's FUBAR";
    }
    
    echo "$name $job $question";
    echo "$name $job $answer";
    
    ?>

    Leave a comment:


  • Anseur
    replied
    so, after looking at the syntax highlighting after posting here, I realised that the punctuatioin in the else code was closing the string before I intended, so I removed it.

    next I realised (I think!) that the contents echo dosent get parsed because it's inside the ' 's so it just prints out the words as written.

    so version 2:

    PHP Code:
    <html>
    <head></head>
    <body> 

    <?php

    // define some stuff
    $name 'Bob';
    $job 'the builder';
    $canhefixit '1';
    $question 'Can he fix it?'


    // check if bob can fix it or not
    if ($canhefixit == '1')
    {
    $answer ='yes he can!';
    }
    else
    {
    $answer ='no sorry Bob cant fix this its FUBAR';
    }

    Print 
    $name $job $question;
    Print 
    $name $job $answer;

    ?>

    </body>
    </html>
    Gives me a "Parse error: parse error in C:\wamp\www\bob.php on line 24" and I'm stuck again.

    Leave a comment:


  • Anseur
    started a topic n00b is trying to make his first ever .php script...

    n00b is trying to make his first ever .php script...

    So being the sad geek I am, I decided to spend this Saturday evening making a start on learning some PHP for fun. Never written any before, only installed vb/mods and modified temples. So picked up some basic ideas of what is possible with that, but wanted to start from the begining anyway.

    So, I googled for some tutorials and found some here. I read parts one and two of that, then thought I would try something out based on some of what that has shown me so far.

    So here's what I did.

    PHP Code:
    <html>
    <head></head>
    <body> 

    <?php

    // define some stuff
    $name 'Bob';
    $job 'the builder';
    $canhefixit '1';
    $question 'Can he fix it?'


    // check if bob can fix it or not
    if ($canhefixit == '1')
    {
    $answer ='yes he can!';
    }
    else
    {
    $answer ='no sorry Bob can't fix this it's FUBAR';
    }

    echo 
    '$name $job $question';
    echo 
    '$name $job $answer';

    ?>

    </body>
    </html>
    Doesn't work of course, I get a "
    Parse error: parse error in C:\wamp\www\bob.php on line 21" from my local WAMP server when viewing it. (Which leads to related question, when apache gives a error like this, does it count blank/commented out lines? Is there anything it doesn't count?)

    Line 21 just contains the closing bracket for the else statement, so not sure what is wrong there. I guess I'm just making some kind of syntax mistake, but after re-reading the examples on the linked to page, I just can't seem to see it.

    Can anyone offer any advice?

    Thanks.
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...
X