php stupidity?

I’m a little familar with html, but I’m trying to teach myself php as well. The books and online tutorials aren’t helping when I can’t simply say a hello world…

A simple echo doesn’t work…

What is wrong with my code? It didn’t work when I was in Vista opening with firefox. Maybe it’s the firefox browser?

I tried

<?php echo “hello” // with and without a semi-colon here.]
?>

It never displayed the text in the browser.

I did

<html>
<head></head>
<body>
[php here]
</body>
</html>

and I literally tried every simple logical thing possible, yet it still didn’t want to print out “hello”


I then copied and pasted a code that was supposedly correct and showed what it should print out on the website, and I copied, pasted, and viewed in browser and it failed!..

Is it because I have to install some php thing before writing in it?

If that is so, then why do php forums on the internet work anyway?

Overall I wanna learn php, and the first steps in the books don’t work, lol.

PHP code doesn’t work if you just view the file. It has to be served from a web server.

You need to have a web server installed and the php functionality installed & enabled.

In openSUSE it is really easy. just install apache2 & php5, then fire up the server via yast run levels. Then place the files in /srv/www/htdocs

Here is a quick tutorial: Apache Quickstart HOWTO - openSUSE

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You can also execute PHP directly from the command line if you have the
CLI pieces installed in the OS and you either call the script with the PHP
executable or have the script using a ‘shebang’ line at the top like with
other scripts that points to the PHP interpreter:

#!/path/to/php5

<?php
echo ‘test’;
?>

Good luck.

