English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

$check_badge = mysql_query("SELECT badge_number FROM users WHERE user_id = '$user_id' LIMIT 1") or die(mysql_error());

while($cb = mysql_fetch_array($check_badge));
{
badge_check = $cb['badge_number'];

}

2007-08-18 05:23:59 · 7 answers · asked by jeff lemon 1 in Computers & Internet Programming & Design

yahoo cut off the middle bit;

while($cb = mysql_fetch_array($check_badge));

2007-08-18 05:24:51 · update #1

ill try again

while($cb = mysql_fetch_array
($check_badge));

2007-08-18 05:25:10 · update #2

7 answers

I dont even understand the query, never mind whats wrong with it

2007-08-18 05:28:37 · answer #1 · answered by Anonymous · 1 1

You never learnt, do you?
1. Your WHERE clause is incorrect:
user_id='$user_id' is wrong syntax.
2. You set your query with LIMIT 1 -> you get ONE record.
So, why do you do a "while"?
3. PhP requires "$" in front of variables.
4. The index in = $cb[' ']; may be ok, if there is no typing mistake, but it is better to use the value of the index (i.e. $cb[0], or the relative index).
So, and for the last time:

$query = "SELECT * FROM users WHERE `user_id`
= ' " . $user_id . " ' LIMIT 1";
// pay attention to the correct syntax: `user_id` (back accent)
// and ' " . $user_id . " ' (spaces added for clarity)
$check_badge = mysql_query ($query) or die (mysql_error() );
$cb = mysql_fetch_array ($check_badge);
$badge_check = $cb[0]; // if badge_number is index 0.

2007-08-19 06:42:21 · answer #2 · answered by just "JR" 7 · 0 0

It looks fine to me except for badge_check needing a $ in front of it. Also, you don't need to do a while loop if you are only grabbing one record. You could just do:

$cb = mysql_fetch_row( $check_badge );
$badge_check = $cb[0];

2007-08-18 13:27:51 · answer #3 · answered by Anonymous · 0 0

Looks like you've missed out the $ from in front of the variable on the statement inside the while loop.

i.e. it needs to be $badge_check instead of badge_check.

Other than that, I don't know.

Edit: To sparky, it's a computer programming language

Edited again: Oops, I forgot the statement in the while loop was an assignment as well. Silly me!

2007-08-18 12:44:30 · answer #4 · answered by pardon_my_klatchian 4 · 0 1

It looks like you are either an oracle dba or an sqlplus programmer maybe you need to write the full detail and what you expected to get as a result from your sqlplus query and the errors you got.

2007-08-18 17:15:29 · answer #5 · answered by allwell 2 · 0 1

what on earth is this supposed to be asking????

is this a mensa test or something????????

2007-08-18 12:32:36 · answer #6 · answered by sparky 3 · 1 1

WTF ?

2007-08-18 12:32:18 · answer #7 · answered by Anonymous · 0 1

fedest.com, questions and answers