WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1]
SELECT rating_username, rating_rating, rating_ip FROM wp_ratings WHERE rating_postid =

Creating the database for your PHP & MySQL login script

Vote This Post DownVote This Post Up (+2 rating, 6 votes)
Loading ... Loading ...

PHP & MySQL Login Tutorial Series
Pt1: Introduction
Pt2: Setting up the database
Pt3: The front end and user validation
Pt4: The code to privatize a page
Pt5: Logout function and clearing the session ID

Part 2: Creating the MySQL database

Before we get to programming, let’s setup the databases. You will need to create two different tables—one for user accounts and the other for sessions. Setup the tables as follows:

Table name: user_accounts
Field 1: userid, int(10), primary key, auto_increment
Field 2: username, varchar(10)
Field 3: password, varchar(32)

Field 1 will store our user id number and will be a primary key for unique user identification. Field 2 is our username with a maximum of 10 characters. The number of characters can be set at whatever you’d like. Field 3 is our password field and, for this example, needs to be a minimum of 32 characters. You can use a larger size, however all passwords will be 32 characters in length.

Table name: user_sessions
Field 1: sessionid, varchar(32), primary key
Field 2: userid, int(10)
Field 3: timestamp, int(12)

Field 1 will store our temporary session id and must be 32 characters as well as a primary key. Field 2 is our user id and its size must be equal to the size you selected in the user_accounts table. Field 3 is our time field. There are several ways to store a time in a database, however we will be storing the Unix timestamp.

Next -> Front end + User validation

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • Reddit
  • Webnews
  • MisterWong
  • Y!GG

Leave a Reply

You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <blockquote cite=""> <code> <em> <strong>