antiparadigm wrote:
> You need to have a web server installed and the php functionality
> installed & enabled.
>
> In openSUSE it is really easy. just install apache2 & php5, then fire
> up the server via yast run levels. Then place the files in
> /srv/www/htdocs
>
> Here is a quick tutorial: ‘Apache Quickstart HOWTO - openSUSE’
> (http://en.opensuse.org/Apache_Quickstart_HOWTO)
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQIcBAEBAgAGBQJJyU/yAAoJEF+XTK08PnB5bj8QAMTGgeWXNDEmh1qi67nU2KRu
RyKj3kNbhigmiU0E86TF55nKPTetTzSiUJaOnYRNJdnHMqzR8zpLMfbwlWnzYLiJ
wG/ydo+l0xuJYyniyHmH731HJnlkWWWEACquclVNpo/QnfSdHk8wE2xzANpeM7YQ
fj/IUrGwUSOfTFcQWCIPNJR/zOyVA5WvEl6tByDzWi0ITuA9NkCVX21W3pV9Og3x
Z3ycuhakXWvPhWoaH2QBE6kcRcB8wajxgyuLsJTBHH1cA5q6kaqEAcs4IHYmqOQa
DwKOTdAKqZxWh2hogZcKYjFxQCsewPz328sSjDNR4aaNJYs8RvMB4YrZHwg9LGMR
SBSGV9RgQT4ldnJvexrmJdZQ4Qy17Y/EjNgCoS3mv7zou4CBqN+c3UcIDCd+K3SD
jdexlBqze1gugUnAq5Q1Q+ibzqQtgISHuEUK1tZrEpsFA4AwEPmONk2Zxf7oRo7D
ouSYu7QCzeC7K9/dEFJv5Ssx63uoSWo68aUbk9uDcYv9xZs5JOeIBNh3OAS40c9A
+aH1DAYsIFw74tWix8dr0HLUz1lyHj1QTLkuXwg/kGXe0veE1xZ1vE68uLxoUKb2
Tu6/QvHrGErCbUbGux8ID6h8dr/p6qQpx/eaFX9Ac4ct6iX5Mkq5x8+R2cbquOS2
Zm34iK9VVY+9fKZh0xu9
=9Thd
-----END PGP SIGNATURE-----

dont forget to save your files as .php instead of .html :stuck_out_tongue:

Try something like Xampp
If you’re only interested in testing things locally, it’s VERY easy to install and should at least get you a hello world :wink:

Axeia wrote:

> Try something like ’ Xampp’ (http://www.apachefriends.org/en/xampp.html)

XAMPP is NOT recommended for openSUSE as we package all required software.
Do not install or use it. People keep messing up with the distribution
packages and config.

If you want LAMP, do:

zypper in -t pattern lamp_server &&
a2enmod php5 &&
/etc/init.d/mysql start &&
/etc/init.d/apache2 start &&
chkconfig -a apache mysql

…after reading the Apache Quickstart document.

Kind regards,
Andreas Stieger

Better? And as far as I know it can’t do any permanent harm as it all stays in the xampp directory instead of the the mentioned ‘messing with the configuration’. Then again it’s been a while since I used it.

Although openSUSE does make life easy, setting up mysql and using PHPMyAdmin is still a ton easier with xampp. However I wouldn’t use it for anything but testing things locally.

This is what happens when I try to install php…

I’m still trying to figure this out.

linux-5lan:~ # rcapache2 start
Starting httpd2 (prefork) done
linux-5lan:~ # yast2 –install php5 php5-mysql apache2-mod_php5
No such client module –install
The search path follows. It does not include the current directory.
/y2update/clients
/root/.yast2/clients
/usr/share/YaST2/clients

Run ‘yast2 -h’ for help on usage
linux-5lan:~ #

I also get this.

linux-5lan:~ # yast2 -install phpMyAdmin
yast2: invalid option – ‘n’
Exit.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Try:

yast -i php5 php5-mysql apache2-mod_php5

Good luck.

Swimi wrote:
> This is what happens when I try to install php…
>
>
> I’m still trying to figure this out.
>
>
>
> linux-5lan:~ # rcapache2 start
> Starting httpd2 (prefork)
> done
> linux-5lan:~ # yast2 –install php5 php5-mysql apache2-mod_php5
> No such client module –install
> The search path follows. It does not include the current directory.
> /y2update/clients
> /root/.yast2/clients
> /usr/share/YaST2/clients
>
> Run ‘yast2 -h’ for help on usage
> linux-5lan:~ #
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQIcBAEBAgAGBQJJ1wG/AAoJEF+XTK08PnB5Ve8QAKhV8ZzPDZO/3xrlGWvOb7bH
yfzgWmuAuW/fI5+SEZdxWQ3Mw0Tb7vn5dK7Fh60ZPTdl3aCvikkBfXb1hXDaluQF
YOLF5CXDQp2oAAiAvAM0Sne5IVUQbFMMBgvS09djXOA5tWQ6EYPm2giVDbBWM3e2
dscuChm4u6xn0tV6IBsjaphvukdJVY3yjCT0Ou9u1+lZhTCfhLYKrrVnieqPPxWp
28EdzQxr6KERx9nnsXrFWnNAkWM9NIH1PzWlxH4wpY2tBYtpmQcojte8bxDZH+7u
s1VfQWYqq8bO8gE2f6lmvbtQg2lDUqU4o8leLAget6nL+4579JCzmGQ0DfppgOvS
8bW3ogtBjoc9Sf7VbxBL3Sn4Yk0+pTAJ89TvNLR5NdTXt5IP6+Fkm8xqMUb2XdO0
MgBJfyU4ocMBh9tkMVF2myqDJ0r0GaXMkjHj2zr7GRnnJeyEWAYUn8W55p8vX0zM
5EGDRF16qfcocxJgYYdNpSXR4NlAB4rTx6EIXcvZ6u9Ylhv9/CSSx69bX2TDRQQy
EIsh2GndPmJmREbQaytevJJvy/civ/sN/nRrAaLLi0adgFIFbRUEvtTHOyJEQnW+
a6/06avp6ZDnxkROuxzEAn8bL9bl0INaTBccS+SR8eXry21O1ysLcrldIxDLvVO5
z4Boj/hkzsaZ48Fpmb0A
=nYI0
-----END PGP SIGNATURE-----