Jump to content

Barrikor

Members
  • Posts

    14
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Barrikor's Achievements

Newbie

Newbie (1/5)

3

Reputation

  1. Not completely true, While Javascript is the only way to dynamically stop a form from sending at all, there's another method using PHP where you compare a token or nonce to a value in the session and then just don't process it if it's a repeat.
  2. expecting ',' or ';' normally means that you missed a ; in the line before it tells you. look at the end of: echo "I'm about to learn PHP!<br>"
  3. Just change: "select * from news where category='gamereview' order by topic ASC" To: "select * from news where category='gamereview' order by topic ASC LIMIT $limit OFFSET $offest" Where $limit and $offset are set by: $current_page_number = 1; // for example $limit = 15; $offset = $limit * ($current_page_number - 1);
  4. Maybe what you'll want to do is just change the folder PHP includes files from? If you're running a PHP file in folder1/folder2/folder3 then PHP is looking for files from folder3's location, which I doubt is what you really want. You probably want to change the running directory to the folder that your folder1 is in. The function for that is chdir(). http://php.net/manual/en/function.chdir.php so if you're 3 folders up from where you want to be, chdir() down 3 folders: chdir('../../../'); Now your includes should all work the way you wanted on your post: include 'folder1/folder1file1.php';
  5. Not that I disagree with you on everything, but every method/practice was created for a reason. Overuse of any aspect of programming is bad... the code should have a healthy balance.
  6. In real life you'll want to be displaying a message on screen, maybe a "Sorry, Try Later" message to the user instead of using die() For testing you'll want to see what the error was, so that you can fix it. Maybe something like this: $resultHandle = $databaseHandle->query("CREATE DATABASE $database") if(resultHandle) { //Stuff to do if the query looks like it worked } else { // Stuff to do if the query failed print 'Error Description: ' . $databaseHandle->error . '----------- Error Number: ' . $databaseHandle->errno; } Also, for your current error, the most common reason for a CREATE DATABASE query to fail is for the database "user" to not have the permission set to allow it to create new databases.
  7. Just swap it to a capital H and you get the 24 hour time =) Edit: or 'G' if you want to get rid of the leading zeros.
  8. Use array_unique() ? http://php.net/manual/en/function.array-unique.php
  9. - Global variables are the normal variables in your PHP file not hidden inside a function or class or array. - Session variables are for saved to the session and passed between pages for the same user only. - ​If you want variables that are on every page for every user, put the variables in a PHP file and include() them, or include_once(), if you want an error to happen if that file fails to load use require() or require_once() - Anything more complicated then that, look at using a database
  10. Looking at your files, it looks like converting directly between the Gregorian Calender (in English) and the Nepali Calender, is a lot of hard work... If you aren't going to use any dates before 1970, what about using the Unix Timestamp, like in PHP's time() function? Then you can just store the date in the database as an integer, and you'd convert the timestamp into dates in both calenders
  11. Normally the site developer will have a pre-made database table with columns for zip/postal code, latitude, longitude, city, state/provence, country; so that they can find what zip codes are next to each other. Then they make another table for all the company's locations. The search just takes the zip code center latitude-&-longitude, and sorts the company locations by the distance to the original zip code center latitude-&-longitude. Looking at it, I think the Starbucks site in particular is just using one of Google's API's, maybe this --> https://developers.google.com/maps/articles/phpsqlajax_v3?hl=en-EN&csw=1 ?
  12. Have a $totalOfTotals variable that you add to on each fetch. (Assuming that you need to also display the data at the same time)
  13. After you run the query, see if $query === false
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.