Beginner need help

Good day I’m trying to learn PHP but I’m having a hard time.

Doing a small test site and I was wondering if there is anybody that can tutor me please as I work through getting to know PHP.

I worked on my site the weekend and now ai have this error message that I don’t know how to resolve.Screenshot_20190902-072833_Chrome

If you expect any help, you should tell us why you think this message is wrong, or at least what you did and what you expected as a result.

Ok I will try and explain.

I have a form with values that is suppose to go to mySQL database when user click submit.

When I click submit that message shows and I don’t know why.

It is suppose to go to a page called totals.php

I’m lost and need guidance.

At least i would recommend that you connect to the internet and purchase the domain from someone, so you can access the files. As an alternative you could rewrite your local DNS and setup a local webserver so you have access to the machine and put files on it. But that machine from the screenshot clearly reports that the file you requested is just not there.

Thanks for reply,

I had it in local development yesterday and it worked 100%.

Then I made a copy for uploading to server and changed connection to database values and uploaded to web server.

Then I got that messages.

You say the error message means it can’t find the page it must go to?

Here’s the link to the site.

http://www.printassistant.co.za

I also have the code on github.

I tried and after posting a form i got a kind of timeout. It should help if you post some relevant code here (between code tags) so that we could take a closer look. Or you can debug your code yourself by placing some status messages or simple some random output so that you know if that part of code is still executed.

Hi frankbeen,

I see the values is going into the database but takes like 2 minutes to show on the totals page.
Why would that be?

Here is n link to my GitHub repo:

Thanks for the help

How many records are there in you totalstable table?

BTW it could be dangerous to put your database settings into your repository. You would better make an config.example.php without privacy details and add config.php to your ,gitignore file.

There is about 10, very little so I don’t think it should take that long.

Any ideas why?

About the error message, that must be some path code that is wrong? Or what elelselelse could it be?

I changed my post above so pleas read the addition,

It looks like a server or network problem, sometimes the page shows up but most times i got a timeout,
Can you test on an other server?

That’s my localhost database config, the real one for server is on my pc.

Can somebody still use the local information?

I tried on pc here at work and only got the error message, no timeout.

I can try on a different server tonight to see if performance increases.

Is it possible that something in my code is making the delay?

Can somebody still use to he local information?

No as long as your db doesnt take connections from outside not. But be warned :wink:

Is it possible that something in my code is making the delay?

As far as i can see with < 100 rows in your database not. If more you should make a mandatory filter, pagination or use “Lazy loading”. This is because you are taking a whole table no matter how many records it are with your query.

I browsed through your code. The URL in the 1st post in this thread shows part of a filename that starts “Pri”. There’s no file in your project that starts with that name, which is why you are getting a 404 error. What is the URL and how are you invoking it?

Next, there are some serious security issues with this code, which may explain the unusual web site operation, and it should probably be removed from the live server until they are fixed -

  1. Don’t echo the raw $_SERVER[‘PHP_SELF’] value as this allows cross site scripting. To get a form to submit to the same page, just remove the action=’…’ attribute from the form tag.
  2. Don’t output raw database errors onto a live web page, i.e. your connection error handling. This gives hackers your connection username and server path information when they intentionally trigger errors, i.e. too many connections in this case. Instead, use exceptions to handle database statement errors (connection, query, prepare, and execute) and in most cases let php catch the exception, where it will use its error related settings to control what happens with the actual error information (database errors will get displayed or logged, the same as php errors, just by changing the php display_errors and log_errors settings when going from development to a live server.)
  3. The …escape_string() functions only provide protection for ‘string’ data and only when the character set that php is using is the same as your database table’s character set. You are using the …escape_string() function on two identifiers, where they will not prevent sql injection. Instead, use a prepared query when supplying external/unknown data to an sql query statement. Using a prepared query will simplify the php code (eliminates the …escape_string() calls) and simplifies the sql query syntax (all the extra quotes and concatenation dots are removed.) Unfortunately, the mysqli extension is overly complicated and inconsistent, especially when dealing with prepared queries, and you should switch to the much simpler and consistent PDO extension.

Hey phdr, thanks for taking the time to reply.

I see what you mean by the URL problem, probably some typo I can fix.

Thanks for the tip on keeping action empty for a page that submits to itself.

The other pointers I will have to research tonight as I’m not sure about what is is but I kinda get the idea.

Will remove the site from server tonight until I can get all issues fixed.

Will also have to read up on PDO

Sponsor our Newsletter | Privacy Policy | Terms of Service