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
Please help me or I'll be fired for sure!!!
Moderator: General Moderators
-
Phoenixheart
- Forum Contributor
- Posts: 123
- Joined: Tue Nov 16, 2004 7:46 am
- Contact:
Please help me or I'll be fired for sure!!!
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
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
Code: Select all
<?php
$someString=$_REQUEST['nameOfString'];
//or $_POST['nameOfString'];
//of $_GET['nameOfString'];
?>$_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:
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.comPHOENIXHEART 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?
Last edited by patrikG on Wed Nov 17, 2004 4:09 am, edited 2 times in total.
you can use the mysql_fetch_array function in a while loop, like this...
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...
Code: Select all
<?php
while($result = mysql_fetch_array($yourRecordset)) {
echo $result['column name'];
}
?>-
ibizconsultants
- Forum Commoner
- Posts: 35
- Joined: Tue Sep 07, 2004 12:07 pm
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
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
-
Phoenixheart
- Forum Contributor
- Posts: 123
- Joined: Tue Nov 16, 2004 7:46 am
- Contact:
<H0>Thank you all!<H0>
And to Steveo:
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!
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!
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
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
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.
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();
?>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.
-
Phoenixheart
- Forum Contributor
- Posts: 123
- Joined: Tue Nov 16, 2004 7:46 am
- Contact:
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:
I did almost evreything possible (check mySQL connect, my database, start the service...) but no use. So please tell me what is it now?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
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 youPHOENIXHEART 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.