i have been able to get my head around html/css/javascript/xml

… but PHP just fucking owns me. I can not get my head around it. I’ve read books, gone through W3 tutorials, everything. I know the premise behind it and how it works, i just cant seem to code a working application with it.

Anyone have better learning resources?

Might help to pick up a beginners programming book. Something not php specific.

That was gonna be my suggestion.

Assuming you have no formal training, take a college course in OO programming theory, or get a book. You need to fully understand the paradigm of objects first.

Then PHP will be a breeze, just gotta learn the syntax and quirks.

This is like trying to build a turbo charger with no knowledge of how a motor works. Start at the start.

O Reilly books are some of the best. Pick up an O Reilly PHP book.

Start off with small simple projects. Simple form processing, data checking, ect. From there, move on to mysql shit. Look at tutorials/examples on line and learn as you do. That’s what i did like 7 or 8 years ago. Now it’s all just second nature.

That being said, i still need to learn JS

anyone have a book recommendation? (amazon link/etc)

Start off with small simple projects. Simple form processing, data checking, ect. From there, move on to mysql shit. Look at tutorials/examples on line and learn as you do. That’s what i did like 7 or 8 years ago. Now it’s all just second nature.

That being said, i still need to learn JS

ive actually been able to create a registration script using php + a mysql db
but anything more complicated is just beyond me. objects, classes, functions, etc. holy shit…

ive actually been able to create a registration script using php + a mysql db
but anything more complicated is just beyond me. objects, classes, functions, etc. holy shit…

For those, i had to start with stealing other people’s and editing them as necessary. Do that enough, and you’ll get the hang of it.

ive actually been able to create a registration script using php + a mysql db
but anything more complicated is just beyond me. objects, classes, functions, etc. holy shit…

This is where reading a book and learning Object Oriented program will really help. If you learn to do this right from the get go, things will be much easier later on and you’ll spend a lot less time maintaining/fixing your code.

First read this, you’re going to want to learn MySQL also.

Once you get through that the new PHP6 OO books will be coming out. Pick up one of those.

Disregard anything you read on the internet, including all of the tutorials I’m sure you’ve gone through, they’re obsolete and always reference PHP4.

.

At first, the concept of functions, objects, and classes seems a bit much. Much if you take it slowly with each one, it should prove to be quite easy.

If you don’t know how to do something, just ask me…

spam it and you will get a ban

The reason you’re probably having a problem is you’re treating PHP like a static HTML page instead of a program. Even Javascript is static in the sense that they are loaded by the client, then the client decides what to do. PHP does all of its decision-making on the server, and then gives it to the client.

PHP scripts are programs that *generate* HTML. You run them, they spit out HTML as a product. It’s like BASIC or C++. You can’t treat a PHP file the same as an HTML file. It’s a whole different point of view.

If you don’t know how to do something, just ask me…

cool

see anything wrong with this code?

<?php

if (isset($_POST['submit']));

    {    
        $age = $_POST['age'];
        if ($age < 21)
            {
                echo "Youre not 21 yet.";
            }
        if ($age >= 21)
            {
                echo "Youre over 21!";
            }
    }
        
else {
        echo "<form action="<?php echo $_POST[PHP_SELF] ?>" method="POST" /><br />";
        echo "What is your age?: <input type="text" name="age" /><br />";
        echo "<p><input type="submit" name="submit" value="submit!" /></p>";
    }
?>

error: Parse error: syntax error, unexpected T_ELSE in /home/xxxx/public_html/test.php on line 17

ive actually been able to create a registration script using php + a mysql db
but anything more complicated is just beyond me. objects, classes, functions, etc. holy shit…

This is where reading a book and learning Object Oriented program will really help. If you learn to do this right from the get go, things will be much easier later on and you’ll spend a lot less time maintaining/fixing your code.

First read this, you’re going to want to learn MySQL also.

Once you get through that the new PHP6 OO books will be coming out. Pick up one of those.

Disregard anything you read on the internet, including all of the tutorials I’m sure you’ve gone through, they’re obsolete and always reference PHP4.

.

At first, the concept of functions, objects, and classes seems a bit much. Much if you take it slowly with each one, it should prove to be quite easy.

If you don’t know how to do something, just ask me…

spam it and you will get a ban

The reason you’re probably having a problem is you’re treating PHP like a static HTML page instead of a program. Even Javascript is static in the sense that they are loaded by the client, then the client decides what to do. PHP does all of its decision-making on the server, and then gives it to the client.

PHP scripts are programs that *generate* HTML. You run them, they spit out HTML as a product. It’s like BASIC or C++. You can’t treat a PHP file the same as an HTML file. It’s a whole different point of view.

If you don’t know how to do something, just ask me…

cool

see anything wrong with this code?

<?php

if (isset($_POST['submit']));

    {    
        $age = $_POST['age'];
        if ($age < 21)
            {
                echo "Youre not 21 yet.";
            }
        if ($age >= 21)
            {
                echo "Youre over 21!";
            }
    }
        
else {
        echo "<form action="<?php echo $_POST[PHP_SELF] ?>" method="POST" /><br />";
        echo "What is your age?: <input type="text" name="age" /><br />";
        echo "<p><input type="submit" name="submit" value="submit!" /></p>";
    }
?>

error: Parse error: syntax error, unexpected T_ELSE in /home/xxxx/public_html/test.php on line 17