Jump to content

[SOLVED] mysqli to mysql?


ShiloVir

Recommended Posts

Can someone tell me how to translate:

 

<?php
$mysqli = mysqli_connect("localhost", "*******", "*******", "*********");
$sql = "SELECT f_name, l_name, username FROM auth_users WHERE username = '".$_POST["username"]."' AND password = PASSWORD('".$_POST["password"]."')";
$result = mysqli_query($mysqli, $sql) or die(mysqli_error($mysqli));
?>

 

to use mysql instead of mysqli, Ive tried a few things but always get errors like...

 

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\xampp\htdocs\login\userlogin.php on line 14

Link to comment
https://forums.phpfreaks.com/topic/134116-solved-mysqli-to-mysql/
Share on other sites

<?php
$conn = mysql_connect("localhost", "*******", "*******") or die(mysql_error());
$use = mysql_query("USE *********") or die(mysql_error());
$sql = "SELECT f_name, l_name, username FROM auth_users WHERE username = '".$_POST["username"]."' AND password = PASSWORD('".$_POST["password"]."')";
$result = mysql_query($sql,$conn) or die(mysql_error());
?>

 

I think that's it... Try it.

k. I tried:

 

<?php
$mysql = mysql_connect("localhost", "****", "*******");
$db = mysql_select_db("Projectshilo", $mysql);

//create and issue the query
$sql = "SELECT f_name, l_name, username FROM auth_users WHERE username = '".$_POST["username"]."' AND password = PASSWORD('".$_POST["password"]."')";
$result = mysql_query($db, $sql) or die(mysql_error($mysql));
?>

 

but got the error:

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\xampp\htdocs\login\userlogin.php on line 15

 

Apparently. PHP-MySQL doesnt like me today. ive done this before. I just dont usderstand why its not working today

<?php
$conn = mysql_connect("localhost", "*****", "*****");
$db = mysql_select_db("Projectshilo");

//create and issue the query
$sql = "SELECT f_name, l_name, username FROM auth_users WHERE username = '".$_POST["username"]."' AND password = PASSWORD('".$_POST["password"]."')";
$result = mysql_query($sql, $conn) or die(mysql_error());
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.