Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-25-2004, 10:10 PM   PM User | #1
th3gh05t
New to the CF scene

 
Join Date: Apr 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
th3gh05t is an unknown quantity at this point
AIM Profile

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.

Quote:
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 Code:
<?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...

Quote:
<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 is offline   Reply With Quote
Old 06-09-2004, 06:38 PM   PM User | #2
th3gh05t
New to the CF scene

 
Join Date: Apr 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
th3gh05t is an unknown quantity at this point
Freedom is never free.
th3gh05t is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:11 AM.


Advertisement
Log in to turn off these ads.