franmm25 Posted November 23, 2011 Share Posted November 23, 2011 Actually i work in create simple database in flat file with this structure : username|password| Jhonh30~123456~ For read all use this function i create : <? function db_read($db_path,$db_name,$db_campos) { foreach ($db_campos as $campos) { global ${$campos}; } global $count_datos; $file=file("".$db_path."".$db_name.""); $linea_datos=$file[0]; for ($i=1;$i<sizeof($file);$i++) { $exp_linea_datos=explode("|",$linea_datos); $exp_datos=explode("~",$file[$i]); $count_datos=0; for ($x=0;$x<count($exp_linea_datos);$x++) { ${$exp_linea_datos[$x]}[]=$exp_datos[$x]; } $count_datos++; } } ?> For call function i use this , in this way : <? db_read("./db_base/foros/","datos_personales.txt",array("username","password")); /// This let me read all fields perfectly with only put this code $username[0]; ?> All works fine the only problem it´s if i create form with the same fields in name as in the db , give this error Fatal error: [] operator not supported for strings in C:\AppServ\www\db\test\index.php ..................... Only give this error if the fields of form his names the same username and password , if the fields use the name username_1 and password_1 no give problem , i want if it´s possible put solution to this , because i work in this for create simple database api and this method let create simple databases and before more things i have created and i want put as open source for everybody Thank´s for your help , regards Link to comment https://forums.phpfreaks.com/topic/251662-need-help-with-this-function/ Share on other sites More sharing options...
franmm25 Posted November 23, 2011 Author Share Posted November 23, 2011 Nothing know how fix this issue or give some idea , Thank´s , Regards ..... Link to comment https://forums.phpfreaks.com/topic/251662-need-help-with-this-function/#findComment-1290748 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.