Jonnie Grieve Digital Media: Website Blog.

Archived Posts: Databases Archives – Jonnie Grieve Digital Media posts.

Websites and interacting with databases.

So in recent weeks my learning attention has switched from Java to PHP.

When I was doing my HNC (Higher National Certificate), a couple of years before I started my degree I was faced with a challenging individual project. It was a very difficult time and a crossroads in my academic life. I faced failure and learning how to pick myself up again. The project I spoke of involved learning how to connect a website to a database.

During my project. I had a project tutor. Every week he would ask me about something called a “confidence test” which was a very particular particular process referring to making a successful connection to a database.  I did try but I could never manage it. And it transpired I was trying to do something I had no experience in doing from my course.

In the project I ended up doing have to attempt in the end and bizarrely, it was the only module I ended up passing in my HNC but I failed that year. I had to take that hit and try again the next year.

Fast forward nearly a decade and I did pass my HNC in the end; I did go on to get a Higher National Diploma; I did get my degree.  And I have gone onto tackle database connections again. This time I have made successful connections and my “confidence” in that regard has increased.

I am now learning how to create webpages that interact with databases in different ways. creating records, reading data, updating those records and deleting them. In other words all the basic interactions with data that fall under the term CRUD. Create, Read, Update, Delete.

Today, with a bit of painstaking research I solved a major problem that was holding my back in a small personal development project.

I was so sure that I was following the video tutorial to the letter but there was just one or 2 little differences in my code that caused the bugs.

Imagine a simple web page with a drop down box, which is a form element and a button that is going to bring up a report based on data that lives in a database.  There was a problem in that no data was being return but I kept getting this PHP notice on the page.

So somewhere along the line not all the data, (or none of the data at all was being retrieved and passed to the function. Eventually I traced the issue to 2 small typos.

The first thing was I needed include the colon in my first echo string for the option value. I’m not sure what makes that work but I think it’s something to do with the query string. Not having it meant a property wasn’t carried over causing the offset warning.


So now when I tested the form I was getting this query string in the URL.

But having solved one problem, it seemed report wasn’t generating any tasks or totals when I tested the drop down. With a keen eye, I noticed that the query string wasn’t carrying a last number in the URL; the number identifying an individual record which is a project ID.

I traced the problem to the same function. One of the things about working with soft and hard quotes is knowing when to use them and in what combination. It seems like I trying to apply a hard quote into the reference to the project ID even though this was concatenated in.

So another day passed and a new learning experience. Now, database connections aren’t such a mystery and are not so daunting. Hopefully I’m going to learn a few more things about CRUD too.