deemurphy Posted July 22, 2010 Share Posted July 22, 2010 I decided to upgrade my site which was doing fine, but now I am getting the following: Warning: mysqli_query() expects parameter 1 to be mysqli, null given in all my PHP files and I do not understand this error. Thank you for any solution to this. LadyDee Quote Link to comment https://forums.phpfreaks.com/topic/208548-warning-mysqli_query-expects-parameter-1-to-be-mysqli-null-given/ Share on other sites More sharing options...
Pikachu2000 Posted July 22, 2010 Share Posted July 22, 2010 What do you mean by upgrade? Quote Link to comment https://forums.phpfreaks.com/topic/208548-warning-mysqli_query-expects-parameter-1-to-be-mysqli-null-given/#findComment-1089637 Share on other sites More sharing options...
deemurphy Posted July 22, 2010 Author Share Posted July 22, 2010 I justed wanted to upgrade the feel and look of the site, it is hosted on 000webhost.com the name of the website is http://ladydee.net23.net/ - If you go to contact me and look at for instance Please View my Calendar and Set an Appointment You will see what I am getting. Thank you LadyDee Quote Link to comment https://forums.phpfreaks.com/topic/208548-warning-mysqli_query-expects-parameter-1-to-be-mysqli-null-given/#findComment-1089833 Share on other sites More sharing options...
Alex Posted July 22, 2010 Share Posted July 22, 2010 We can't help much without seeing relevant code. The problem is that when using mysqli_query() in procedural style the first parameter needs to be the mysqli link. To be more specific we'll need to see some code. Quote Link to comment https://forums.phpfreaks.com/topic/208548-warning-mysqli_query-expects-parameter-1-to-be-mysqli-null-given/#findComment-1089841 Share on other sites More sharing options...
deemurphy Posted July 22, 2010 Author Share Posted July 22, 2010 I am attaching the code for the calendar. LadyDee [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/208548-warning-mysqli_query-expects-parameter-1-to-be-mysqli-null-given/#findComment-1089843 Share on other sites More sharing options...
Pikachu2000 Posted July 22, 2010 Share Posted July 22, 2010 Did you inadvertently remove the database connection script from showcalendar_withevent.php, or accidentally delete it altogether? Can you post the code within . . . tags? Warning: mysqli_error() expects parameter 1 to be mysqli, null given in /home/a3151982/public_html/showcalendar_withevent.php on line 203 Quote Link to comment https://forums.phpfreaks.com/topic/208548-warning-mysqli_query-expects-parameter-1-to-be-mysqli-null-given/#findComment-1089844 Share on other sites More sharing options...
Alex Posted July 22, 2010 Share Posted July 22, 2010 After mysqli_connect put something like this to see if it's failing: if (!$mysqli) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); } Quote Link to comment https://forums.phpfreaks.com/topic/208548-warning-mysqli_query-expects-parameter-1-to-be-mysqli-null-given/#findComment-1089848 Share on other sites More sharing options...
Pikachu2000 Posted July 22, 2010 Share Posted July 22, 2010 Did you edit this to post it here, or did you edit it to use during development? I wouldn't expect to see the root user being the account used for DB access on a hosted site. Also, usually (but not always) the database server isn't at localhost. $mysqli = mysqli_connect("localhost", "root", "ladydee", "ladydee"); Quote Link to comment https://forums.phpfreaks.com/topic/208548-warning-mysqli_query-expects-parameter-1-to-be-mysqli-null-given/#findComment-1089853 Share on other sites More sharing options...
deemurphy Posted July 23, 2010 Author Share Posted July 23, 2010 I edited it to upload it here. Here is the actual file. LadyDee [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/208548-warning-mysqli_query-expects-parameter-1-to-be-mysqli-null-given/#findComment-1089959 Share on other sites More sharing options...
Alex Posted July 23, 2010 Share Posted July 23, 2010 You should edit that file and remove your connection details immediately. Your problem is that $mysqli is never set, you're also mixing mysql and mysqli functions, you can't do that. Quote Link to comment https://forums.phpfreaks.com/topic/208548-warning-mysqli_query-expects-parameter-1-to-be-mysqli-null-given/#findComment-1089963 Share on other sites More sharing options...
deemurphy Posted July 23, 2010 Author Share Posted July 23, 2010 Thank you, but then how should I fix this. LadyDee Quote Link to comment https://forums.phpfreaks.com/topic/208548-warning-mysqli_query-expects-parameter-1-to-be-mysqli-null-given/#findComment-1089964 Share on other sites More sharing options...
Pikachu2000 Posted July 23, 2010 Share Posted July 23, 2010 If you can't unattach that file from the post, or edit it, you should change your DB password ASAP. Quote Link to comment https://forums.phpfreaks.com/topic/208548-warning-mysqli_query-expects-parameter-1-to-be-mysqli-null-given/#findComment-1089967 Share on other sites More sharing options...
deemurphy Posted July 23, 2010 Author Share Posted July 23, 2010 I changed the password, I think if I change all of mysli to mysql this will work it that correct. LadyDee Quote Link to comment https://forums.phpfreaks.com/topic/208548-warning-mysqli_query-expects-parameter-1-to-be-mysqli-null-given/#findComment-1089971 Share on other sites More sharing options...
Pikachu2000 Posted July 23, 2010 Share Posted July 23, 2010 The mysql and mysqli extensions use a somewhat different syntax, but it looks like the script was written with the mysql extension originally, then an attempt was made to modify it. If that's the case, you should be able to change the mysqli's back to mysql. If that doesn't work, I'm sure someone here can help out. Quote Link to comment https://forums.phpfreaks.com/topic/208548-warning-mysqli_query-expects-parameter-1-to-be-mysqli-null-given/#findComment-1089974 Share on other sites More sharing options...
deemurphy Posted July 23, 2010 Author Share Posted July 23, 2010 Now I am getting the following error: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource LadyDee Quote Link to comment https://forums.phpfreaks.com/topic/208548-warning-mysqli_query-expects-parameter-1-to-be-mysqli-null-given/#findComment-1090378 Share on other sites More sharing options...
PFMaBiSmAd Posted July 23, 2010 Share Posted July 23, 2010 The second parameter in a mysql_query() function call is an optional mysql link resource. Your's is not one. You would need to troubleshoot why the second parameter you are supplying is not a mysql link resource and make it the one that your mysql_connect() created. Quote Link to comment https://forums.phpfreaks.com/topic/208548-warning-mysqli_query-expects-parameter-1-to-be-mysqli-null-given/#findComment-1090382 Share on other sites More sharing options...
deemurphy Posted July 23, 2010 Author Share Posted July 23, 2010 I am not sure how to do this as I have never mixed the two. I got part of this from the All In One PHP Book. LadyDee Quote Link to comment https://forums.phpfreaks.com/topic/208548-warning-mysqli_query-expects-parameter-1-to-be-mysqli-null-given/#findComment-1090452 Share on other sites More sharing options...
PFMaBiSmAd Posted July 24, 2010 Share Posted July 24, 2010 No one can really help you with what is specifically wrong with your code without seeing the code that produces the error. I told you what the error means, if you don't understand what the parameters are in a function call or where or if they are getting set to the correct values, you will need to post your code. Quote Link to comment https://forums.phpfreaks.com/topic/208548-warning-mysqli_query-expects-parameter-1-to-be-mysqli-null-given/#findComment-1090470 Share on other sites More sharing options...
deemurphy Posted July 24, 2010 Author Share Posted July 24, 2010 Here is the code. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/208548-warning-mysqli_query-expects-parameter-1-to-be-mysqli-null-given/#findComment-1090510 Share on other sites More sharing options...
PFMaBiSmAd Posted July 25, 2010 Share Posted July 25, 2010 That code isn't even using mysql_query() so it cannot be the code you were using that produced the error you posted in Reply #14. In fact, it is probably the original code you stared with and it produces the error message in the title of this thread. When your problem is a moving target of randomly changing code and errors that don't even match the code you provide, no one really wants to try to chase down what you are changing in it. You have had both the mysqli and mysql errors explained and been told that you cannot mix mysql and mysqli functions in one script. You must pick one way or the other and all the database related code on any page must use the same type. Quote Link to comment https://forums.phpfreaks.com/topic/208548-warning-mysqli_query-expects-parameter-1-to-be-mysqli-null-given/#findComment-1090801 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.