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

  • Home
  • SEARCH
  • 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 8397775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:52:43+00:00 2026-06-09T20:52:43+00:00

I have three php arrays that i am filling up with information returned from

  • 0

I have three php arrays that i am filling up with information returned from a msql query. The first two arrays fill up perfectly with the information need but the last array does not fill up. The only thing that gets entered is a ‘v’. It works perfectly if i don’t make it an array and just a single value but when i make it an array it stops working. If you have any ideas thanks.

$query = mysql_query("SELECT * FROM chanels WHERE cname = '$cname' ");
$numrows = mysql_num_rows($query);

while($row = mysql_fetch_array($query))
{
    $videolocation[$counter2] = $row['videolocation'];
    $title[$counter2] = $row['title'];
    $imagelocation[$counter2] =  $row['videoimagelocation'];
    $counter2++;

}

ImageLocation array is the one that does not work while the other two fill up perfectly. I have checked spelling and everything is entered perfectly.

  • 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-06-09T20:52:44+00:00Added an answer on June 9, 2026 at 8:52 pm

    Instead of using fetch_array use mysql_fetch_assoc for your method so that you bring back the rows with keys in the array named as the columns in the results – like this:

    while ($row = mysql_fetch_assoc($result)) {
        echo $row["videolocation"];
        echo $row["title"];
        echo $row["videoimagelocation"];
    }
    

    Also, you should probably move away from the old mysql_* functions and tinker with the new shiny PDO functions. These will let you connect in a much safer manner as well as providing much more flexibility.

    Edit: When you bring back an assoc array, it is still a single row of the database. However, your current code returns something like this:

    $row[0]='someLoc' // Data from videoLocation
    $row[1]='someTitle' // Data from title column
    $row[2]='someImageLoc' // Data from videoImageLocation
    

    And Assoc Array will work like this:

    $row['videolocation']='someLoc' 
    $row['title']='someTitle' 
    $row['videoimagelocation]='someImageLoc' 
    

    Edit 2: It seems that I chased down a bit of a red herring with the array vs assoc issue. The first thing that I could check is the spelling, but you have done that, the next is check the case of the column names. On windows, the case is by default not important, but on Linux machines it is.

    I find the easiest way is to do this:

    mysql_query("SELECT videolocation, title, videoimagelocation FROM chanels WHERE cname = '$cname' ");
    

    If a column is the wrong case, this should return an error for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating JSON encoded data from PHP arrays that can be two or three
I have three PHP arrays that I've encoded with json... extra PHP code has
Lets say I have the following two PHP arrays that contain integers: $foo =
If I have three files index.php file.php and fns.php First example (it works): index.php
I have three files: one called sql.php witch has a class db that I
I have three files in a folder 'test' one.php two.php print.html And i have
i have three arrays in php script $arr1=(a,b,c) //(1,2,3) $arr2=(d,e,f) //(4,5,6) $arr3=(g,h,i) //(7,8,9) note
I have a bunch of php arrays that look like this (please don't ask
PROBLEM I have a nested PHP array that I need to populate from flat
I have a few arrays that I want to send to process with PHP.

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.