Hi
I'm new here and to php!
In the code
$row['user_first_name'] = $userID;
$row['user_last_name'] = '. Please complete this form to register';
$result = mysqli_query($link, 'SELECT * FROM users_table WHERE user_ID="' . $userID . '" And user_entity="' . $entity . '" And user_password="' . $password . '"');
if ($result) {
$row = mysqli_fetch_array($result);
}
$row seems to get cleared even when $result is false, so I never see 'Please complete this form to register'.
Please show me how I can retain the preset values in $row if nothing is returned by the sql query.
Best regards
Chris
how I can retain the preset values in $row
Moderator: General Moderators
-
jazzercising011
- Forum Newbie
- Posts: 9
- Joined: Tue Sep 14, 2010 4:47 am
Re: how I can retain the preset values in $row
you have got this thing all out of whack! You cant really assign things to $row[' '] because once you run the query, it will clear itself. Try using this format instead.
$result = mysqli_query($link, 'SELECT * FROM users_table WHERE user_ID="' . $userID . '" And user_entity="' . $entity . '" And user_password="' . $password . '"');
while($row = mysql_fetch_array($result))
{
$blah = $row['blah'];
}
$result = mysqli_query($link, 'SELECT * FROM users_table WHERE user_ID="' . $userID . '" And user_entity="' . $entity . '" And user_password="' . $password . '"');
while($row = mysql_fetch_array($result))
{
$blah = $row['blah'];
}
Re: how I can retain the preset values in $row
Why are you using same variable before the SQL execution and also for extracting result?
Use differnt variables,
Use differnt variables,
Code: Select all
$var['user_first_name'] = $userID;
$var['user_last_name'] = '. Please complete this form to register';Re: how I can retain the preset values in $row
@ PradeepKr
I think I'm having a problem with unsuccessful query, successful query that didn't find anything and successful query that finds a row.
Are these three different conditions?
What does
return if
a) the query doesn't find anything
b) the query has bad syntax
?
Chris
The idea was, if the query didn't find anything, $row would be loaded with alternate text to be displayed.Why are you using same variable before the SQL execution and also for extracting result?
I think I'm having a problem with unsuccessful query, successful query that didn't find anything and successful query that finds a row.
Are these three different conditions?
What does
Code: Select all
if ($result = mysqli_query($link, 'SELECT * FROM sof4prof_users WHERE user_ID="' . $userID . '" And user_entity="' . $entity . '" And user_password="' . $password . '"')) {a) the query doesn't find anything
b) the query has bad syntax
?
Chris