[SOLVED] Trying to get property of non-object |
[eluser]Brandt1981[/eluser]
Hello, The textbox will have no value when the page is loaded, but when a query is done, the textbox value should be set to the database value returned. I am using Doctrine. I need help with the following code: Controller home.php: Code: class Home extends Controller { View home.php: Code: <?php echo form_open('home/query'); echo form_input('query', 'ID#'); echo form_close(); ?> Hope you can help!
[eluser]kaejiavo[/eluser]
Hi, you can use doctrine hydrate array (HYDRATE_ARRAY) to achieve this. Code: $employee['pk_emp_id']
[eluser]Brandt1981[/eluser]
ok. I read the link, but don't understand (I'm also tired)..i'm not much of a coder. Would you be able to show me using my code from above? EDIT: I changed it to this: Code: <p> And now get this error: Message: Uninitialized string offset: 0
[eluser]kaejiavo[/eluser]
Try it like this: Code: //Controller As i dont know what you really want to do with your code, this is possibly not the best way to do it with doctrine. It is just a way to get rid of the error you get by accessing empty object variables.
[eluser]Brandt1981[/eluser]
It needs to to be in the index function, as the code works fine when there is a post to query. Only when the page first loads and the text boxes are empty is when I get the errors..
[eluser]kaejiavo[/eluser]
[quote author="Brandt1981" date="1287400495"]It needs to to be in the index function, as the code works fine when there is a post to query. Only when the page first loads and the text boxes are empty is when I get the errors..[/quote] Yes, you are right. In the index() function you set your variables to '' so $employee is a string. In your view you try to access a property $employee->pk_emp_id which is simply not there.
|
Welcome Guest, Not a member yet? Register Sign In |