New to PHP, what am I doing wrong?? pointers??

I have a url called test.php?user=me&subject=you

here's my code... i connect to the database fine, but my variables are all empty.. any pointers as to what is going wrong?

<?php

$user = $_REQUEST['user'];
$subject = $_REQUEST['subject'];

$link = mysql_connect('localhost', 'mailer', 'mailer321')
   or die('Could not connect: ' . mysql_error());

mysql_select_db('mailer') or die('Could not select database');

$query = "SELECT * FROM email where name = '$user' and subject = '$subject' order by id desc limit 1";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());

while ($rows = mysql_fetch_array($result))  {
$name = $rows[name];
$email = $rows[email];
$content = $rows[content];

print "name=$name";
print "email=$email";
print "content=$content";

}

mysql_free_result($result);

mysql_close($link);

?>
jmingoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RoonaanCommented:
Try adding error_reporting(E_ALL) to the top of your php section: eq:

<?php
 error_reporting(E_ALL);
 ..rest of code
?>

I expect an error on the $rows[name] part (should be $rows['name']), but this should not kill your script or cause empty outputs.

Try the error_reporting first

Regards

-r-
0
jmingoAuthor Commented:

this is what came up.


Warning: Undefined variable: _REQUEST in /var/www/html/php/test.php on line 18

Warning: Undefined variable: _REQUEST in /var/www/html/php/test.php on line 19

Warning: Use of undefined constant name - assumed 'name' in /var/www/html/php/test.php on line 30

Warning: Use of undefined constant subject - assumed 'subject' in /var/www/html/php/test.php on line 31

Warning: Use of undefined constant content - assumed 'content' in /var/www/html/php/test.php on line 32
name=email=content=
0
RoonaanCommented:
then you have to use either $_GET or $_POST in stead of $_REQUEST
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

jmingoAuthor Commented:
When i change it to

$user = $_GET['user'];
$subject = $_GET['subject'];

it returns

Warning: Undefined variable: _GET in /var/www/html/php/test.php on line 18

Warning: Undefined variable: _GET in /var/www/html/php/test.php on line 19

and this

$user = $_POST['user'];
$subject = $_POST['subject'];

returns

Warning: Undefined variable: _POST in /var/www/html/php/test.php on line 18

Warning: Undefined variable: _POST in /var/www/html/php/test.php on line 19
0
RoonaanCommented:
And $http_post_vars/$http_get_vars?

Try <?php phpinfo();?> and tell us which version of php you have installed, because it sounds either pretty odd, or pretty old..

Regards

-r-
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jmingoAuthor Commented:
PHP Version 4.0.4pl1

i'm using $http_get_vars now and here's what comes up...

Warning: Use of undefined constant name - assumed 'name' in /var/www/html/php/test.php on line 31

Warning: Use of undefined constant subject - assumed 'subject' in /var/www/html/php/test.php on line 32

Warning: Use of undefined constant content - assumed 'content' in /var/www/html/php/test.php on line 33
name=test@test.caemail=testcontent=here is content
0
mattjp88Commented:
change:

$name = $rows[name];
$email = $rows[email];
$content = $rows[content];

to:

$name = $rows['name'];
$email = $rows['email'];
$content = $rows['content'];
0
jmingoAuthor Commented:
there... no more errors...

what i'm trying to do is load this data into a flash file but that isn't working....
0
jmingoAuthor Commented:
if you can help me out with the flash ascept, i'll up the points some... if not, i'll just accept your answer.


thanks
0
suresh_aspCommented:
try this,

replace the below

$name = $rows['name'];
$email = $rows['email'];
$content = $rows['content'];

instead of

$name = $rows[name];
$email = $rows[email];
$content = $rows[content];

0
jmingoAuthor Commented:
here's my php code now.

<?php

error_reporting(E_ALL);

$user = $HTTP_GET_VARS['user'];
$subject = $HTTP_GET_VARS['subject'];

$link = mysql_connect('localhost', 'mailer', 'mailer321')
   or die('Could not connect: ' . mysql_error());

mysql_select_db('mailer') or die('Could not select database');

$query = "SELECT * FROM email where name = '$user' and subject = '$subject' order by id desc limit 1";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());

while ($rows = mysql_fetch_array($result))  {

$name = $rows['name'];
$email = $rows['subject'];
$content = $rows['content'];

print "name=$name";
print "email=$email";
print "content=$content";

}

mysql_free_result($result);

mysql_close($link);

?>
0
RoonaanCommented:
What is the "flash aspect"?

To my understanding, Flash can only communicate using xml. But this is a whole other issue and requires a second thread/topic.

Regards

-r-
0
jmingoAuthor Commented:
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.