Is there a better way to include() a PHP loop that depends on a varying MySQL query? -
I have a large PHP loop that I am reusing on many pages of my site in many places. I usually use one () to set that PHP loop, where it is necessary, but in the PHP loop, a MySQL query is used in which the variable for different instances of it (different filters And different borders) are required to change I PHP Loop
& lt ;? Php $ results = mysql_query ("Select * Columnname DESC, Other column names DESC LIMIT 6", $ connection from database name); If (! $ Result) {dead ("database query failed"); }? & Gt; & Lt ;? Php while ($ variable = mysql_fetch_array ($ result)) {---- execute this loop ----}; ? & Gt; I was still remembered using
& lt; ? & Gt;
Everything was going well until I removed the actual MySQL query of the file contained in it and it was placed before each instance PHP (so I asked for each frequency of the query Could control the variable). Now, the MySQL query and the included PHP loop do not look like this, and I get the following warning:
"Warning: mysql_fetch_array (): The supplied argument is line / home / filepathhere /includedfile.php does not have a valid MySQL result resource
I think the included PHP is running in the included file and then the injection is going on in the main page before running the main page Injecting is required.
What is the main page in PHP Loop Is there a better way to inject "inclusion"?
To know about this It takes a good time :)
To expand: contains
which is a way to use the code again, but as you are experiencing There is no controlled method of changing the behavior of that code, in order to pass arguments to a function, a clearly defined A function Trflk, which you can use inside the function to change its behavior.
function my_big_loop ($ condition) {// preparation $ bet = mysql_real_escape_string ($ condition); // always! Even for a simple example too :) $ result = mysql_query ("select * from anywhere WHERE x = '$ condition'"); // duplicate baggage return $ big_pile_of_HTML; } Echo my_big_loop ('some condition');
Comments
Post a Comment