ShiloVir Posted November 24, 2008 Share Posted November 24, 2008 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 More sharing options...
revraz Posted November 24, 2008 Share Posted November 24, 2008 This should help. Basically you need to connect to the DB after you connect to the Server. http://www.phpfreaks.com/tutorial/php-basic-database-handling/page3 Link to comment https://forums.phpfreaks.com/topic/134116-solved-mysqli-to-mysql/#findComment-698129 Share on other sites More sharing options...
waynew Posted November 24, 2008 Share Posted November 24, 2008 <?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. Link to comment https://forums.phpfreaks.com/topic/134116-solved-mysqli-to-mysql/#findComment-698135 Share on other sites More sharing options...
ShiloVir Posted November 24, 2008 Author Share Posted November 24, 2008 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 Link to comment https://forums.phpfreaks.com/topic/134116-solved-mysqli-to-mysql/#findComment-698137 Share on other sites More sharing options...
wildteen88 Posted November 24, 2008 Share Posted November 24, 2008 This $result = mysql_query($db, $sql) or die(mysql_error($mysql)); Should be $result = mysql_query($sql, $sql) or die(mysql_error($mysql)); Link to comment https://forums.phpfreaks.com/topic/134116-solved-mysqli-to-mysql/#findComment-698139 Share on other sites More sharing options...
revraz Posted November 24, 2008 Share Posted November 24, 2008 $result = mysql_query($sql) or die(mysql_error($mysql)); Link to comment https://forums.phpfreaks.com/topic/134116-solved-mysqli-to-mysql/#findComment-698141 Share on other sites More sharing options...
waynew Posted November 24, 2008 Share Posted November 24, 2008 <?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()); ?> Link to comment https://forums.phpfreaks.com/topic/134116-solved-mysqli-to-mysql/#findComment-698143 Share on other sites More sharing options...
ShiloVir Posted November 24, 2008 Author Share Posted November 24, 2008 Thank you guys for the fast responses. TOPIC SOLVED... haha. I guess I forgot to remove my passwords from the string. dumb me. Time to change meh pass before someone hacks meh. haha Link to comment https://forums.phpfreaks.com/topic/134116-solved-mysqli-to-mysql/#findComment-698151 Share on other sites More sharing options...
waynew Posted November 24, 2008 Share Posted November 24, 2008 It's on your localhost... if it's not allowing external connections, you should be fine. Either way, better safe than sorry. Best to use a pass that is alphanumeric. Link to comment https://forums.phpfreaks.com/topic/134116-solved-mysqli-to-mysql/#findComment-698155 Share on other sites More sharing options...
ShiloVir Posted November 24, 2008 Author Share Posted November 24, 2008 yah. I changed them. and thanks to wildteen for Arteriskin' them out for me Link to comment https://forums.phpfreaks.com/topic/134116-solved-mysqli-to-mysql/#findComment-698158 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.