Jump to content

CRUD basics with Mysqli & PHP part2: undefined property error.


Recommended Posts

Hi I've been typing along with this and in part 2 I'm getting the error below:

Notice: Undefined property: stdClass::$lastname in C:\MAMP\htdocs\CRUD-my-php\view.php on line 27

This repeats 5 times on the page once for each row. The table displays as it should below these 5 errors except for the "lastname" column which is blank except for the heading. As I copied and pasted the code for the "id" row as suggested in the video I'm at a loss as to where the error is?



The code for this section is below as I've typed it:



It dosesn't look any less baffling in big letters.  I'm working with Windows 10 in Sublime text 3.

That's it for I'm done for today, time for a cuppa and to descend upon this packet of ginger nuts like Atilla and the boys on a day trip to Rome.   



Link to comment
Share on other sites

Hi fra168nk, 

Thanks, it did indeed help. I've been over that line 27 numerous times but you're asking that question made me look at it differently.

It was a typo alright, though not in the sublime text doc, it was in the column name in phpmyadmin. I had it headed "second name"! I never thought to look at that. That'll be another part of the mental map of how things work hammered into place.  

This has caused no end of doubt and anguish so thanks again 😀 

Link to comment
Share on other sites

Not the first and I'm sure not the last time I'll be reminded of that and I'm grateful for all these reminders, they help to maintain some perspective.

I'm beginning to think that bloody minded stubbornness might be the most important character trait for anyone trying to get into this field.

10 hours ago, administrator said:

Welcome to programming! 😀

Is the Buddha's "Life is suffering" paraphrased for nerds. 

Link to comment
Share on other sites

PS. Hi Stef, a final note on this project. I wasn't able to get the "Add record" function to work even if I did a clean download of the project files and loaded them instead of the ones I'd done working along to the videos. Do we have a bug somewhere in the works? 

Link to comment
Share on other sites

  • 2 months later...

How can this be corrected then? I've started everything from the very beginning again right back at HTML because the resolve evaporated along with the daily routine and whilst I hadn't given up I'd stopped. And continued being stopped. So when I hopefully pass this way again in a bit how is this problem to be solved, if it can be on my end?

Also while I'm grateful for the response, it's almost 2 months between question and response (not answer but response). I like your courses even if some videos are a decade old, the structure and the thought that went into them initially was well done.

The forums however let things down badly. Taking a few days to answer is one thing, though if it's a critical question it can hold up/disrupt someone's entire study regime, but this length of time is poor. This is a crucial issue you need to address with some urgency Stef because I know it's not only me that's frustrated by this element of things.

Link to comment
Share on other sites

Hello Jim,

I understand your frustration.

I was able to get through and understand the CRUD basics course.

Yeah, 2 months is a pretty rough response time.

I assume you've repeated the CRUD course a few times. 

If you haven't tried this already, I'd put your code in difchecker (https://www.diffchecker.com/) alongside the code you can download from the course.  What I do is find a section that is probably giving trouble - it may be small.  I'll copy the code I've written, and then copy the correct course code and paste it alongside one another.  I tend to do this only after I've conceptually understood the concepts - but something just isn't working right in code.  What usually happens is that I've missed a quotation mark or a paranthesis.  Difchecker finds where the difference is.

If there are no differences in your code (and this happened to me before), I find that my database connection may be to blame (the database password may be different for some users depending on what computer they use: mac or pc.  my password is 'root' - others' password is just this: ''.)

  • Like 1
Link to comment
Share on other sites

Hi Drew thanks for your help, I wasn't aware of diffchecker it'll be useful when I get to the CRUD basics again, and all sorts of other places too I'm sure. I've gone back to year zero course wise, to Beginners HTML and intend to repeat it all. I wasn't racing at top speed but I think there was an element of wanting to get through things rather than actually properly studying. Too busy thinking about arriving to appreciate the journey.

Working in corporate travel I've been expecting the flush go anytime this year, which it did this month. A focus on escape was never the best mindset for exploring something new and the course content's something I can enjoy with the right approach. I guess 2021 will be a personal "Great Reset" in more ways than one.     

The last unit I was doing before restarting was the Wordpress theme one, but with no history of using any image manipulation programs/apps it was tough going learning Gimp before I could get fully stuck into it. I've had a much underused Wordpress site of my own for several years so Wordpress seems a natural direction (the Basic Wordpress unit felt weird being on the same geek level as the tutor).   

So being honest the frustration has more than one root.

Thanks Drew for the time you took as much as the advice itself, it's appreciated.



Link to comment
Share on other sites

Yeah, I think it's all about constant practice - which can be tough given there are several coding languages.

I've been told that young monks re-read holy texts tons of times in order to memorize them.  So, perhaps taking this course once is good, but maybe not enough to reinforce everything to a master degree.

  • Like 1
Link to comment
Share on other sites

That's true re the constant practice, and I like the monastic analogy. The master level of knowledge may be a stretch, or may not, but reaching a level of competence that gives confidence enough to make a living from these skills would be an achievement in itself.

I need to pay less attention to external uncertainties too such as Covid, Brexit, and in Scotland the threat of a hostile UK government. This isn't really the place for politics so i'll stop there. One thing I'd like is to get to the end of 2021 and think, well that was a bit too beige.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...