Forum Moderators: coopster
I'm a pure newbie in PHP and MySQL, with very good knowledge in HTML and CSS, using Dreamweaver MX 2004 to code.
I just installed MySQL 4.1, and chose C:\MySQL Datafiles\ as the server folder (not the installation folder). And now I have a PHP testing and learning site set up in Dreamweaver with site local root folder as:
C:\PHP\
And the Testing Server details are:
The code inside a testing.php file is:
<html>
<head>
<title><?echo $title?></title>
</head><body>
<?php include "email.txt";?>
</body>
</html>
I have an email.txt file with some (hello world) in it, in both: (MySQL Datafiles) folder, and (PHP) folder.
Now when I test the testing.php file in the browser, I do not see the contents of the email.txt file in the page. :(
Why is that? It's obvious I'm doing something wrong. Maybe I have setup the server in the wrong way? Or I gave Dreamweaver the wrong paths in the Testing Server details?
Thanks a lot for anyone taking the time to help.
<html>
<head>
<title><?echo $title?></title>
</head><body>
<h1>
Hello World!
</h1>
<p>
Hello again, World!
</p></body>
</html>
Isn't any simple text in a txt file valid PHP code? Before reading your post, I simply had "hello world" inside an email.txt file. But after reading your post, I changed the file to email.php, and wrote in it the code above. It still didn't work.
I also pasted the line that you gave me inside the testing.php file, but nothing showed up at all in the browser after testing the page. :(
I think I'm doing something else that is wrong. How can I be sure that MySQL 4.1 server (essential version) is running correctly to run PHP files correctly? And how do I setup the PHP website locally using Dreamweaver? The information I posted in my last post has details about the information that Dreamweaver needs. Did I give Dreamweaver the info correctly?
so try the phpinfo as suggested
<?php
phpinfo();
?>
If you get a big blue screen with loads of info on it you are cooking.
to test for printin variables dont bother with using includes as the moment, they can cause their own problems with paths etc
Try this
<?php
$printing_var = "This mutha works";
//print the Variable to the screen
print "<h1>$printing_var</h1>";
?>
Make sure you have the server running and try and request the page, if you see big fat letters on the screen, smile :)
HTH a little
What else do I have to install exactly so that PHP is "running"? I only have graphic design, loads of WYSIWYG stuff, and I use Dreamweaver to code, plus MySQL 4.1 (essential version) installed on my PC. But that's it. Nothing specifically for PHP.
How do I start cooking, man? :)
file:///C:/PHP/ http://localhost/PHP/ You need to set up a webserver - either Apache, IIS or PWS - on your development machine. You then access the page through the web server, so that the php pages are be parsed and executed.
At the moment you're just viewing the file testing.php - I'm guessing that when you do a "View Source" in your browser, you see exactly the contents of the file, including the PHP code.
Besides, I keep hearing "PHP & MySQL" a lot. I mean both come together a lot. I thought these guys were buddies. I'm a bit lost, but I'm really eager to understand. Will you tell me why I need Apache or Microsoft's IIS and not MySQL?
Apache = Open source server tech
Typically you will find that hosts who run apache have all the open source stuff available as well. So you will find the database stuff (mysql) and the web langauge (PHP) ready to go.
If you want to emulate an apache environment on a windows machine with little effort, consider that firepages i recommend. You can do most of what you will find on a dedicated apache server (httpd edit etc) without working out how to compile it.
You can run php on an IIS server, but that is not typical and less than easy imho.
Again, I'm using Dreamweaver to write the code. And now I understand that I need a web server technology installed on my system, like IIS or Apache (although I still don't understand why MySQL does not suffice). However, what about these Windows Binaries files in php.net, now?
It is not an easy area to follow if you are not that sure. I can stress how easy a pre-compiled application liek the one i recommend. You will see how they all fit together.
No offense but you have a long road ahead if you try and intall these things manually if you are not sure how the different bits fit together.
you can learn how to do proper installs later if needs be.
But I thought that just like I don't need to install anything called "HTML" in order to write HTML, I also didn't need to install anything called "PHP" to write PHP.
You don't need anything installed called "PHP" to write PHp. You are right that PHP code can be written in Notepad or any other such utility. However, to see the PHP in action on your own machine, you need to install PHP along with Apache. Just like HTML, without a browser you would not see anything but a text file. The browser interprets the HTML and thus you see a web page.
MySQL is the database part of the equation, it does not interpret the PHP code, it simply stores values.
Hope this helps clear a few things up.
coho75, ohh yes, that did clear up important things for me. Thank you very much really! :)
I got a few questions, though, HOPEFULLY the last in this topic. You said MySQL stores values, because it's just the database part of the equation.
Now do you mean that MySQL is where I store PHP "variables", for instance?
And in an example like:
<html>
<head>
<title><?echo $title?></title>
</head>
</html>
...where exactly do I store the $title value? Given that I installed MySQL 4.1 last night, and--God willing--I'm installing phpdev423 now?
Are the PHP Windows Binaries from php.net, and phpdev423, the same, then, but phpdev423 is easier? So if I install phpdev423, then I don't need to install those Windows Binaries files from php.net?
It worked. I'm cooking! :)
I installed phpdev, and thankfully, after a few trials, figured how to put my testing/learning website on my computer, and I tested it, and it worked. It looked so beautiful coming from my PC after I could only see that stuff on my website host. :)
Thank you again, ukgimp.
Now pleease, I just want to know this one thing: how do I assign a value for a variable like $title OUTSIDE the php file itself which has this title?
I read about the 2 kinds of PHP symbol tables: global and function-local, where you store a list of variable names and their values. Now how do I code or develop a symbol table like that? I don't want a table with hundreds of fields, just 2 variables, for instance, for training and learning. And how do I make a php file get the values of the variables in it from that symbol table? Is there a way like linking? Like when an HTML file is linked to a CSS file to get its style data from it?
<?php
include('includes.php');
print "$title";
?>
the create a file in the same directory called include.php
and have the following
<?
//file variables
$title = "My site Title";
?>
Now when you view the first file it inlcuded the second which allows you to use that varaible. So if you have 1000 pages on your site you only need to change the inlcude file to change all the pages.
Is that what you were asking
[w3schools.com...]
[freewebmasterhelp.com...]
What I did NOT know, was that I have to put the:
<?php
include('varvalues.php');
?>
part BEFORE the <title><?php echo $title;?></title> part.
Having just immigrated from HTML coding, I thought that everything has to go in the <body></body>, you digging me? :)
But I figured it out. There's still hope in me, I'm not THAT dumb. Hehehe. :)
Thank you
Sorry if I sounded like I don't want to study on my own. It's just that technical authors can sometimes confuse, rather than make you feel welcome. Also, sometimes I have questions about something that is not working, and I keep looking for answers online, but can't find any. So I end up needing to ask, and repeatedly. :)