php show slave status - php

im not to sure why im getting a Warning: mysql_fetch_array(): when running this query
$query="SHOW SLAVE STATUS;";
$result = mysql_db_query("aid", $query, $con);

well i use my_db_query because im new to php and thats all i really know well here is the full error
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/admin/domains/ismfast.com/public_html/V3/internal/karl_tools/slave_email.php on line 23
$query="SHOW SLAVE STATUS;";
$result = mysql_db_query("aid", $query, $con); echo $result;
$r = mysql_fetch_array($result);
if($r['Slave_SQL_Running']=="Yes"){echo $r['Exec_Master_Log_Pos']}

Related

Converting mysql to mysqli functions and getting parameter error

I'm new to mysqli and am upgrading all my code to use it.
I understand functions now need to have the $conn variable included with them.
Here is my code:
$query = "SELECT * FROM...";
$result = mysqli_query ($conn, $query);
while ($row = mysqli_fetch_array($conn, $result)) {
}
I'm getting the error:
PHP Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result
and I can't figure out what I'm missing.
and I can't figure out what I'm missing.
Missing? Nothing. Extra? :)
mysqli_fetch_array will take $result, which already knows about $conn; so mysqli_fetch_array($result) is correct, and adding $conn confuses it.

Error after Server Upgrade - mysql_num_rows(): supplied argument is not a valid MySQL result resource [duplicate]

This question already has answers here:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result [duplicate]
(6 answers)
Closed 8 years ago.
I tried to search and found some similar questions but none seemed to help with my code. I upgraded to a new server:
MySQL = 5.0.96-community
PHP = 4.4.9
I get following error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL
result resource in /path/to/file/filename.php on line 209
Here's the Line 209:
$num_rows = mysql_num_rows($result);
The code right above it for reference is:
<?
// Connect to DB
$db = mysql_connect("localhost","db_name","password");
if (!$db)
{
echo "No connection.";
exit;
}
mysql_select_db("db_name");
$v = str_replace(' ','_',$v);
$query = "SELECT * FROM reviews";
$result = mysql_query($query);
$num_rows = mysql_num_rows($result);
You aren't doing basic error checking:
$result = mysql_query($query);
For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning
resultset, mysql_query() returns a resource on success, or FALSE on
error.
For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc,
mysql_query() returns TRUE on success or FALSE on error
See also mysql_error():
Returns the text of the error message from previous MySQL operation

Is mysql_fetch_array() supported in PHP 5.2.6?

I get this error message when I try to use mysql_fetch_array():
while( $deffefgpSfet->fetch() ) {
$roefe= mysql_fetch_array($ffefe, MYSQL_NUM);
Warning: mysql_fetch_array(): supplied argument is not a valid
MySQL result resource in <b>/opt/lampp/htdocs/index.php on line 157
You don't show the code for the object $defeft but I can assume what you're trying to do...
$blah = mysql_query("SELECT 1 FROM information_schema.tables");
if(!$blah) { // check for mysql errors
echo mysql_error();
exit;
}
while( $defeft = mysql_fetch_array($blah)) {
echo $defeft['row'];
}
Defeft holds the rows data in a array, and while loops through each row.
doesn't that error refer to using mysql_fetch_X on a variable that is not a Resource, e.g. the query failed, ensure your query returns a valid result, rather than a mysql error?
$a = mysql_query($sql) or die();
try this (or similar) :)

Warning mysql_fetch_array when I use MATCH, AGAINST in PHP/mySQL

I get this error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
when I changed my code to this
$term = $_POST["term"];
$query = mysql_query("SELECT id FROM planet1 WHERE MATCH (title) AGAINST ('$term')");
while($row = mysql_fetch_array( $query )) {
echo $row['id'],'<br>';
}
This happens when there is an error during the execution of the SQL query :
mysql_query() returns false
and that's not a resource as mysql_fetch_array() expects.
You should try calling mysql_error(), to have some information about the error that's caused by the execution of your MySQL :
$query = mysql_query("SELECT id FROM planet1 WHERE MATCH (title) AGAINST ('$term')");
if (!$query) {
echo mysql_error();
die;
}
Note: of course, this echo+die is OK while developping, but should never be present on a production server.

mysql_num_rows(): supplied argument is not a valid MySQL result resource [duplicate]

This question already has answers here:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result [duplicate]
(6 answers)
Closed 9 years ago.
if(mysql_num_rows($result))
{
echo "no match found!";
}
it is throwing an error-
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\Hosting\6448289\html\includes\getQuestion.php on line 72
You need to check the return value of mysql_query
$query = 'YOUR QUERY';
$result = mysql_query($query);
if (!$result) {
trigger_error('Invalid query: ' . mysql_error()." in ".$query);
}
// go ahead and fetch the results using mysql_num_rows.
If mysql_query fails it returns boolean false instead of a resource.
When you pass this boolean value to mysql_num_rows you get this error.

Categories