PHP problem... Hello world! Hello?

Started by InCreator, Wed 03/01/2007 06:10:23

Previous topic - Next topic

InCreator

I got my hands on a book on PHP for beginners and full with enthusiasm, I started to learn this thing. Again.
But I have a tiny problem:

<HTML>
<?php
  echo "Hello world!";
?>
</HTML>

Results in... nothing. Why?

Firefox browser shows a blank screen. IE 7... same thing! Tried to save as .php and as .html
None works.
I feel extremely stupid.

What am I doing wrong?

Gregjazz

#1
Save it as a .php, and try going:

<HTML>
<BODY>
<?php
  echo "Hello world!";
?>
</BODY>
</HTML>

See if that works..

EDIT: Works on my server: http://www.gregjazz.com/test.php

InCreator

#2
It works on your server (i see the text), but not on my hard disk  :'(
Though I have PHP 5.20 correctly installed.


I just don't get it.
But wait, it also works on my own server...

So, I can't test any of my php-doings without actually uploading them?

hedgefield

#3
That is correct. PHP is mainly server-side, though it could be used from a command line interface, but that's not really practical.

voh

That's not correct, largo. You can test your php locally if you set up a HTTP server on your own system. I use OmniSecure because it's light-weight and it's hella easy to set up. Since it's not a live server, I really don't need Apache and I just want to switch settings easily for testing purposes.

Omni comes with its own PHP, but you can set it to your own PHP install by going to admin > properties > web server global settings > external

There should be an entry for PHP there. It'll point to its own when you select it. Change the path to your own PHP-CGI.exe executable (which should be in the directory you installed PHP 5 in) and click Replace. OK. Then you've got a webserver with PHP 5 :)
Still here.

nihilyst

I'm using XAMPP. It's easy to set up and works fine for me.

Ishmael

The thing with PHP is that files loaded into the browser through the absolute hard drive path don't work even if you have PHP installed and running, you need to access those files through a server which parses them first for you. XAMPP is what I use for a local server. It comes with Apache, mySQL, and all the other treats, and nowadays has a very easy admin program too. So if you're doing web dev other than PHP also it'd in my opinion be a good choise.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

InCreator


monkey0506

voh I tried pointing OmniSecure (OmniHTTPd) to my custom PHP directory and it didn't work. Installing my own version of PHP (i.e. the latest version of PHP instead of the version that comes with OmniSecure) to OmniSecure's PHP directory solved that problem.

Also Largo, PHP isn't just a server-side web-programming language. PHP can also be used to compile stand-alone programs. And it is practical, it's just not a very common implementation of PHP.

Oneway

Quote from: monkey_05_06 on Thu 04/01/2007 03:37:11...
PHP can also be used to compile stand-alone programs.

PHP as a compiler? Could you link me up with some more info?
Almost intentionally left blank.

scotch

PHP alone can't compile to anything but PHP bytecode, but there are programs around that will bind an interpreter (usually in a dll) and the source into a standalone executable, as with most script languages. For php there are a few, such as PriadoBlender or Embeder.

That said, PHP really was designed as a server side hypertext processor, it's part of the name. I wouldn't recommend it for anything except that purpose (actually I wouldn't recommend it for that purpose, but it's the one thing it isn't totally awful at...)

For web programming testing I run apache and mysql on my PC, it's really easy to set up on windows and it's what we have on the server so I have similar config file settings and so on.

InCreator

#11
I have another question, but I don't want to make another thread.

Question is - is there any alternatives to MySQL? Like with graphical UI, past 80's, click-this-button-to-create-the-damn-table-like, yet totally compatible with PHP/browser ones? Or something that makes MySQL understandable/configurable to standard human being? Like graphical add-on maybe?

MySQL makes my head hurt. And makes me think of angry ubernerds who doesn't want anyone to know how to make a single database so making unbelievably unlearnable system.

What happened? I tried to create a nice little table. By some tutorial. Yet, I get "database not found" error. And I have no clue what's going on.


Peder 🚀


InCreator

#14
With XAMPP, PHP 5.20, PHPMyAdmin and MySQL installed, confed through everything configurable and not-so-configurable, making my machine a server, having hard hassle with DI-604 router and its superidiotic "configuration utility" to open up some ports in firewall for local server, trying everything on everything.......


....i'm totally lost.

I simply can't understand why can't I create a simple table, with 4 variables in it?

Why do I have to make a server out of my machine? With 3 different programs at once? To create a table?
Even though I thought I had everything installed well, with localhost well setup and everything, PHPMyAdmin (via XAMPP) never started to work, giving some stupid Mysql driver error, I never got simple phpinfo() function to show correct stuff...
So I guess PHP installation failed at some point. Maybe because I have no clue in what order to install all this crap.

I found seemingly wonderful program from MySQL page, a full graphical table creator! With buttons and everything. But problem is, the best it does is a sql file. Which - I guess - I still have to compile through command-line-hell-generator.

Even worse - I know that my webhost supports MySQL and I can create databases manually on their self-help web section, I will never figure out how to get homemade table (if I ever manage to create it, ahem) into server and working there too, once I get far enough to actually upload my creations.

I wish there was a web page explaining everything and what those are needed for - simply and understandably. Like what this does and what for, and what another-- in English, not tech language.

I uninstalled everything and give it another try. Maybe I pick correct order this time. But still--

Lost, lost, lost.

EDIT: God bless WAMP! OmniSecure created error after error, and XAMPP didn't let me even modify docroot/remove stupid homepage from it nor really uninstall despite nice uninstalling progress bar thingies. But WAMP works like magic and I even got to make my first long-waited table! Still no idea how it works or where does it physically exist, though.

What's most important - this the first server thingy that lets me see correct phpinfo()
That's a big thing.

"WAMP5 has detected Firefox browser on your computer. Would you like to use it with WAMP5?"
So beautiful  :'(

EDIT_2: And my webhost has PHPMyAdmin built-in! How wonderfully could things turn out? Also, I finally realised, that I don't need any command-line compiling at all, doing every mysql-related stuff directly from PHP.
Sorry for long and n00bish posts.

Ishmael

Getting XAMPP to work is really not much to do. If you're happy with the docroot location it gives you (xampp/apache/htdocs or something, I don't remember) you're set, just put your php pages there. And to change the docroot you need to change two paths in the httpd.conf file under apache/conf. I don't run apache nor mysql as services, nor do I use any other utilities than the XAMPP toolbox thing with four start/stop buttons and four admin buttons. Works like a charm. Oh well...

And I don't think you need to open any ports either. Doesn't 127.0.0.1 loop back to the calling machine without even sending the signal anywhere outside?
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Peder 🚀

Quote from: InCreator on Mon 08/01/2007 01:14:30
EDIT: God bless WAMP! OmniSecure created error after error, and XAMPP didn't let me even modify docroot/remove stupid homepage from it nor really uninstall despite nice uninstalling progress bar thingies. But WAMP works like magic and I even got to make my first long-waited table! Still no idea how it works or where does it physically exist, though.

What's most important - this the first server thingy that lets me see correct phpinfo()
That's a big thing.

"WAMP5 has detected Firefox browser on your computer. Would you like to use it with WAMP5?"
So beautifulÃ,  :'(

I personally like WAMP best :). And its the one I have had less problems with.
Good thing it worked!

Peder.

Chicky

Bit OT but what program can i use to test my ASP pages on localhost?

scotch

IIS, assuming you are running one of the supported operating systems (2000, XP Pro, 2003, Vista...).

SMF spam blocked by CleanTalk