Page 1 of 1

mysqli

Posted: Wed Jun 18, 2014 9:58 pm
by Caroll09
hello guys i am really struggling with the new mysqli thing

for example if i had:

$testinfo = "SELECT * from players where username = $player";
$testinfo1 = mysql_query ($testinfo) or die ("Could not query players");
$testinfo2 = mysql_fetch_array ($testinfo1);

what would be the mysqli equivalent

Thank you

Re: mysqli

Posted: Wed Jun 18, 2014 10:49 pm
by Script47
Caroll09 wrote:hello guys i am really struggling with the new mysqli thing

for example if i had:

$testinfo = "SELECT * from players where username = $player";
$testinfo1 = mysql_query ($testinfo) or die ("Could not query players");
$testinfo2 = mysql_fetch_array ($testinfo1);

what would be the mysqli equivalent

Thank you
The "i" is imperative as it's MySQLi.

Code: Select all

$testinfo = "SELECT * from players where username = $player";
$testinfo1 = mysqli_query ($testinfo) or die ("Could not query players");
$testinfo2 = mysqli_fetch_array ($testinfo1);
Be sure to make use of MySQLi's prepared statements too.

http://www.php.net//manual/en/book.mysqli.php
http://codular.com/php-mysqli

Re: mysqli

Posted: Wed Jun 18, 2014 11:06 pm
by Caroll09
The "i" is imperative as it's MySQLi.

Code: Select all

$testinfo = "SELECT * from players where username = $player";
$testinfo1 = mysqli_query ($testinfo) or die ("Could not query players");
$testinfo2 = mysqli_fetch_array ($testinfo1);
Be sure to make use of MySQLi's prepared statements too.

http://www.php.net//manual/en/book.mysqli.php
http://codular.com/php-mysqli
so the only thing that changes is the 'i'?

Re: mysqli

Posted: Wed Jun 18, 2014 11:32 pm
by Script47
Caroll09 wrote:The "i" is imperative as it's MySQLi.

Code: Select all

$testinfo = "SELECT * from players where username = $player";
$testinfo1 = mysqli_query ($testinfo) or die ("Could not query players");
$testinfo2 = mysqli_fetch_array ($testinfo1);
Be sure to make use of MySQLi's prepared statements too.

http://www.php.net//manual/en/book.mysqli.php
http://codular.com/php-mysqli
so the only thing that changes is the 'i'?
Mostly yes, I suggest learning it. Not just guessing as you might get unexpected results.

Re: mysqli

Posted: Thu Jun 19, 2014 2:28 pm
by Sharlenwar
I have found the mySQLi stuff is different. Very different from the old way. You also want to move to what PHP5 is doing with their somewhat object orientated stuff.

In this thread I use mySQLi: http://indie-resource.com/forums/viewto ... 4&start=10

Hope it helps? Plus I'm not expert, just some nobody.