...

View Full Version : AIM Profile



th3gh05t
05-25-2004, 10:10 PM
Hi,

I am really into making my own AIM profile.

You can check it out.. AIM: w0lverne

Anyway, I need some help with some code.

I have this code, that gets the users screenname, time and date, and IP address. The screenname and IP are correct but I get this error everytime I view the page.


Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/derek/www/profile/aim.php on line 45<br />

Here is the code that I using:


<?php
// AIM Automatic-Answering Machine/Logger v1.0
//
// Code in your aim profile should look like this:
//<A HREF="http://www.halo-source.com/aim.php?T4=%n"
// TARGET="_self">Click Here</a>
//


// get user's IP Address
$userip = getenv("REMOTE_ADDR");

//mysql information
$dbusername='derek';
$dbpassword='*********';
$hostname='localhost';
$databasename='aim';

// connect
$link1 = mysql_connect($hostname, $dbusername, $dbpassword);

//get db
if (!mysql_select_db($databasename, $link1)) {
echo "error with db";
exit();
}

// get current time and date
$time1 = date("h:i a");
$date1 = date("d/m/Y");

// sql statement to insert values
$addstmt = "Insert into tablename(ip, time, date, screenname) values('%s', '%s', '%s', '%s')";

// code in case there is an error inserting
if (!mysql_query(sprintf($addstmt, $userip, $time1, $date1, $T4), $link1)) {
$flag1 = 1;
}

// sql to check to see how many times the user has viewed the profile
$result = mysql_query("select * from aimlist where screename = '".$T4."'");

// count the number of recs
$countthis = 0;
while ($row = mysql_fetch_array($result)) {
$countthis = $countthis + 1;
// you can do other things in here as well
// such as print out all the dates and times the user has viewed
}
// now print out the personalized message for each user
// you can easily put this in another table
// this will be done in the next version

echo "<BR>You have looked at my profile ${countthis}";
echo "times.<BR>";
echo "Screenname: <b>${T4}</b><BR>";
echo "IP: <b>${userip}</b><BR>";
echo "</body>";
echo "</html>";

?>

This is what I get when I click on the link in my profile. It almost works... :(


<br />
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/derek/www/profile/aim.php on line 45<br />

You have looked at my profile 0times.
Screenname: w0lverne
IP: 24.199.6.***

You can see that the "You looked at my profile X times.", isn't working either..

I got this code from evilwalrus.com. There were many mistakes in the code, that I have had to fix. But it isn't perfect yet. I think that I need to create a table into the database. But I am not sure what to name it, what fields to have in it.

If you could provide some code, that would be great!

Thanks, th3gh05t

th3gh05t
06-09-2004, 06:38 PM
Freedom is never free.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum