₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,152 members, 8,420,575 topics. Date: Friday, 05 June 2026 at 03:19 AM

Toggle theme

Php Array_unique Error - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingPhp Array_unique Error (1165 Views)

1 Reply (Go Down)

Php Array_unique Error by Dlastofmykind(op): 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:
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(op): 4:41pm On Jul 03, 2014
select distinct worked..
bt wat if i dnt wanna use dt bt wanna use array_unique?
1 Reply

How Do I Fix "Player.exe Has Stopped Working" Error Message.Invalid Security Token Error 403 Blogger TemplatePhp Header() Function Error234

PHP Interactive (learn And Teach)VIP Dating AppJavascript