Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7487829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T14:40:00+00:00 2026-05-29T14:40:00+00:00

I am getting this: Array ( [0] => 1 [id] => 1 [1] =>

  • 0

I am getting this:

Array
(
[0] => 1
[id] => 1
[1] => 778613c4344dbc9565c359c1154c6a18
[session] => 778613c4344dbc9565c359c1154c6a18
[2] => fn
[first_name] => fn
[3] => ln
[last_name] => ln
[4] => un
[username] => un
[5] => 016e6128e8ca9dda1b310c364d9b622c
[password] => 016e6128e8ca9dda1b310c364d9b622c
[6] => address
[email] => address
[7] => 100
[permission] => 100
[8] => 10
[year_level] => 10
[9] => 
[department] => 
[10] => Sample
[campus] => Sample
[11] => 0
[logo_url] => 0
)

After running this

$user = mysql_fetch_array(mysql_query("SELECT session FROM users WHERE username='$cookie[username]' AND first_name='$cookie[first_name]' AND last_name='$cookie[last_name]' AND campus='$cookie[campus]' AND id='$cookie[id]'")) 

Any ideas why it is duplicating like this? Thanks

EDIT: I think the primary key is doing this. Any idea on how to stop it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T14:40:01+00:00Added an answer on May 29, 2026 at 2:40 pm

    If you don’t specify a result type as a second parameter, mysql_fetch_array() will default to MYSQL_BOTH (quoting) :

    By using MYSQL_BOTH (default), you’ll get an array with both
    associative and number indices
    .

    If this is not what you want, you have to pass a second parameter to that function, to indicate what type of results you want.

    For example, to only get an associative array with columns names as keys :

    $result = mysql_query("SELECT session FROM users WHERE username='$cookie[username]' AND first_name='$cookie[first_name]' AND last_name='$cookie[last_name]' AND campus='$cookie[campus]' AND id='$cookie[id]'");
    $user = mysql_fetch_array($result, MYSQL_ASSOC);
    

    As a sidenote :

    • Make sure you are escaping the variables you inject into your query, to prevent SQL Injections, using, for example, mysql_real_escape_string()
    • Before using mysql_fetch_array(), you should test if mysql_query() was successful,
    • And, especially for a new project, you should use mysqli or PDO, and not the old mysql_* functions — see Choosing an API.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this piece of code which works 90% of the time: $user_details=$fb->api_client->users_getInfo($fb_user, array('last_name','first_name','proxied_email'));
So what's getting pushed to this array is dependant on a few radio boxes.
I keep getting this Magento error emailed to myself: URL: http://mysite.com/sendfriend/product/send/id/1/ IP Address: 66.249.65.69
Im getting this error message randomly: Index was outside the bounds of the array.
I keep getting this error: initializer-string for array of chars is too long Even
I am getting this data from JSON web services List ARRAY: ( { assets
I'm getting an Illegal offset type for this array: public static $CATS_AND_TYPES = array(
I'm getting this error ev.c:11: error: subscripted value is neither array nor pointer for
I am getting this error when i use a string array java.lang.NullPointerException The code
At the top using this $alert['new_msg'] i am getting this array. Array ( [0]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.