Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,120 members, 7,818,361 topics. Date: Sunday, 05 May 2024 at 01:34 PM

Php Array_unique Error - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Php Array_unique Error (1079 Views)

How Do I Fix "Player.exe Has Stopped Working" Error Message. / Invalid Security Token Error 403 Blogger Template / Php Header() Function Error (2) (3) (4)

(1) (Reply) (Go Down)

Php Array_unique Error by Dlastofmykind(m): 10:18am On Jul 02, 2014
I really need the help of php gurus.
I'm having a problem with php array_unique function.
This is what I'm trying to achieve.
I'm currently developing a web application called students information management system using php and mysql.
So, I added a courseform feature to it whereby admin can insert courseform details of each level and dept into the db.
I created a table called courseform in d mysql db and d fields that r dia are:
id, code, title, unit, nature, level , dept.

This is how the interface looks like:

There is a field to be filled. i.e the admin has to enter the number of courses to be added.
Then, underneath it, is the department and level which have been fetched frm d db and displayed in a dropdown menu.
So, take for instance, the admin input 5 in the number of courses field and he selected medicine as the department and 300L as the level and he click on the submit button.
He'll be re-directed to the next page where 5 rows wil be displayed each for the course code, unit, title, nature fields.
The admin has to fill those fields, then click on the submit button to insert it into the db.

Then, I wanna view the courseform details for each levels and dept by fetching all the levels dt is in level field of dt courseform table without repeating any levels more than once in d sense dt if there is a courseform details that has been inserted for electrical engineering dept , chemistry dept, pharmacy dept and accountancy 100L - 500L each, normally if i wanna fetch and display d levels only, going by d above illustration, wat sud b displayed is 100L - 500L 4 times bt wat I want it to display 100L, 200L, 300L, 400L, 500L ONCE without repeating any level more dan once.

I fetched all those levels frm d db using mysql_fetch_array function, using a while loop.
Then, I declared a variable for an empty array using array() function.
then I push each Levels insyd dt empty array using array_push and finally i declared another variable called $array_unique and I used array_unique to remove all duplicate levels.
but when I print dt $array_unique.....
It displayed array_unique expects parameter 1 to be array, string given on line 259.
Line 259 is where array_unique was used.

Please what do u think d problem is and whats d likely solution?

THANKS!
Re: Php Array_unique Error by Nobody: 12:54pm On Jul 02, 2014
zz
Re: Php Array_unique Error by Nobody: 6:24pm On Jul 02, 2014
Trolls inside the thread and sits on the fence
Re: Php Array_unique Error by okrobo: 6:46pm On Jul 02, 2014
Sorry I dnt knw wht ur questn is, but frm d little I can get u can select distinct(unique) values from a mysql table using "Select distinct" in ur mysql query which does the same as array_unique php function.
Maybe that shld help.
Re: Php Array_unique Error by curiouslad(m): 12:51am On Jul 03, 2014
Dlastofmykind:
I fetched all those levels frm d db using mysql_fetch_array function, using a while loop.
Then, I declared a variable for an empty array using array() function.
then I push each Levels insyd dt empty array using array_push and finally i declared another variable called $array_unique and I used array_unique to remove all duplicate levels.
but when I print dt $array_unique.....
It displayed array_unique expects parameter 1 to be array, string given on line 259.
Line 259 is where array_unique was used.

Please what do u think d problem is and whats d likely solution?

THANKS!

Try print_r ing out the empty array you created to be sure you of what you are passsing.
Also show some code =>Pastebin.com
Re: Php Array_unique Error by Dlastofmykind(m): 4:41pm On Jul 03, 2014
select distinct worked..
bt wat if i dnt wanna use dt bt wanna use array_unique?

(1) (Reply)

Happy New Year To All Programmers In Nairaland / Semi-final Mr. NAIRALAND Contest 2016 - Vote Vizkiz / The Best Way To Create A Module In Magento 2

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 17
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.