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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why does the "same" code give different results? 1

Status
Not open for further replies.

Qmoto

MIS
Oct 21, 2004
74
US
I'm trying to pass the following variables to an MS SQL 2000 server. The first example inputs the correct value [Grant], the second example inputs [NULL].

Any ideas as to why this is, or how I can fix this?

Code:
[red]Example 1:[/red]

mssql_bind($sp, "@ZZSALES",
$_POST['ZZSALES'], SQLCHAR, FALSE, FALSE, 5);

Code:
[red]Example 2:[/red]

foreach ($mpList_array as $key => $val) {
  mssql_bind($sp, "@$key",
  $_POST['$key'], SQLCHAR, FALSE, FALSE, 5);
}

Thanks for the help!

btw, I have to leave work today (Friday) by 3:30pm CST, so if I don't respond to your post today, I will respond as soon as possible on Monday.

Thanks for the help!
Steve
 
The code is not the same. At least part of your problem will be related to your incorrect use of quotes.

I your second example, you have the variable referenc:

$_POST['$key']

the index, $key, is inside single-quotes, which in accordance with the PHP online manual ( means what is inside the quotes is not interpolated. I'd bet there is no key literally named "$key" inside $_POST

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thanks for the quick reply, correct answer and enlightenment, it solved my problem - I really appreciate the help!

You'll get a star for this one :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top