since mysql was changed having issues with video 2

Location of the Videos
Post Reply
rhillman
Posts: 1
Joined: Mon Dec 01, 2014 3:21 am

since mysql was changed having issues with video 2

Post by rhillman »

since php and mysql where updated your original dont work so i tried to revamp code to mysqli and i still cant get it to work my code is
<?php
include 'connect.php';

$playerinfo = mysqli_query($conn, "SELECT * from player WHERE name='Kronus'");
$playerinfo2 = mysqli_query($conn, $playerinfo) or die ("could not select players");
$playerinfo3 = mysqli_fetch_array($conn, $playerinfo2);

echo "Kronus's email is " . $playerinfo3['email'];
?>
but i get ( ! ) Warning: mysqli_query() expects parameter 2 to be string, object given in C:\wamp\www\Tutorial\test.php on line 5


i cant figure out where i am going wrong
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: since mysql was changed having issues with video 2

Post by Epiales »

This would be your database connect:

Code: Select all

<?php
$db_conx = mysqli_connect("localhost", "root", "", "login2");
// Evaluate the connection
if (mysqli_connect_errno()) {
    echo mysqli_connect_error();
    exit();
}// else {
//echo "Successful database connection!!!";
//}
?>
Then you would write it like this:

Code: Select all

$playerinfo = "SELECT * from player WHERE name='Kronus'";
$playerinfo2 = mysqli_query($db_conx, $playerinfo);
$playerinfo3 = mysqli_fetch_array($playerinfo2, MYSQLI_ASSOC);
Of course you can change the $db_conx to $conn if u're more comfortable that way...
Nothing fancy, but a work in progress!

http://gameplaytoday.net
Post Reply

Return to “Older Browser MMO Videos”