|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Functions, return?
function pass_check($username, $password)
{ $sql = "SELECT password FROM user_info WHERE username='". $username . "'"; $result = mysql_query($sql); $real_password = mysql_fetch_array($result); if ($password == $real_password) { return 1; } else { return 0; } } //Should not this call the function and give the $passcheck the value 1 or 0 $passcheck = pass_check($username, $password); |
|
#2
|
|||
|
|||
|
RE: Functions, return?
It should...
|
|
#3
|
|||
|
|||
|
RE: Functions, return?
NO! it shouldn't!
look at the php man for the explanation on what does mysql_fetch_row() function do: http://php.net/mysql_fetch_array when u read that, u should know that all u need to change is the condition in the if statement to: |
|
#4
|
|||
|
|||
|
RE: Functions, return?
It would return 0 because of the else...
|
|
#5
|
|||
|
|||
|
RE: Functions, return?
function pass_check($username, $password)
{ $sql = "SELECT password FROM user_info WHERE username='". $username . "'"; $result = mysql_query($sql); $real_password = mysql_fetch_array($result); if ($password == $real_password[0]) { return 1; } else { return 0; } } This code works, thanks zombie. As you see Im a newbie. Besides, I guess I should learn about session handeling. To you other 'Anonymous', the function ends if $password = $real_password[0] The [0] means the first row in the array, $real_password turns into an array when I use mysql_fetch_array Correct me if Im far of track |
|
#6
|
|||
|
|||
|
RE: Functions, return?
NO! it doesn't mean first row of the array, it means first element of the array, or in this case, first column in the row.
and NO, mysql_fetch_array DOESN'T turn anything into an array, it returns array of all columns in one table row! you should read more about http://php.net/mysql and not about sessions... |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > Functions, return? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|