Note that there are some explanatory texts on larger screens.

plurals
  1. PO(PHP) Why after some looping, the function doesn't called anymore?
    primarykey
    data
    text
    <p>I have query below:</p> <pre><code>$r = "Query goes here..."; $r = conn::execq($q); while($fetch = mysqli_fetch_array($r)) { $q = "Query goes here..."; //The $fetch value above is inserted here as 'WHERE' clause $r = conn::execq($q); //--&gt; The problem $r = mysqli_fetch_row($r); if($r &gt; 0) print "ok&lt;br/&gt;"; else print "failed&lt;br/&gt;"; } </code></pre> <p>And in class "<strong>conn</strong>" function "<strong>execq</strong>":</p> <pre><code>public static function execq($q) { $dbc = @mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME) OR die ('Could not connect to MySQL: ' . mysqli_connect_error()); $r = mysqli_query($dbc, $q); mysqli_close($dbc); return $r; } </code></pre> <p>The <strong>execq</strong> function doesn't called after some looping. The first query has been executed successfully, and then the second query being executed. After some looping, the query being stopped to called the function "conn::execq". Any ideas? Thanks..</p> <p><strong>--- EDIT ---</strong></p> <pre><code>conn:openconn(); //Open connection $r = "Query goes here..."; $r = conn::execq($q); while($fetch = mysqli_fetch_array($r)) { $q = "Query goes here..."; //The $fetch value above is inserted here as 'WHERE' clause $r = conn::execq($q); //--&gt; The problem $r = mysqli_fetch_row($r); if($r &gt; 0) print "ok&lt;br/&gt;"; else print "failed&lt;br/&gt;"; } conn:closeconn(); //Close connection </code></pre> <p>And in class "<strong>conn</strong>":</p> <pre><code>public static function openconn() { global $dbc; $dbc = @mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME) OR die ('Could not connect to MySQL: ' . mysqli_connect_error()); } public static function closeconn() { mysqli_close($dbc); } public static function execq($q) { $r = mysqli_query($dbc, $q); return $r; } </code></pre> <p>And now I've got:</p> <pre><code>Notice: Undefined variable: dbc in ... Warning: mysqli_error() expects parameter 1 to be mysqli, null given in ... </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload