Cannot return from function

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 1
Joined: Fri Mar 31, 2017 1:09 pm

Fri Mar 31, 2017 1:25 pm


I have a school assignment where you are supposed to create functions that will return values to a premade driver-class called "StudentRegister.php". We are not supposed to change any values in the driver-class (picture number three), only in the function.

I've been trying to create a a function that will return single students for almost three days now, but it still won't work. Does anyone know what I'm doing wrong? Could anyone explain how the driver class communicate with my function? I don't even quite understand what I'm supposed to return..

I really appreciate your help! :D
Skjermbilde 2017-03-31 kl. 23.12.38.png
Skjermbilde 2017-03-31 kl. 23.12.38.png (58.63 KiB) Viewed 1405 times
Skjermbilde 2017-03-31 kl. 23.11.59.png
Skjermbilde 2017-03-31 kl. 23.11.59.png (33.51 KiB) Viewed 1405 times
Skjermbilde 2017-03-31 kl. 23.11.48.png
Skjermbilde 2017-03-31 kl. 23.11.48.png (51.9 KiB) Viewed 1405 times
User avatar
php-forum GURU
php-forum GURU
Posts: 998
Joined: Mon Feb 22, 2016 5:52 pm

Fri Mar 31, 2017 3:59 pm

If you want to return a value from a function, you need to use the return keyword.
php-forum GURU
php-forum GURU
Posts: 622
Joined: Fri Aug 05, 2011 9:53 am

Sat Apr 01, 2017 12:00 am

With your function, you are preparing the SQL statement, but not fetching the results. So have a look at how to do this and as hyper points out, these values then need to be returned from your function.
Post Reply