Jump to content

Need help with this function


franmm25

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.