vrtx Posted January 4, 2007 Share Posted January 4, 2007 I would like to load variables that are stored in a txt file into my PHP programming... I looked at the {config_load file="test.conf"} option, but I cant get it to put variables in the PHP programming (only in the HTML-part). So, I wonder if there is a way to get this done!?Yours Mr. VRTX ::) Link to comment https://forums.phpfreaks.com/topic/32794-solved-how-to-load-a-variable-from-file-into-php/ Share on other sites More sharing options...
SharkBait Posted January 4, 2007 Share Posted January 4, 2007 How is your config file written? I mean what does it look like? We could then see how you can read it in and parse it for the variables? Link to comment https://forums.phpfreaks.com/topic/32794-solved-how-to-load-a-variable-from-file-into-php/#findComment-152689 Share on other sites More sharing options...
vrtx Posted January 4, 2007 Author Share Posted January 4, 2007 The config file just contains:[code]slot = 6003[/code]The script I made:[code]{config_load file="slot.conf"}<body bgcolor="#000000"><?php@extract($_POST); $name = stripslashes($name); $phone = stripslashes($phone); $email = stripslashes($email); $message = stripslashes($message); $sleutel = stripslashes($sleutel); //just some vriables import from Flash$test = 20;if (#slot# > $test) { echo 'welldone'; } else { echo 'not correct'; }mail('[email protected]','VRTX sitereactie',"Contactpersoon: $nameTelefoon: $phonee-mail: $emailBericht: $message","From: $email"); //lets mail the vars to my address[/code] Link to comment https://forums.phpfreaks.com/topic/32794-solved-how-to-load-a-variable-from-file-into-php/#findComment-152871 Share on other sites More sharing options...
vrtx Posted January 5, 2007 Author Share Posted January 5, 2007 I found another way:http://www.php-editors.com/articles/php_textfile.phpthis makes use of a data array...[code]$data = array();# define your data file and its path, ensure you have write permission to folder$myTextFile = 'slot.txt';if (file_exists($myTextFile)) $data = parse_ini_file($myTextFile, true);$slot = $data[sectienaam]['waarde'];[/code]and in the txt file you should put somthing like...[code][sectienaam]waarde=51[/code]Now $slot equals 51 Link to comment https://forums.phpfreaks.com/topic/32794-solved-how-to-load-a-variable-from-file-into-php/#findComment-153285 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.