Re: [PHP-DB] Reading from file

2010-11-02 Thread Artur Ejsmont
Return Values

If only two parameters were passed to this function, the values parsed
will be returned as an array. Otherwise, if optional parameters are
passed, the function will return the number of assigned values. The
optional parameters must be passed by reference.

http://php.net/manual/en/function.fscanf.php

so you should expect an array. print_r it to see what is inside.

art


On 2 November 2010 03:34, Ethan Rosenberg eth...@earthlink.net wrote:
 Dear List -

 Thank you for all your help.  Here is another one.

 I have a file [/home/ethan/PHP/RecNum] which consists of the number 1005.
  It also has been 1005.  No matter how I do it, it is only recognized as
 1.

 Here is the code.  In this case, the file is 1005.

 $fptr1 = fopen(/home/ethan/PHP/RecNum, r+);
 $recNum = (int)fscanf($fptr1,%s);
 echo $recNum;  //which always is 1

 If I do not typecast $recNum to int, the value is Array.

 Thanks.

 Ethan

 MySQL 5.1  PHP 5  Linux [Debian (sid)]


 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





-- 
Visit me at:
http://artur.ejsmont.org/blog/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Reading from file

2010-11-02 Thread Ethan Rosenberg

At 06:08 AM 11/2/2010, Artur Ejsmont wrote:

Return Values

If only two parameters were passed to this function, the values parsed
will be returned as an array. Otherwise, if optional parameters are
passed, the function will return the number of assigned values. The
optional parameters must be passed by reference.



so you should expect an array. print_r it to see what is inside.

art


On 2 November 2010 03:34, Ethan Rosenberg eth...@earthlink.net wrote:
 Dear List -

 Thank you for all your help.  Here is another one.

 I have a file [/home/ethan/PHP/RecNum] which consists of the number 1005.
  It also has been 1005.  No matter how I do it, it is only recognized as
 1.

 Here is the code.  In this case, the file is 1005.

 $fptr1 = fopen(/home/ethan/PHP/RecNum, r+);
 $recNum = (int)fscanf($fptr1,%s);
 echo $recNum;  //which always is 1

 If I do not typecast $recNum to int, the value is Array.

 Thanks.

 Ethan

 MySQL 5.1  PHP 5  Linux [Debian (sid)]



==
Artur -

Thanks.

I also wanted to be able to increment recNum.

Her is what finally worked for me:

$fptr1 = fopen(/home/ethan/PHP/RecNum, r+);
$recNum = fscanf($fptr1,%d);
$sql1 =  insert into intake2 (Site,Record,BMI) values ('A',$recNum[0],19);
$recNum[0] = $recNum[0] + 1;
rewind($fptr1);
fprintf($fptr1,%d, $recNum[0]);

Ethan



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php