Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

mysql extension deprecated error

php mysqli

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1 DarkHeart

DarkHeart

    CC Newcomer

  • Member
  • PipPip
  • 16 posts

Posted 12 April 2016 - 08:47 AM

I am having this error "mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead on line 66" on alot of my PHP scripts and i'm not really sure what the solution is. The following an example of the line of codes which are giving me that error

   $mysqli = new mysqli('localhost', 'root', '', 'radian');


if ($mysqli->connect_error) {
    die('Connect Error (' . $mysqli->connect_errno . ') '
            . $mysqli->connect_error);
}	 
    
$query = "SELECT Staff_id,Fname,Sname,Gender,username FROM staff  ";

$result = mysql_query($query);
if (!$result) die ("Database access failed: " . mysql_error());
$rows = mysql_num_rows($result);
for ($j = 0 ; $j < $rows ; ++$j)


{
    $row = mysql_fetch_array($result);
	$staff_id = $row['Staff_id'];
    $Fname = $row['Fname'];
    $Sname = $row['Sname'];
	$Gender = $row['Gender'];
	$username = $row['username'];

    echo '<tr> <td>'.$staff_id.'</td> <td>'.$Fname.'</td> <td>'.$Sname.'</td> <td>'.$Gender.'</td> <td>'.$username.'</td> </tr>';
}
 
 }

Edited by DarkHeart, 12 April 2016 - 08:48 AM.


#2 freshfish

freshfish

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted 13 May 2016 - 03:49 AM

mysql_ is deprecated as of version 5.5 and totaly removed from version 7 and should not be used.

 

Insted you should use PDO, http://php.net/manua...statements.php.






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download