Php Data reading

Source: Internet
Author: User
Php reads File 1. When saving a file in php, $ testfilename2 is not a single quotation mark. otherwise, double quotation marks will report an error. Should I use single quotation marks for variables in the future ?? $ Testfilename2 = 'd: \ ProgramFiles2 \ AppServ \ www \ catch28 \ admin \ testmethod6.h php reads files

1. $ Testfilename2 is not a single quotation mark when saving a file in php. otherwise, double quotation marks will report an error. in the future, single quotation marks should be used for variable storage.

?

?

$ Testfilename2 = 'd: \ ProgramFiles2 \ AppServ \ www \ catch28 \ admin \ testmethod6.html '; // file name, which can be a text file such as .php;.txt

File_put_contents ($ testfilename ,' ');



2. Mysql_free_result () does not need to be called during the update operation:




Mysql_free_result

(PHP 4, PHP 5)

Mysql_free_result-Free result memory

Description bool Mysql_free_result(Resource $ Result)

Mysql_free_result ()Will free all memory associated with the result identifierResult.

Mysql_free_result ()Only needs to be called if you are concerned about how much memory is being used for queries that return large result sets. all associated result memory is automatically freed at the end of the script's execution.

Parameters

?

Result

The result resource thatis being evaluated. This result comes from a call tomysql_query ().

Return Values

ReturnsTRUEOn success orFALSEOn failure.

If a non-resource is used forResult, An error of level E_WARNING will be emitted. It's worth noting that mysql_query () only returns a resource for SELECT, SHOW, EXPLAIN, and DESCRIBE queries.

Examples

?

Example #1Mysql_free_result ()Example

$result?=?mysql_query("SELECT?id,email?FROM?people?WHERE?id?=?'42'");
if?(!$result)?{
????echo?'Could?not?run?query:?'?.?mysql_error();
????exit;
}
/*?Use?the?result,?assuming?we're?done?with?it?afterwards?*/
$row?=?mysql_fetch_assoc($result);

/*?Now?we?free?up?the?result?and?continue?on?with?our?script?*/
mysql_free_result($result);

echo?$row['id'];
echo?$row['email'];
?>
Notes

Note: For backward compatibility, the followingdeprecated alias may be used:Mysql_freeresult ()

See Also

?

  • Mysql_query ()-Send a MySQL query
  • Is_resource ()-Finds whether a variable is a resource



If you need to use?Mysql_free_result (), You may have attached Ed this error. What causes it and how can you fix it?

First, what isMysql_free_result ()? When you makemySQL database queries that return large sets of data, it can causeyour server to bog down because those results are hogging up a lot ofmemory. on a high-traffic site, it can actually crash your server asmore and more of those results build up. so,Mysql_free_result ()Is a built-in PHP function that releases the results of your query frommemory. again, this is usually not a big deal unless you are returninglarge data sets from your queries, but it is always good practice toclear your results and free up the memory on your server. here is anexample of what the PHP code might look like:

?

?

//...CONNECT TO DATABASE...$query = "SELECT * FROM employees WHERE age >= 30";if ($result = mysql_query($query)) {while ($row = mysql_fetch_array($result)) {//...DO SOMETHING HERE...}mysql_free_result($result); //free the query results from memory}///...CLOSE YOUR DATABSE CONNECTION...
? But, if you have strict PHP warnings enabled on your server, you maystart getting the warning abve for some (but not all) of your queries. I had a really hard time tracking this problem down, but I finallyfound it here. you only use Mysql_free_result ()For the following query types: SELECT, SHOW, EXPLAIN, and DESCRIBE. so, if you perform an UPDATE query, it doesn't return a valid resource andthrows the warning when you call mysql_free_result (). duh.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.