Re: [PHP-DB] Problem with passing variables

2004-01-27 Thread Viorel Dragomir

- Original Message - 
From: Phil Matt [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, January 27, 2004 17:08
Subject: [PHP-DB] Problem with passing variables


 Hello to all.

 I am a relative newcomer to PHP. I am trying to pass the value of a
variable from a
 MySQL database from one PHP page to another PHP page. On the first page,
I've made
 the connection to the database, and the query works just fine, displaying
the correct
 values from the $myrow fields.

 This is the code to that point:

 ?
 $db = mysql_connect(ip address here,user here,password here) or die
(Unable to
 connect to SQL server);
 mysql_select_db(databasename,$db);
 ;
 $result= mysql_query(SELECT * FROM databasename WHERE ID20,$db);
 echo'table

thtrtdName/tdtdTitle/tdtdPhone/tdtdE-mail/td/tr/th';
 while ($myrow = mysql_fetch_row($result)){
 echo'tr
 td'. $myrow[0].'/td
 td'. $myrow[1].'/td
 td'. $myrow[2].'/td

 This works just fine. Then I try to pass the variable $myrow[0] to a
second page, where
 the value of the variable (a string that contains a name) is supposed to
appear. Here's
 the line of code:


*Maybe this will help. I'll presume the next statement is not included in a
print command
 tda href=email.php?recip=$myrow[0]img src=graphics/mail.gif
class=imglink

use ?recip=?=$myrow[0]?.


 alt=Click to send mail to this person //a/td/tr';


 The page receiving this variable, email.php, uses this to retrieve the
value of $myrow[0]:

 Send e-mail to ?php $recip=$_GET['recip']; echo $recip; ?


 However, all this manages to do is to print out this:

 Send e-mail to $myrow[0]

 Instead of the VALUE contained in the variable!

 What am I doing wrong?

 TIA --- Phil Matt






 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Problem with passing variables

2004-01-27 Thread Ricardo Lopes
If you have something like this:

echo 'tda href=email.php?recip=$myrow[0]img src=graphics/mail.gif
class=imglink alt=Click to send mail to this person //a/td/tr';

It wont work. Use instead:

echo 'tda href=email.php?recip='.$myrow[0].'img
src=graphics/mail.gif class=imglink alt=Click to send mail to this
person //a/td/tr';

Notice the '. before the $myrow[0] and the .' after, any doubt see the
documentation about operators.

This is caused because the ' doesnt parse variables to values like the 
does.

- Original Message -
From: Phil Matt [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, January 27, 2004 3:08 PM
Subject: [PHP-DB] Problem with passing variables


 Hello to all.

 I am a relative newcomer to PHP. I am trying to pass the value of a
variable from a
 MySQL database from one PHP page to another PHP page. On the first page,
I've made
 the connection to the database, and the query works just fine, displaying
the correct
 values from the $myrow fields.

 This is the code to that point:

 ?
 $db = mysql_connect(ip address here,user here,password here) or die
(Unable to
 connect to SQL server);
 mysql_select_db(databasename,$db);
 ;
 $result= mysql_query(SELECT * FROM databasename WHERE ID20,$db);
 echo'table

thtrtdName/tdtdTitle/tdtdPhone/tdtdE-mail/td/tr/th';
 while ($myrow = mysql_fetch_row($result)){
 echo'tr
 td'. $myrow[0].'/td
 td'. $myrow[1].'/td
 td'. $myrow[2].'/td

 This works just fine. Then I try to pass the variable $myrow[0] to a
second page, where
 the value of the variable (a string that contains a name) is supposed to
appear. Here's
 the line of code:

 tda href=email.php?recip=$myrow[0]img src=graphics/mail.gif
class=imglink
 alt=Click to send mail to this person //a/td/tr';


 The page receiving this variable, email.php, uses this to retrieve the
value of $myrow[0]:

 Send e-mail to ?php $recip=$_GET['recip']; echo $recip; ?


 However, all this manages to do is to print out this:

 Send e-mail to $myrow[0]

 Instead of the VALUE contained in the variable!

 What am I doing wrong?

 TIA --- Phil Matt






 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Problem with passing variables

2004-01-27 Thread Phil Matt
On 27 Jan 2004 at 15:56, Ricardo Lopes wrote:

 If you have something like this:
 
 echo 'tda href=email.php?recip=$myrow[0]img src=graphics/mail.gif
 class=imglink alt=Click to send mail to this person //a/td/tr';
 
 It wont work. Use instead:
 
 echo 'tda href=email.php?recip='.$myrow[0].'img
 src=graphics/mail.gif class=imglink alt=Click to send mail to this
 person //a/td/tr';
 
 Notice the '. before the $myrow[0] and the .' after, any doubt see the
 documentation about operators.
 
 This is caused because the ' doesnt parse variables to values like the 
 does.
 

Ricardo - That's it!  I did read a lot of PHP docs and mailing list posts before I 
posted my 
question to this list, but never stumbled (and that's the word, I'm afraid!) on the 
syntax 
explanation that would untangle this for me.

If I want to pass additional variables for processing on the second page, I'm assuming 
that the syntax would be (where $foo is another variable)

a href=email.php?foo='.$myrow[3].'?recip='.$myrow[0].' 

Thanks again for restoring my sanity!

Cheers --- Phil Matt



Re: [PHP-DB] Problem with passing variables

2004-01-27 Thread Ricardo Lopes
Yes, the sintax is correct (if you are inside an echo or inside a print
opened with ' and not with ). ex:

echo 'a href=email.php?foo='.$myrow[3].'?recip='.$myrow[0].' ';--
correct
echo a href=email.php?foo='.$myrow[3].'?recip='.$myrow[0].' ;   ---
error !!! (parse error)

I know that you must be using the first one, but just in case ...

You can also do something different, put your html code as html not as php
code as you are doing.
This will save time, because you dont need to scape the slashes '  , your
code will have less errors and it will run faster because the server doesnt
have to call the print or echo method from php. Example:

instead of:
?
echo 'tda href=email.php?recip=$myrow[0]img src=graphics/mail.gif
 class=imglink alt=Click to send mail to this person //a/td/tr';
?

use:
tda href=email.php?recip=? echo $myrow[0]; ?img
src=graphics/mail.gif
 class=imglink alt=Click to send mail to this person //a/td/tr

there is a shorter way to print but i dont remeber the sintax, if you want
to know consult the php manual.
it is something like ?=$var? i guess

This way the php sintax is reduced to its minimun.

- Original Message -
From: Phil Matt
To: Ricardo Lopes ; [EMAIL PROTECTED]
Sent: Tuesday, January 27, 2004 4:27 PM
Subject: Re: [PHP-DB] Problem with passing variables


On 27 Jan 2004 at 15:56, Ricardo Lopes wrote:


 If you have something like this:

 echo 'tda href=email.php?recip=$myrow[0]img src=graphics/mail.gif
 class=imglink alt=Click to send mail to this person //a/td/tr';

 It wont work. Use instead:

 echo 'tda href=email.php?recip='.$myrow[0].'img
 src=graphics/mail.gif class=imglink alt=Click to send mail to this
 person //a/td/tr';

 Notice the '. before the $myrow[0] and the .' after, any doubt see the
 documentation about operators.

 This is caused because the ' doesnt parse variables to values like the 
 does.



Ricardo - That's it!  I did read a lot of PHP docs and mailing list posts
before I posted my question to this list, but never stumbled (and that's the
word, I'm afraid!) on the syntax explanation that would untangle this for
me.


If I want to pass additional variables for processing on the second page,
I'm assuming that the syntax would be (where $foo is another variable)


a href=email.php?foo='.$myrow[3].'?recip='.$myrow[0].' 


Thanks again for restoring my sanity!


Cheers --- Phil Matt

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Problem with passing variables in PHP

2003-03-14 Thread Hutchins, Richard
On update.php, you need to refer to the varibles passed from the first page
like so: $_POST[varname]. I think that'll fix your problem.

 -Original Message-
 From: Mazin Albahkali [mailto:[EMAIL PROTECTED]
 Sent: Friday, March 14, 2003 11:08 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Problem with passing variables in PHP
 
 
 I'm a beginner in PHP and Database connections
 
 I'm accessing a MS Access database using PHP. Everything is 
 working fine. I
 get the data through an ODBC query and show it on an HTML 
 format form so
 that I can modify the data and re-post it. I tried to pass 
 the values to a
 second php file that has the updating query but no luck. My PHP didn't
 accept passing variables at all. I'm using PHP 4.3.1 on IIS 
 5.1 server, I
 even tried Apatche2 with no luck.
 
 Is there a way to run an update query using data from a form 
 in the same
 page without the need for passing it to another page?, and 
 what is wrong
 with my server not allowing me to pass variables, is there a 
 parameter in
 the server I should set on?
 
 
 Here is a test example for passing a variable that failed:
 
 
 File 1: Test Passing a variable
 
 ?PHP
 
 echo html\n;
 echo body\n;
 
 echo form name=\Update\ method=\post\ ACTION=\update.php\\n;
 
 echo p align=\right\INPUT type=\text\ NAME=\sname\
 VALUE=\$sname\ SIZE=30/td\n;
 
 echo PINPUT TYPE=\submit\ NAME=\submit\ 
 VALUE=\Send\/p\n;
 
 echo /FORM\n;
 
 echo /body\n;
 echo /html\n;
 
 ?
 
 
 
 File 2: update.php
 
 ?php
 
 echo html\n;
 echo body\n;
 
 
 if (isset($sname)) {
 
   print($sname);
 
 
   } else {
 
   print (No data yet\n);
 
   }
 
 echo /body\n;
 echo /html\n;
 
 ?
 
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Problem with passing variables in PHP

2003-03-14 Thread SELPH,JASON (HP-Richardson,ex1)
I am sure someone else will beat me to this but here is an example

update.php
---
?php

echo html\n;
echo body\n;
//add this to assign POST to a variable you can use on this page
$sname=$_POST[sname]
//that will give you an idea of what to do
if (isset($sname)) {
print($sname);
} else {
print (No data yet\n);
}

echo /body\n;
echo /html\n;
?

-Original Message-
From: Mazin Albahkali [mailto:[EMAIL PROTECTED] 
Sent: Friday, March 14, 2003 10:08 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Problem with passing variables in PHP


I'm a beginner in PHP and Database connections

I'm accessing a MS Access database using PHP. Everything is working fine. I
get the data through an ODBC query and show it on an HTML format form so
that I can modify the data and re-post it. I tried to pass the values to a
second php file that has the updating query but no luck. My PHP didn't
accept passing variables at all. I'm using PHP 4.3.1 on IIS 5.1 server, I
even tried Apatche2 with no luck.

Is there a way to run an update query using data from a form in the same
page without the need for passing it to another page?, and what is wrong
with my server not allowing me to pass variables, is there a parameter in
the server I should set on?


Here is a test example for passing a variable that failed:


File 1: Test Passing a variable

?PHP

echo html\n;
echo body\n;

echo form name=\Update\ method=\post\ ACTION=\update.php\\n;

echo p align=\right\INPUT type=\text\ NAME=\sname\
VALUE=\$sname\ SIZE=30/td\n;

echo PINPUT TYPE=\submit\ NAME=\submit\ VALUE=\Send\/p\n;

echo /FORM\n;

echo /body\n;
echo /html\n;

?



File 2: update.php

?php

echo html\n;
echo body\n;


if (isset($sname)) {

print($sname);


} else {

print (No data yet\n);

}

echo /body\n;
echo /html\n;

?



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php