Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

very simple question

Status
Not open for further replies.

inusrat

Programmer
Joined
Feb 28, 2004
Messages
308
Location
CA
Hi,

I am new to PHP. When a form is sumbited , how do we retrive variable in PHP on the other page..Like in ASP we do the following

birthcountry= Request.form("birthcountry")

***********

When you are coming through a link, how do we retrive the variables of the link ..like ASP we do ...


Tab = Request("tab")

Thanks



 
$yourvariable=$_GET[userentereddata];

or

$yourvariable=$_POST[userentereddata];

You should search for ASP2PHP, a freeware that can convert ASP code to PHP. While it is not perfect, it is a good way to see how your ASP knowledge translates to PHP.


- - picklefish - -
Why is everyone in this forum responding to me as picklefish?
 
Can you plz tell me what I am doing wrong here, I am trying to do construct a SQL statement with where clause.


________________
$yourvariable= "Women";

$result= mysql_query("SELECT * FROM products where gender= $yourvariable",$link)
or die("Couldn't execute query");
____________________

Thanks

 
If gender is a text field you need the contents surrounded in quotes in the query statement.

Code:
$yourvariable= "Women";

$result= mysql_query("SELECT * FROM products where gender= [COLOR=red]'[/color]$yourvariable"[COLOR=red]'[/color],$link)
  or die("Couldn't execute query");

The above should work.
 
Put the $yourvariable in to single quotes i.e.
SELECT * FROM products where gender= '$yourvariable'
 
Oops, ingresman, we posted at the same time, and mine with an error...

Code:
$result= mysql_query("SELECT * FROM products where gender= [COLOR=red]'[/color]$yourvariable[COLOR=red]'[/color]",$link)
  or die("Couldn't execute query");

Mine should be corrected now...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top