getting null value from DB event though it's there

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
someguyhere
Forum Contributor
Posts: 181
Joined: Sun Jul 27, 2008 3:24 pm

getting null value from DB event though it's there

Post by someguyhere »

The code below gives me the following error: Warning: mysqli_error() expects exactly 1 parameter, 0 given in /home/efarrell/public_html/wp-content/plugins/wp-members-pages/members_page.php on line 46

Code: Select all

		$mysqli = new mysqli("localhost", "db", "pw", "user");
			$query = "SELECT * FROM wp_network_members WHERE f_name = $member[0] AND l_name = $member[1]";
			$result = mysqli_query($mysqli, $query) or die(mysqli_error());
			$member_data = mysqli_fetch_row($result);
The value for $member is Array ( [0] => Liz [1] => Barlowe ) and there is a row in the DB with the correct first and last name in the correct fields.

Any idea what is wrong here?
someguyhere
Forum Contributor
Posts: 181
Joined: Sun Jul 27, 2008 3:24 pm

Re: getting null value from DB event though it's there

Post by someguyhere »

solved:

Code: Select all

			$query = "SELECT * FROM wp_network_members WHERE f_name = '$member[0]' AND l_name = '$member[1]'";
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: getting null value from DB event though it's there

Post by Darhazer »

It have to be

Code: Select all

$result = mysqli_query($mysqli, $query) or die(mysqli_error($mysqli));
this will help you with the debugging next time :)
Post Reply