Please help me or I'll be fired for sure!!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Phoenixheart
Forum Contributor
Posts: 123
Joined: Tue Nov 16, 2004 7:46 am
Contact:

Please help me or I'll be fired for sure!!!

Post by Phoenixheart »

Gosh! I only coded ASP with MSSQL before, but now my new project is on a Linux server, so I have to switch to PHP and MySQL. MySQL is similar to MSSQL so I have no problems with it, but I'm busted with PHP. For now, I have a (I know) very simple problem that I cannot solve. You know, in ASP with VBScript we can retreive a value from the URL "http://somehost.com/somefile.asp?str_sent=blahblah" by using Request.QueryString("str_sent")
But how can I do the same in PHP? I know this is a silly post, but help me please, I'm a total newbie :oops:
jl
Forum Commoner
Posts: 53
Joined: Tue Nov 09, 2004 12:05 am

Post by jl »

User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

Code: Select all

<?php
$someString=$_REQUEST['nameOfString'];
//or $_POST['nameOfString'];
//of $_GET['nameOfString'];
?>
depending on what how your form method is used to submit the page.
$_REQUEST is neutral so easier to use but not as secure.
Phoenixheart
Forum Contributor
Posts: 123
Joined: Tue Nov 16, 2004 7:46 am
Contact:

Post by Phoenixheart »

Thank you very much.
And by the way, could you show me how to display records from a result set by and by? In ASP, we have a moveNext() function, but I couldn't find any similiar one in PHP. Do we have to use 2 nested "FOR" loop? (Using num of columns and num of rows) or there's another way?
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

PHOENIXHEART wrote:Thank you very much.
And by the way, could you show me how to display records from a result set by and by? In ASP, we have a moveNext() function, but I couldn't find any similiar one in PHP. Do we have to use 2 nested "FOR" loop? (Using num of columns and num of rows) or there's another way?
That's what the manual is there for. Read it. I suggest you start here or google for mysql tutorials. There are plenty on zend.com
Last edited by patrikG on Wed Nov 17, 2004 4:09 am, edited 2 times in total.
roobottom
Forum Newbie
Posts: 3
Joined: Wed Nov 17, 2004 3:40 am

Post by roobottom »

you can use the mysql_fetch_array function in a while loop, like this...

Code: Select all

<?php
while($result = mysql_fetch_array($yourRecordset)) {
    echo $result['column name'];
}
?>
But you really should read the manual. Or even better yet, het PHP 5 and MySQL bible, by Tim Converse and Joyce Park ISBN: 0-7645-5746-7 it'll answer all your questions...
ibizconsultants
Forum Commoner
Posts: 35
Joined: Tue Sep 07, 2004 12:07 pm

Post by ibizconsultants »

Hi PHOENIXHEART,

to get it done in PHP you should use the following syntax:

<?

$mystring = $_GET['str_sent'];

echo $mystring;

?>


To access post variables in ASP you use Request.Forms("variablename"), but in PHP you need to use $_POST['variablename'];

Let me know if you have anything else that you find difficult in PHP or MySQL.

iBizConsultants
http://www.ibizconsultants.com
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

Why did you take it/be assigned to it if you don't know anything about it? Just seems like an avoidable conundrum.
Phoenixheart
Forum Contributor
Posts: 123
Joined: Tue Nov 16, 2004 7:46 am
Contact:

Post by Phoenixheart »

<H0>Thank you all!<H0>
And to Steveo:
Why did you take it/be assigned to it if you don't know anything about it? Just seems like an avoidable conundrum.

I'm not good in English but it seems like you're advising me to resign? Nah, I don't want to do that. Though for now I'm nothing but an extreme idiot in this brand-new PHP, but I won't let it beat me. Thanks for your advice.
To everyone! I've just install PHP4 on my WinXP following all the installation guides in the PHP manual, and configured the IIS too. But (yeah the worst word on the world "but" *_*) when I browsed the simpliest "helloworld.php" from the IIS, a HTTP 400 "The page cannot be found" appeared. In the manual there's only a HTTP 500 error solving guide. Anyone have this experience like me please help me out, or give me a link to solve it. Thank you!
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

Break the problem down more and tell us what steps you have taken to solve it yourself... People on this board generally try to help in spare time and will give priority to those people who show they are prepared to put some effort into solving problems themselves.

As to your error...
Can you view any web pages on your localhost. Any HTML file (.html with no PHP code) will do
If the file gets shown correctly then create a file phpinfo.php as follows

Code: Select all

<?php
    phpinfo();
?>
and see if that loads under localhost.... If not your php/IIS configuration is wrong.
I don't know IIS (prefering Apache) so cannot help you on that, but if that displays a page then your page code is wrong and you should post the code here.
hairyjim
Forum Contributor
Posts: 219
Joined: Wed Nov 13, 2002 9:04 am
Location: Warwickshire, UK

Post by hairyjim »

The chances are that it is a permissions problem

Check you have specified iusr_*your machine name* with read & execute permissions to the php folder.
Phoenixheart
Forum Contributor
Posts: 123
Joined: Tue Nov 16, 2004 7:46 am
Contact:

Post by Phoenixheart »

Thanks everyone. Now my php can execute. But as I am a new bie, new problems keep coming for more. When i set up a mysql_connect('localhost','myusrnm','mypass') at line 11 in my php file and run it, I always got an error like this:
Connecting... // This is my echo()
Warning: mysql_connect(): Client does not support authentication protocol requested by server; consider upgrading MySQL client in F:\Saigonartframe Website\php_test.php on line 11
Could not connect: Client does not support authentication protocol requested by server; consider upgrading MySQL client
I did almost evreything possible (check mySQL connect, my database, start the service...) but no use. So please tell me what is it now?
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

PHOENIXHEART wrote:<H0>Thank you all!<H0>
And to Steveo:
Why did you take it/be assigned to it if you don't know anything about it? Just seems like an avoidable conundrum.

I'm not good in English but it seems like you're advising me to resign? Nah, I don't want to do that. Though for now I'm nothing but an extreme idiot in this brand-new PHP, but I won't let it beat me.
Not at all... I'm not telling you to resign, I'm just asking why you would take this on if you didn't know much about the language... that's all. Very brave of you :)
Post Reply