detox Posted January 5, 2009 Share Posted January 5, 2009 I can't get '$cred1;' => '$cred2', to populate with row1 and row2 values why? how can i do this Thank you $RunThisQuery = "SELECT row1, row2 FROM frm_auth WHERE userid=".$_REQUEST['id']; $results = $connector->query($RunThisQuery); while ($row = $connector->fetchArray($results)){ $cred1=$row['row1']; $cred2=$row['row2']; $LOGIN_INFORMATION = array( '$cred1;' => '$cred2', 'neverguess' => 'neverguess2' ); } Link to comment https://forums.phpfreaks.com/topic/139486-populate-array-with-sql-row-values-using-php/ Share on other sites More sharing options...
emehrkay Posted January 5, 2009 Share Posted January 5, 2009 single quotes are evaluated as what is in them, not as the variable's value. so $var = 'hey'; '$var' is actually '$var'; where as "$var" is 'hey' Try double quotes Link to comment https://forums.phpfreaks.com/topic/139486-populate-array-with-sql-row-values-using-php/#findComment-729683 Share on other sites More sharing options...
detox Posted January 5, 2009 Author Share Posted January 5, 2009 thanks that helped a bit, the problem now is: i have 5 entries in my sql row and only the last one is being recognized. Link to comment https://forums.phpfreaks.com/topic/139486-populate-array-with-sql-row-values-using-php/#findComment-729698 Share on other sites More sharing options...
detox Posted January 5, 2009 Author Share Posted January 5, 2009 i thing the cause of the problem is that when the rows are being looped no space is being put between them. Any ideas? Thanks Link to comment https://forums.phpfreaks.com/topic/139486-populate-array-with-sql-row-values-using-php/#findComment-729705 Share on other sites More sharing options...
detox Posted January 5, 2009 Author Share Posted January 5, 2009 ok after some review that may not be it either Link to comment https://forums.phpfreaks.com/topic/139486-populate-array-with-sql-row-values-using-php/#findComment-729715 Share on other sites More sharing options...
detox Posted January 5, 2009 Author Share Posted January 5, 2009 for some reason only the last loop pass is sticking it doesnt print seperate array values like this array( example1 => example1a, example2 => example2a it just creates the last one: array (example2 => example2a Link to comment https://forums.phpfreaks.com/topic/139486-populate-array-with-sql-row-values-using-php/#findComment-729725 Share on other sites More sharing options...
emehrkay Posted January 5, 2009 Share Posted January 5, 2009 I assume that the problem is that you are rewriting the same key so only the last one is staying. You could make it a multidimensional array $LOGIN_INFORMATION = array(); while(){ $LOGIN_INFORMATION[] = array( 'key' => 'val' ); } Link to comment https://forums.phpfreaks.com/topic/139486-populate-array-with-sql-row-values-using-php/#findComment-729890 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.