Jump to content

Recommended Posts

HI all,

 

I am a self taught PHP / MySQL programmer and I learned from trial and error (editing scripts) then went on to writing them. Anyway I wont give you my life story but the point I am getting at is when I make scripts I don't know why I am putting code their, I just know to do it.

 

I have just started a new project and I have been using PHP variables in queries as shown below:

 

$query_string = "SELECT `username` , `password` FROM `accounts` WHERE `loginname` = '".$user."' LIMIT 1";
$query = mysql_query($query_string)or die("Error: ".mysql_error()."<br /><br />In File: ".__FILE__."<br /><br />On Line: ".__LINE__);

 

I was just wondering is this really necessary as it is quite annoying to do to be honest.

 

If not what is the best way to do this?

 

Thankyou for all replies.

Well earlier in the script I have the mysql_real_escape_string to all variables that are going into queries and in this case the login-name and password are encrypted using md5(); then the username is fetched from the database to start the session.

 

Also I am not familiar with the proper functionality of sprintf(); what does it do exactly.

 

Also thanks for the help guys :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

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.