-1

I am not really familiar with mysqli that much, and I have to upgrade my script to mysqli, please could you help me sort it?

I have this

function getConnected($host,$db_user,$db_password,$db) {

       $mysqli = new mysqli($host, $db_user, $$db_password, $db);

       if($mysqli->connect_error) 
         die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());

       return $mysqli;
    }
    $mysqli = getConnected("localhost", "user_name_data456", "password123456", "user_database456");

and my query

        mysqli_query($mysqli,$sql);
        mysqli_query($mysqli,$sql2);
        mysqli_query($mysqli,$sql3);
        mysqli_query($mysqli,$sql4);
        mysqli_query($mysqli,$sql5);

The queries sql1 - 5 are working fine, it just has some insert things, I know doing more queries on mysql or mysqli isn't recommended, but I am just too tired.

Please help me sort it out. :/

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
T.Lowly
  • 54
  • 1
  • 7

1 Answers1

1

Change this line

$mysqli = new mysqli($host, $db_user, $$db_password, $db);

to

$mysqli = new mysqli($host, $db_user, $db_password, $db);

removed extra $ from db_password variable

Md. Sahadat Hossain
  • 3,210
  • 4
  • 32
  • 55
  • Oh my god, I feel so stupid.. The no sleep part did its trick. ughhhh, thanks alot everything works fine – T.Lowly Mar 14 '17 at 06:28
  • @T.Lowly it's not a no sleep part but no error reporting part. Were you had error reporting properly set, you'd been told by PHP what's wrong – Your Common Sense Mar 14 '17 at 07:04
  • @YourCommonSense Im not really sure which part of "not really familiar with mysqli" you misunderstood, but Im not hare to take on arguments, thanks for the tip, next time before I am planning on sleeping Ill definitely check out a tutorial that takes probably longer than my eyes can stay open and then just, quickly finish a script, and go to sleep. Anyways thanks, please don't reply. – T.Lowly Mar 14 '17 at 09:00
  • @YourCommonSense I'm sorry I over reacted a bit, just few things annoyed me recently and feel on the edge, anyways, you are right, I should've thought of using error reporting, that's my own stupidity. Thanks for the advice. – T.Lowly Mar 14 '17 at 09:06
  • Who give me -1. Please tell me my fault. I will correct it – Md. Sahadat Hossain Mar 14 '17 at 09:17
  • @Md.SahadatHossain Dont know, I upvoted it and gaved it a winning reply, I couldnt do it imedeatly – T.Lowly Mar 15 '17 at 12:16