Jump to content

Really odd mysqli_fetch_array behaviour


Minklet

Recommended Posts

I think I put this in the wrong forum, as it seems to be more of a php problem (I think)

 

 

I'm trying to populate a profile page with information from the database. Really bizarrely, every $row variable that isn't null returns as 'website', which is the database username. I have absolutely no idea why this is.

 

It might be worth noting I have just changed hosts...the only thing I can think might make a difference. Any help would be great, thankyou

 

 

$query = "SELECT * FROM member WHERE username='$member'";
$result = mysqli_query ($dbc, $query) or trigger_error ("query: $query\n<br />MySQL Error: " . mysqli_error($dbc));

if ($result) {

while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {

	$member_id = $row['member_id'];
	$username = $row['username_id'];
	$photo = $row['photo'];
	$about = $row['about'];
	$slink = $row['soundcloud_link'];
	$mlink = $row['mixcloud_link'];
	$flink = $row['facebook_link'];
	$dlink = $row['divshare_link'];
	$mylink = $row['myspace_link'];
	$plink = $row['postbocks_links'];
	$website = $row['personal_website'];
	$type = $row['member_type'];
	$status = $row['status'];


}


}

}

 

 

I've echo'd the $query and put the result into sql directly and it comes out fine.

Link to comment
Share on other sites

Try this:

$query = "SELECT * FROM member WHERE username='$member'";
$result = mysqli_query ($dbc, $query) or trigger_error ("query: $query\n<br />MySQL Error: " . mysqli_error($dbc));

$row = mysqli_fetch_array($result)

// List out your variables here

// Then somewhere you can echo them out to format your page.

 

 

Link to comment
Share on other sites

Array

(

    [member_id] => 1

    [member_firstname] => Michael

    [member_lastname] => Mallett

    [member_dateregistered] => 2010-08-05 11:05:25

    [password] => cca961192cdfac00b66a8e2ad9337ad9250ab11f

    [username_id] => Shiverman

    [activate_code] =>

    [photo] =>

    [fb_userid] =>

    [fb_proxiedemail] =>

    [about] =>

    [soundcloud_link] =>

    [facebook_link] =>

    [divshare_link] =>

    [mixcloud_link] =>

    [myspace_link] =>

    [postbocks_links] =>

    [personal_website] =>

    [member_type] => 1

    [status] => 1

    => Mike@Generalpie.com

    [active] =>

)

 

 

So it's kicking out the right values...

Link to comment
Share on other sites

It's actually nothing to do with the sql query. I've just tried putting a string into the variables and it is still coming up with 'website'. If it's not the database username then I have no idea what it is.

 

It echo's the correct values when it is inside the if ($result) braces, so it seems to be a scope thing...is this a php setting?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.