Page 1 of 2
A variety of php related questions
Posted: Thu Nov 06, 2003 9:18 pm
by simflex
Hello experts,
I am a new comer to this site.
I an ecommerce programmer having programmed alot with asp.
I am trying to switch to php (not by choice, although it will be beneficial in the end) for the first time.
I have a variety of questions, please be patient and help as much as possible.
I have installed and configured an apache server to be used with the php that I have installed.
First question is, where in apache do I put my php/html files?
So far, I have been putting them in the DocumentRoot of apache server like this:
D:\Program Files\apache group\apache2\htdocs\php/html files.
Is this correct?
Second, what editor do you use to program your php?
Does this editor need configuration?
A friend recommended phpEdit.
So far, it has not worked for me.
When I click on run(f9), nothing happens.
Third, We currently have sql server /access database.
What is the most standard php connection syntax for connecting?
I have played around with several connection strings and syntaces but nothing seems to work.
I do believe that at this point, the 2 most important/urgent help I need are ensuring that php files, html files, and other related files are stored in the correct directory.
With asp, you store the asp files in the root directory of iis.
I need to understand where to store php files in apache.
The other critical need I have is to ensure I use the right editor.
Again with asp, I used textpad.
When I click on run, if error exists, I am told of the error and the line.
I need an editor similar to that, in case anyone has used it.
I need all the help I can get from you to get started, please.[/i]
Posted: Thu Nov 06, 2003 10:10 pm
by infolock
First question is, where in apache do I put my php/html files?
So far, I have been putting them in the DocumentRoot of apache server like this:
D:\Program Files\apache group\apache2\htdocs\php/html files.
Is this correct?
no. your DocumentRoot should be D:/Program Files/Apache Group/Apache2/htdocs
in the apache configuration file (which is what i assume you are refering to )
Second, what editor do you use to program your php?
Does this editor need configuration?
A friend recommended phpEdit.
So far, it has not worked for me.
When I click on run(f9), nothing happens.
i've had the same problems with phpedit. i don't think you need to use it until you are familiar with php... use notepad, i do
Third, We currently have sql server /access database.
What is the most standard php connection syntax for connecting?
I have played around with several connection strings and syntaces but nothing seems to work.
I do believe that at this point, the 2 most important/urgent help I need are ensuring that php files, html files, and other related files are stored in the correct directory.
With asp, you store the asp files in the root directory of iis.
I need to understand where to store php files in apache.
The other critical need I have is to ensure I use the right editor.
Again with asp, I used textpad.
When I click on run, if error exists, I am told of the error and the line.
I need an editor similar to that, in case anyone has used it.
I need all the help I can get from you to get started, please.
dunno about sql, but you can go to this link :
http://www.php.net/function.mssql-connect
and it should help you out.
when you store your php files, store them in your HTDOCS directory, creating new directories as needed..
if you need anymore help, just ask.
ps:
there are 4 ways to learn php, and learn it correctly :
#1 ( and most important ), get a book. I have PHP and MySQL Web Development by Luke Welling and Laura Thomson. it's one of the best books i've ever read as far as teaching a new language ( i came from Delphi to PhP).
#2 Look at other peoples code both on these forums, on Evil Walrus (
http://www.evilwalrus.com), and on php.net function library.
#3 Get an idea, and try to impliment it into code. when you get stuck, ask a question and normally someone can help you out. Me personally, i learn more by answering questions then i do coding, as i'm sure others do as well ( and thus why the quick responses ). i'm not saying everyone does, but there are a few of us that do
anyways, that's it. hope that helps.
cheers
Posted: Thu Nov 06, 2003 10:49 pm
by simflex
Thanks infolock for your response.
It is much appreciated.
You have clarified a couple of things.
1, I now know for sure that I was putting my php/html files in the right directory.
What I meant with this line:
D:\Program Files\apache group\apache2\htdocs\php/html files
is that this:
\php/html files meaning php and html files will be in htdocs directory (conf file).
I now also know that you can test your php by going to your browser and typing something like
http://localhost:8000/directory/phpfilename.
That is what I have been doing so far.
This was exactly the way I started testing asp until I discovered textpad editing tool.
I am sure there are editors out there like textpad that will prevent you from having to go the browser all the time to test.
It's a matter of time, I will discover it.
Again thanks and I will read up on the link you provided.[/b]
Posted: Thu Nov 06, 2003 11:51 pm
by infolock
well, if you view this topic :
viewtopic.php?t=6288
they will pretty much tell you what editors most of the people here use. just go to google, search for them, and download em. most of the people left comments about the ones they use, why they like it, or what is bad about it. hope that helps.
Posted: Fri Nov 07, 2003 10:59 am
by simflex
Infolock, again I thank you very much.
I am glad that some folks use the editors I have used and continue to use to do a variety of developments such as dreamweaver and textpad.
I just will like to find out from anyone of them, especially those who use TextPad, how they run their php codes.
For instance, when you write a code that inserts records into the database, let's call this insert.php.
You then write an input screen called insert.html with action="insert.php", how do you make sure that this works?
I mean, how do you ensure connection is fine, records are or are not inserting?
Sorry for all these cheap silly questions but even if I go to the browser and run the code from there, it does not insert records into the database and does not raise an exception.
Please help me get beyond this stage and I promise you, I will figure out most of my problems
Posted: Fri Nov 07, 2003 6:13 pm
by infolock
best way to see if it works is try to print something on the new page after clicking on the link. if something doesn't work, it will give you an error with error #. then, you just have to go to your code, find that line #, and trouble shoot. if this isn't what you mean, please try giving a few more details, otherwise, hope that helps.
cheers
Posted: Fri Nov 07, 2003 6:32 pm
by d3ad1ysp0rk
infolock wrote:
use notepad, i do
how can you?!
do you program perfectly or something? without any errors?
"Parse error on line 357" how the heck do you fix that without line numbering??
and PHP highlighting in editors is nice too
i used notepad when i was learning php, but once i started developing i switched to WinSyntax.
Posted: Fri Nov 07, 2003 7:48 pm
by simflex
infolock,
What I meant was I am missing something about php.
In other words, there is got to be some php configuration that needs to be done before my code is recognized as php.
So far, I am NOT getting any errors letting me know that something is right or wrong and nothing is getting written to or pulled from the database.
For instance, today when I go to the browser to test a php code I had written, the code is treated as though it was a download.
PHP, I think needs to be set up in a way that your editor or browser recognizes it as a php code rather than just a text.
This php thing is driving me crazy.
Everyone keeps saying that if you can program asp, you can easily program php but what they don't tell you is setting php up is a nightmare, at least to me so far.
Once I get to the point where I can test a php code and get some kind of a feedback, be it an error or a message saying something is done successfully or not, then I know I have arrived.
Posted: Fri Nov 07, 2003 9:27 pm
by McGruff
The obvious first step is to chek if the scripts are wrapped up in php tags
I assume this a local test server? If you install something like
http://www.easyphp.org/ all the configuration is taken care of - maybe adjust the php.ini though to suit your preferences (eg E_ALL error reporting).
Others at
http://www.hotscripts.com/PHP/Software_ ... tion_Kits/
Posted: Sat Nov 08, 2003 10:39 am
by simflex
Here is an example of what I am talking about.
I called this sample code test.php.
I just put this together just to see if my connection to the database is working.
I deliberately entered the wrong database.
The real database name is northwind.
I didn't get an error, nothing.
Again, I feel there is some php configuration that needs to bedone but I don't know what it is or how to config.
<?php
$myServer = "localhost";
$myUser = "simflex";
$myPass = "sim";
$myDB = "Nond";
$s = @mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
$d = @mssql_select_db($myDB, $s)
or die("Couldn't open database $myDB");
?>
Posted: Sat Nov 08, 2003 3:08 pm
by twigletmac
Find your php.ini file and change display_errors to on if it's off.
Mac
Posted: Sat Nov 08, 2003 3:30 pm
by simflex
First I want to thank everyone who has tried to help>
If I don't get it to work, it is not because you guys haven't tried.
That said, I checked my php.ini file and display_errors is set to on.
That leads me to some additional questions.
1, am I using the right php file?
I downloaded and installed php-4.3.4-win32.
I am also using apache2.
Should I use apache 1.3.9?
This is puzzzling.
I never thought installing and using a product could be this grueling?
Posted: Sat Nov 08, 2003 5:36 pm
by SBukoski
I think what he is trying to say is that his PHP script is not being recgonized as a Server Side script and is not executing. It is either just displaying the code in the browser or asking him to download the PHP file. Is that a correct assumption?
Now, if it is, I wish I could help, but unfortunately I downloaded one of the bundles (forget which one). It installed Apache, MySQL and PHP onto my Windows 2000 machine. Setup the Services and everything. All I had to do was type in the right URL in the browser and everything worked like a charm.
Posted: Sat Nov 08, 2003 9:35 pm
by simflex
Yes, you are correct with your assumption SBukoski.
It would have been easier for me to download one of those bundles you talked about but unfortunately, we are asked to use our existing database which is sql server.
However, I think I have had php configured, tested it with phpinfo and it works real well now.
My next problem right now is configuring php to recognize sqlserver database, and I am going to spend a sizable amount of time tonight researching it.
I found a good article on how to configure php for sql server database but it is very confusing.
If anyone of you has a link or info on how to make php talk to sql server db, please advise.
thanks again for all the help.
Posted: Sat Nov 08, 2003 9:45 pm
by SBukoski
I always find the best place for help on anything is the PHP manual itself. 9 times out of 10 it points me in the right direction or solves it immediately. So, in case you haven't seen it yet, here's a link to the MSSQL Server functions used in PHP:
http://us3.php.net/mssql