Forum Moderators: coopster
here is a piece of code where i want to store the users information from the database to valuables!
but the thing is that it generates this error instead
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/rickyb/public_html/up/toxinhead.html on line 15
here is my code..
PHP Code:
$result = mysql_query("SELECT * FROM users where username = $username");
while($data = mysql_fetch_array($result)){
$firstname = $data['firstname'];
$lastname = $data['lastname'];
$password1 = $data['password1'];
$email = $data['email'];
$gender= $data['gender'];
}
Thanks again
ricky
Parse error: syntax error, unexpected T_VARIABLE in /home/rickyb/public_html/up/toxinhead.html on line 14
Here is my code :
PHP Code:
<?php
//1. creating a connection
$connect = mysql_connect(localhost,user,pass);
if(!$connect){
die ("1. failed connecting ".mysql_error());}
//2. selting a database
$db = mysql_select_db("rickyb_bbs",$connect);
if(!$db){
die("2. failed connecting to database ".mysql_error());}
/////converting Username to a valuble, This cannot be changed
$placeholders = array("{username}");
$username = $placeholders[0];
//Finding out the other users information!
$result = mysql_query("SELECT * FROM users where username = '". $username ."' ");
while($data = mysql_fetch_array($result)){
$firstname = $data['firstname'];
$lastname = $data['lastname'];
$password1 = $data['password1'];
$email = $data['email'];
$gender= $data['gender'];
}
?>
Thanks