|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this 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
|
|||
|
|||
|
Question on "return"
I have a very strange problem.
Based on Ben`s artikel i am building up a small comunty system. After i did the admin stuff, i wanted to let the users change there own detailpage. The idea ist simple: IF User ist logged in AND pageuserid=userid a link is been placed to a edit page(which ist secured too ;-) ). Similar to the admin query i did this: //----------------------------------------------------------- function UseridIsDetailId() { session_start(); // Check that the session id is valid $dbVars = new dbVars(); @$svrConn = mysql_connect($dbVars->strServer, $dbVars->strUser, $dbVars->strPass); if($svrConn) { $dbConn = mysql_select_db($dbVars->strDb, $svrConn); if($dbConn) { $strQuery = "SELECT {$this->__FieldNameSess}, {$this->__FieldNameSec}, {$this->__FieldNameUserId} FROM {$this->__StoreSessionTableName} "; $strQuery .= "WHERE {$this->__FieldNameSess} = '" . session_id() . "' AND {$this->__FieldNameUserId} = '$userid'" ; $results = @mysql_query($strQuery); if($result = @mysql_fetch_array($results)) { return $result{$this->__FieldNameSec}; } else { return 0; } } else { return false; } } else { return false; } } //________________________________________________ Debuggin the Query gets this: Array ( [0] => 0082810f7a81847def0077ec0a55d0eb [sessionid] => 0082810f7a81847def0077ec0a55d0eb [1] => 1 [auth] => 1 [2] => 27 [userid] => 27 ) //___________________________________________ So als {$this->__FieldNameSec} = auth the funktion should return "1" and i would be happy. But NO!! the problem has du be somewere here if($result = @mysql_fetch_array($results)) { return $result{$this->__FieldNameSec}; } else { return 0; } //___________________________________________ if i change { return $result{$this->__FieldNameSec}; } else { return 1; }//<-----to that it works, so were is the mistake here:{ return $result{$this->__FieldNameSec}; } I am workin 2 days on that problem help would be very kind. Thank you very much timepoint5 |
|
#2
|
|||
|
|||
|
Are you receiving any error messages at all?
Also, where is "$userid" coming from? Is it entered by the user on a form?
__________________
____________________________________________ Developer Shed Weekly Writer | DevArticles Forum Moderator Build Your Own KlipFolio Klip With PHP FrankManno.com - Under Construction Design Interactive Group - Under Construction |
|
#3
|
|||
|
|||
|
As i didnt find the mistake, ich wrote the funktion on to the page, that worked. So the mistake was calling and debugging a class funktion not in the class.php.
The Userid comes from the funktion that lists all related data to the current userid. Perhaps it could work if i could make that var global, but i dont know how. Anyway its works ok now. Perhaps i should have dont somethink like $GET['userid'] ... Greetings timepoint5 |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Question on "return" |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|