PDA

View Full Version : What's wrong with this?



tbh imo no m8
25-04-2006, 09:12 PM
<?
ob_start(); // allows you to use cookies
$conn = mysql_connect("web10.mysql.000025.net","dan_user","abc123");
mysql_select_db(DATABASE NAME) or die(mysql_error());
//fill in the above lines where there are capital letters.
$logged = MYSQL_QUERY("SELECT * from users WHERE id='$_COOKIE[id]' AND password = '$_COOKIE[pass]'");
$logged = mysql_fetch_array($logged);
//the above lines get the user's information from the database.
?>

That is what i have and this is what it is based around


<?
ob_start(); // allows you to use cookies
$conn = mysql_connect("localhost","DATABASE USERNAME","DATABASE PASSWORD");
mysql_select_db(DATABASE NAME) or die(mysql_error());
//fill in the above lines where there are capital letters.
$logged = MYSQL_QUERY("SELECT * from users WHERE id='$_COOKIE[id]' AND password = '$_COOKIE[pass]'");
$logged = mysql_fetch_array($logged);
//the above lines get the user's information from the database.
?>
What am i doing wrong?

zainx
25-04-2006, 09:20 PM
Keep it Localhost

tbh imo no m8
25-04-2006, 09:22 PM
All my other db's use that host?

Parse error: parse error, unexpected T_STRING in /usr/home/dan/public_html/config.php on line 4

Thats all i get :'(

MattUH
25-04-2006, 09:32 PM
lol why show us your password, all we need to do is find out your site your doing this too =]

tbh imo no m8
25-04-2006, 09:36 PM
Why what can you do? Anyway thats just my database password? See what is wrong?

Steven.
25-04-2006, 09:40 PM
Have you tested it with what zainx said?

tbh imo no m8
25-04-2006, 09:49 PM
Yea i noticed what as wrong lol i didn;t edit this bit

mysql_select_db(DATABASE NAME) or die(mysql_error());

Now i have this



Warning: Cannot modify header information - headers already sent by (output started at /usr/home/dan/public_html/index.php:2) in /usr/home/dan/public_html/login.php on line 43

Warning: Cannot modify header information - headers already sent by (output started at /usr/home/dan/public_html/index.php:2) in /usr/home/dan/public_html/login.php on line 44
Thank You! You will be redirected

And this is the file for them lines


setcookie("id", $user[id],time()+(60*60*24*5), "/", "");
setcookie("pass", $user[password],time()+(60*60*24*5), "/", "");
// the above lines set 2 cookies. 1 with the user's id and another with his/her password.

Arisham
25-04-2006, 09:58 PM
Dude, put this:


<?
ob_start();
include('config.php');
?>

AT THE VERY TOP OF YOUR FILE! LINE 1!
It is so important you do that so the cookie information can be sent successfully.

Then, remove


ob_start();
include('config.php');

from the original code.

tbh imo no m8
26-04-2006, 09:33 AM
Yea it works now i knew what was wrong :).

Sygon.
26-04-2006, 02:47 PM
Dude, put this:


<?
ob_start();
include('config.php');
?>
AT THE VERY TOP OF YOUR FILE! LINE 1!
It is so important you do that so the cookie information can be sent successfully.

Then, remove


ob_start();
include('config.php');
from the original code.

Exactly what he said.

D3stroyer
26-04-2006, 02:57 PM
Exactly what sygon said he said :D

Daza

Want to hide these adverts? Register an account for free!