Help Ugently Needed For My Msqli Error - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Help Ugently Needed For My Msqli Error (1255 Views)
| Help Ugently Needed For My Msqli Error by dapaiks(op): 8:15pm On Jan 31, 2018 |
Good day house, i update my locallhost/wampserver, after importing my database into my phpadmin i tried login in buh i got this error "mysql depricated, use mysqli or pdo blablabla... in connection.php" This the code bello <?php session_start(); $hostname = "localhost"; $database = "db_crimemanager"; $username = "root"; $password = ""; $conn = mysql_connect($hostname, $username, $password) or die(mysql_error()); $db = mysql_select_db($database, $conn) or die(mysql_error()); if (!$db) { die("Unable to select database" ;} ?> Pls i need sme1 to help me out with this as soon as posible, thnkx |
| Re: Help Ugently Needed For My Msqli Error by Luminee(f): 8:18pm On Jan 31, 2018 |
dapaiks:You need to write your codes in mysqli mysql is no more in use. Mysqli and PDO is the new normal. Read more on it. Mysql is no more secured from sql injection attack, that's the reason for having to upgrade to mysqli. |
| Re: Help Ugently Needed For My Msqli Error by dapaiks(op): 8:41pm On Jan 31, 2018 |
Luminee:I will definately read abt it, buh ryt nw i dnt hv tym on my side, i jst need a way to handle this situation like imediately. |
| Re: Help Ugently Needed For My Msqli Error by Hostermipo(m): 9:04pm On Jan 31, 2018 |
dapaiks:use it this way but you will still have to change all your MySQL to MySQLi in all your codes. MySQL is outdated. <?php //Connect to database $db_connect = mysqli_connect("localhost", "root", "", "db_crimemanager" ;// check the connection if (mysqli_connect_error()) { echo 'Unable to select database'; exit(); } |
| Re: Help Ugently Needed For My Msqli Error by kaythinks(m): 10:34pm On Jan 31, 2018 |
| Re: Help Ugently Needed For My Msqli Error by Luminee(f): 2:14am On Feb 01, 2018 |
dapaiks:The issue just doesn't affect only your php login code, as affects all your codes. There is a slight difference in the syntax of mysqli, so even if I help you with the login code, how do you solve all other pending issues? Read on it bro |
| Re: Help Ugently Needed For My Msqli Error by ClintonNzedimma(m): 8:00am On Feb 01, 2018 |
Boss, this is a safer method so you won't waste time In your connection.php, write $mysql=new mysqli("localhost", "root", "", "db_crimemanager" ;Then in your functions and classes make $mysql a GLOBAL variable If you have the old mysql_query(), change it to $query=$mysql->query() if you have the old mysql_num_rows(), change it to $num_rows=query->num_rows Don't forget to always make the $mysql variable a global in all your functions or classes else it won't work |
An Error Occurred At Log Record Id. • Programmer Needed Ugently.... • Sql Error Msg 1801, Level 16 During Execution In Ssms • 2 • 3 • 4
Java/Kotlin/Groovy/Scala/Clojure - What's Your Favourite JVM Language? • I Need A Site Like Njatym blog Or A Site Like Nairaland Created With Blogger • Frontend Web Dev Course & IOS App Dev Course for free
;