Hello friends,
I am getting an error message whenever i am trying to run any query in php.I don't know whats wrong with it.I am getting the following error message as follows
PHP Notice: Undefined variable: array in C:\xampp\htdocs\mysql_class_2.php
Hello friends,
I am getting an error message whenever i am trying to run any query in php.I don't know whats wrong with it.I am getting the following error message as follows
PHP Notice: Undefined variable: array in C:\xampp\htdocs\mysql_class_2.php
Sure i will help you out with this is it possible for you to provide me the code so that i can give you a perfect solution for it.
Following are the code on which i am getting the error message
PHP Code:<?php
class mysql {
function Connect($host, $name, $pass, $db){
$connection = mysql_connect("$host","$name","$pass");
mysql_select_db("$db", $connection);
}//ends the connection function
function Close(){
mysql_close($this->connection);
}//ends the close function
function FetchRow($query){
$rows = mysql_fetch_row($query);
return $rows;
}
function FetchArray($query){
$array = mysql_fetch_array($query);
return $array;
}
function FetchNum($query){
$num = mysql_num_rows($query);
return $num;
}
function Query($sql){
$query = mysql_query($sql) or die(mysql_error());
return $query;
}//ends the query function
function FetchAssoc($query2){
if($query2 and !is_bool($query2)){
$array = mysql_fetch_assoc($query2);
}
return ($array);
}
/*
function TanimotoSimilarity($query,$input_arrays) {
$i=0;
$row= array();
while( $row=mysql_fetch_assoc($query) )
{
$first[$i]=(count(array_intersect($row,$input_arrays)))/(count($row)+count($input_arrays)-count(array_intersect($row,$input_arrays)));
$i++;
}
return($first);
} */
}//ends the class
?>
Try to use the following code instead of your
And with that you need to use else statement to return a NULL value for your $array.PHP Code:$x = 1;
$y = 2;
// Because our conditional will return false, it will skip the creation of $xy.
if ( $x === $y )
{
$xy = $x + $y;
}
// Therefore, we are now trying to return a variable that doesn't exist.
return $xy;
$x = 1;
$y = 1;
// Now that the if conditional will return true, it sets the variable and we can
// successfully return it.
if ( $x === $y )
{
$xy = $x + $y;
}
return $xy;
Bookmarks