SA-MP Forums Archive
PHP help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Other (https://sampforum.blast.hk/forumdisplay.php?fid=7)
+--- Forum: Everything and Nothing (https://sampforum.blast.hk/forumdisplay.php?fid=23)
+--- Thread: PHP help (/showthread.php?tid=444802)



PHP help - Camorra - 18.06.2013

Hi,
i trying make some format reading houses into php and i would like to get some help

i trying do something like that as PHP
Код:
format(nomefile,sizeof(nomefile),"%s.txt",biz[t][bizname]);
i got this line but that reading just one file and not reading

Код:
if(!$file=fopen("$GameDir/scriptfiles/property.cfg","r")) die("Error reading bizzfile");



Re: PHP help - Sinner - 18.06.2013

PHP код:
<?php
$path 
"PATH_TO_FILE";
$bizname "BIZNAME_HERE";
$file $path $bizname;
if(
file_exists($file"r") == true)
{
    
$file_content file_get_contents($file);
    
// Content of the buziness file is now in $file_content
}
else
{
    die(
"Error reading bizz file " $file);
}



Re: PHP help - Camorra - 18.06.2013

Can you make that stock i have for explain for me, i just started PHP ?
I have houses saving as " Casa " but they many like Casa1.txt , Casa2.txt to Casa800.txt

i just need that then i'll learn from it
PHP код:
    function GetPlayerHouseInfo($user)
    {
        require 
"config.php";
        if(!
$file=fopen("$GameDir/scriptfiles/Casa233.txt","r")) die("Error reading bizzfile");
        while ((
$data=fgetcsv($file,1024"|")) !== FALSE)
        {
            if(
$data[14] == $user)
            {
                
$datanew = array(
                    
"owner" => $data[0],
                    
"id" => $data[1],
                    
"housecash" => $data[2],
                    
"interiorpack" => $data[3],
                    
"garage" => $data[4],
                    
"PriceProd" => $data[5]
                );
                return 
$datanew;
            }
                
        }
        
    } 



Re: PHP help - Camorra - 18.06.2013

Anyone please...
How can i make it read just the house owner via php code and open it


Re: PHP help - saiberfun - 18.06.2013

I think you are better up asking at a Forum that offers help and stuff for PHP Newbies.
Of course, there are some devs in here that know how to handle PHP but you'd get better answers mostly from their.


Re: PHP help - Sinner - 18.06.2013

Quote:
Originally Posted by Camorra
Посмотреть сообщение
I have houses saving as " Casa " but they many like Casa1.txt , Casa2.txt to Casa800.txt[/php]
You shouldn't rely on all 1-800 files to exist. Instead you need to scan the directory for each file.
http://php.net/manual/en/function.scandir.php

If you don't understand the basics of file scanning and iteration I suggest you ask it on a more PHP-related forum. Those people are in a much more suitable position to help you.