Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Nice Profile URL? Re: Nice Profile URL?

#96006
bungle
Member

Couple of different points for you

In the middle of this you have a series of queries run one after the other using a while loop to and mysql_fetch_assoc each time to fill a variable

You can fill all of these with a single query and mysql_fetch_array()

So instead

$result = mysql_query(“SELECT info,email,img FROM husers WHERE id = $id”);
$userinfo = mysql_fetch_array($result);
$info = $userinfo;
$email = $userinfo;
$img = $userinfo;

will save you running multiple queries

Also, be careful when including variables in query statements

PHP will substitute in variables only inside double quotes

So $sql = ‘SELECT * from users where id = $id’;

will not work, instead you need

$sql = “SELECT * from users where id = $id”;

or

$sql = ‘SELECT * from users where id = ‘.$id;

and if you need to include a string rather than an integer then you need to quote that string inside the sql statement

so $sql = ‘SELECT * from users where username = “‘.$uname.'”‘;

will result in an actual query of SELECT * from users where username = “john” or whatever

Make sense?