Jump to content

deepermethod

Members
  • Posts

    33
  • Joined

  • Last visited

    Never

Everything posted by deepermethod

  1. I scrapped my script altogether. I used your script, including creating the new table. All it shows is the offline image. I have the session_start(); at the top of each page and still only the offline image. When I look in the table in my database there is nothing there, it isn't getting inserted some how. Not looking for a script rewrite, just some advice.
  2. I'll keep looking at it. I did include <?php session_start();?> to the top of both pages and it still isn't working. Some how it isn't getting inserted into my database.
  3. Even if I am using the online.inc.php as an include?
  4. Well, I adjusted it to what I need and it initially worked (showed online image). When I go to another page and back to the page with the online.php script it shows the offline image. My code: <?php //Prevent the included file from being called directly. if(basename($_SERVER['PHP_SELF']) == "online.inc.php") { header("Location: /index.php"); exit; } $connection = @mysql_connect("$db_host", "$db_user", "$db_pass") or die("Couldn't connect."); $db = @mysql_select_db($db_name, $connection) or die("Couldn't select database."); $timestamp = time(); $timeout = $timestamp - 180; $mem_id = $_SESSION['member_id']; $rem_add = $_SERVER['REMOTE_ADDR']; $php_self = $_SERVER['PHP_SELF']; $sql=("SELECT * FROM $tbl_online WHERE id = $_SESSION[member_id]") or die("Error in user online result query!"); $count=mysql_num_rows($result); if($count=="0"){ $sql1=("INSERT INTO $tbl_online(id, timestamp, ip)VALUES('$mem_id', '$timestamp', '$rem_add')"); $result1=mysql_query($sql1); } else { $sql2=("UPDATE `tbl_online` SET count = count + 1 WHERE id = '$mem_id'"); $result2=mysql_query($sql2); } $sql3=("SELECT * FROM $tbl_online"); $result3=mysql_query($sql3); if(mysql_num_rows($result3)){ echo"<img src='./gr_image/online.jpg'>"; } else { echo"<img src='./gr_image/offline.jpg'>"; } echo $img; // if over 10 minute, delete session $sql4=("DELETE FROM $tbl_online WHERE timestamp<$timeout"); $result4=mysql_query($sql4); ?>
  5. Yes, I am in the process of adapting it to my needs. I just wanted to make sure that is what the code did.
  6. That looks good, but is that to count the number of users online? I was looking to show 2 different images - one if a user was online and another if the user was offline. Thanks
  7. So is this possible or should I just scrap the idea?
  8. Okay. I'm stumped. After doing some more searching, here's my current code (unfinished): <?php //Prevent the included file from being called directly. if(basename($_SERVER['PHP_SELF']) == "online.inc.php") { header("Location: /index.php"); exit; } $connection = @mysql_connect("$db_host", "$db_user", "$db_pass") or die("Couldn't connect."); $db = @mysql_select_db($db_name, $connection) or die("Couldn't select database."); $timestamp = time(); $timeout = $timestamp - 180; $mem_id = $_SESSION['member_id']; $rem_add = $_SERVER['REMOTE_ADDR']; $php_self = $_SERVER['PHP_SELF']; $result = mysql_query("SELECT DISTINCT ip FROM $tbl_online WHERE id = $_SESSION[member_id]") or die("Error in user online result query!"); if(mysql_num_rows($result) > 0) { $update = mysql_query("UPDATE $tbl_online WHERE timestamp<$timeout")or die("Error in who's online update query!".mysql_error()); } else { $insert = mysql_query(("INSERT INTO $tbl_online (id, timestamp, ip, file, ol_user, ol_id) VALUES('$mem_id', '$timestamp', '$rem_add', '$php_self', '$ol_user', '$ol_id')") or die("Error in who's online insert query!".mysql_error()); } //Delete Users $delete = mysql_query("DELETE FROM $tbl_online WHERE timestamp<$timeout") or die("Error in who's online delete query!"); Now, how do I get it to echo/print the online or offline images? Here's how I had it before: //Fetch Users Online $result = mysql_query("SELECT DISTINCT ip FROM $tbl_online WHERE id = $_SESSION[member_id]") or die("Error in user online result query!"); if(mysql_num_rows($result) > 0) { echo"<img src='./gr_image/online.jpg'>"; } else { echo"<img src='./gr_image/offline.jpg'>"; } Thanks in advance.
  9. Been trying to do a fix all day and can't seem to get it to work. Any help?
  10. Thanks maq and zenag. I got the online image to show, initially. Now, a new error. When I go to another page and then come back to where the online/offline image is I get this error: "Error in who's online insert query!Duplicate entry '4' for key 1". Any ideas? Is my Delete Users query not working correctly? <?php //Prevent the included file from being called directly. if(basename($_SERVER['PHP_SELF']) == "online.inc.php") { header("Location: /index.php"); exit; } $connection = @mysql_connect("$db_host", "$db_user", "$db_pass") or die("Couldn't connect."); $db = @mysql_select_db($db_name, $connection) or die("Couldn't select database."); $timestamp = time(); $timeout = $timestamp - 180; $mem_id = $_SESSION['member_id']; $rem_add = $_SERVER['REMOTE_ADDR']; $php_self = $_SERVER['PHP_SELF']; //Insert User $insert = mysql_query("INSERT INTO $tbl_online (id, timestamp, ip, file, ol_user, ol_id) VALUES('$mem_id', '$timestamp', '$rem_add', '$php_self', '$ol_user', '$ol_id')") or die("Error in who's online insert query!".mysql_error()); //Delete Users $delete = mysql_query("DELETE FROM $tbl_online WHERE timestamp<$timeout") or die("Error in who's online delete query!"); //Fetch Users Online $result = mysql_query("SELECT DISTINCT ip FROM $tbl_online WHERE id = $_SESSION[member_id]") or die("Error in user online result query!"); if(mysql_num_rows($result) > 0) { echo"<img src='./gr_image/online.jpg'>"; } else { echo"<img src='./gr_image/offline.jpg'>"; } ?>
  11. I am getting this error= "Error in who's online insert query!" I am just learning php, so be patient please. Here's the current code: <?php //Prevent the included file from being called directly. if(basename($_SERVER['PHP_SELF']) == "online.inc.php") { header("Location: /index.php"); exit; } $connection = @mysql_connect("$db_host", "$db_user", "$db_pass") or die("Couldn't connect."); $db = @mysql_select_db($db_name, $connection) or die("Couldn't select database."); $timestamp = time(); $timeout = $timestamp - 180; //Insert User $insert = mysql_query("INSERT INTO $tbl_online (id, timestamp, ip, file, ol_user, ol_id) VALUES(\"$_SESSION[member_id]\",'$timestamp','".$_SERVER['REMOTE_ADDR']."','".$_SERVER['PHP_SELF']."','$ol_user','$ol_id')") or die("Error in who's online insert query!"); //Delete Users $delete = mysql_query("DELETE FROM $tbl_online WHERE timestamp<$timeout") or die("Error in who's online delete query!"); //Fetch Users Online $result = mysql_query("SELECT DISTINCT ip FROM $tbl_online WHERE id = $_SESSION[member_id]") or die("Error in user online result query!"); if(mysql_num_rows($result) > 0) { echo"<img src='./gr_image/online.jpg'>"; } else { echo"<img src='./gr_image/offline.jpg'>"; } ?>
  12. I have a personal website that show the number of users on my site as a whole (like = 12 members online). The site has profile pages so I would like to show if a user is online or offline with an image. I have searched and searched here and haven't found what I was looking for. Can I alter my current file to fit what I want? <?php //Prevent the included file from being called directly. if(basename($_SERVER['PHP_SELF']) == "online.inc.php") { header("Location: /index.php"); exit; } $connection = @mysql_connect("$db_host", "$db_user", "$db_pass") or die("Couldn't connect."); $db = @mysql_select_db($db_name, $connection) or die("Couldn't select database."); $timestamp = time(); $timeout = $timestamp - 180; if(session_is_registered("valid_user")) { $ol_user = "$valid_user"; } else { $ol_user = "guest"; } if(session_is_registered("valid_user")) { $ol_id = "$member_id"; } else { $ol_id = "0"; } //Insert User $insert = mysql_query("INSERT INTO $tbl_online (timestamp, ip, file, ol_user, ol_id) VALUES('$timestamp','".$_SERVER['REMOTE_ADDR']."','".$_SERVER['PHP_SELF']."','$ol_user','$ol_id')") or die("Error in who's online insert query!"); //Delete Users $delete = mysql_query("DELETE FROM $tbl_online WHERE timestamp<$timeout") or die("Error in who's online delete query!"); //Fetch Users Online $result = mysql_query("SELECT DISTINCT ip FROM $tbl_online") or die("Error in who's online result query!"); $users = mysql_num_rows($result); if($users == 1) { $ol_label = "user"; } else { $ol_label = "users"; } ?> <table align="center" cellpadding="0" cellspacing="0"> <tr> <td class="online"> <p><?php echo "<b>$valid_user</b> $ol_label"; ?> online</p> </td> </tr> </table> Thanks in advanced.
  13. You have made my day corbin. Now that you got it working, I will go and read the tut's that you posted so I can understand it better. I am sorry for any inconvenience.
  14. Sorry to bother you corbin. Can someone tell me why I am getting this error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/xxxxx/public_html/xxxxx/include/main_new_members.inc.php on line 61 The code is below. See "LINE 61 IS HERE" <?php //Prevent the included file from being called directly. if(basename($_SERVER['PHP_SELF']) == "newestmember.inc.php") { header("Location: /index.php"); exit; } $connection = @mysql_connect("$db_host", "$db_user", "$db_pass") or die("Couldn't connect."); $db = @mysql_select_db($db_name, $connection) or die("Couldn't select database."); $sql = "SELECT p.*, i.* FROM images i JOIN profiles p ON p.profile_id = i.image_id WHERE i.displayname != 'Community' AND default_pic = 'yes' ORDER BY image_id DESC LIMIT 0, 2"; $result = @mysql_query($sql,$connection) or die(mysql_error()); $num=mysql_num_rows($result); if($num < 1){ echo "<center>No Members with pictures found.</center>"; } else { ?> <table style='text-align: left; width: 100%;' border='0' cellpadding='0' cellspacing='0'> <tbody> <tr> <td>new to lounge{in}</td> </tr> </tbody> </table> <? while ($row = mysql_fetch_array($result)) { $url = $row['url']; $image = $row['image']; $member = $row['displayname']; $fullurl = "$userurl/$url"; $src = "$userdir/$url/$image"; LINE 61 IS HERE --> $age = "$row['age']"; echo " <table style='text-align: left; width: 100%;' border='0' cellpadding='0' cellspacing='0'> <tbody> <tr> <td><a href=\"$fullurl\"><img src=\"thumbs/phpThumb.php?src=/$src&w=50\" border=\"0\"></a></td> <td align='undefined' valign='undefined'> <table style='text-align: left; width: 100%;' border='0' cellpadding='0' cellspacing='0'> <tbody> <tr> <td><a href=\"$fullurl\">$member</a>$age </td> </tr> <tr> <td align='undefined' valign='undefined'>location</td> </tr> </tbody> </table> </td> </tr> <tr> <td align='undefined' valign='undefined'>sgl div</td> <td align='undefined' valign='undefined'>sgl div</td> </tr> </tbody> </table> "; } ?> </table> <? } ?>
  15. Change the HTML? So, the query matched the image_id and the profile_id. How do I pull the age from the profiles table? If you look in the code below I want to have the age appear where it says INSERT AGE HERE (in the HTML part). How do I define the age and the print it? <?php //Prevent the included file from being called directly. if(basename($_SERVER['PHP_SELF']) == "newestmember.inc.php") { header("Location: /index.php"); exit; } $connection = @mysql_connect("$db_host", "$db_user", "$db_pass") or die("Couldn't connect."); $db = @mysql_select_db($db_name, $connection) or die("Couldn't select database."); $sql = "SELECT p.*, i.* FROM images i JOIN profile p ON p.profile_id = i.image_id WHERE i.displayname != 'Community' AND default_pic = 'yes' ORDER BY image_id DESC LIMIT 0, 5"; $result = @mysql_query($sql,$connection) or die("Couldn't execute query."); $num=mysql_num_rows($result); if($num < 1){ echo "<center>No Members with pictures found.</center>"; } else { ?> <table align="center" cellpadding="4" cellspacing="0" width="100%"> <? while ($row = mysql_fetch_array($result)) { $url = $row['url']; $image = $row['image']; $member = $row['displayname']; $fullurl = "$userurl/$url"; $src = "$userdir/$url/$image"; echo "<table style='text-align: left; width: 100%;' border='0' cellpadding='0' cellspacing='0'> <tbody> <tr> <td>new to lounge{in}</td> </tr> </tbody> </table> <table style='text-align: left; width: 100%;' border='0' cellpadding='0' cellspacing='0'> <tbody> <tr> <td><a href=\'$fullurl\'><img src=\'thumbs/phpThumb.php?src=/$src&w=50\' border=\'0\' alt=\'$member\'></a></td> <td align='undefined' valign='undefined'> <table style='text-align: left; width: 100%;' border='0' cellpadding='0' cellspacing='0'> <tbody> <tr> <td><a href=\"$fullurl\">$member</a>INSERT AGE HERE</td> </tr> <tr> <td align='undefined' valign='undefined'>location</td> </tr> </tbody> </table> </td> </tr> <tr> <td align='undefined' valign='undefined'>sgl div</td> <td align='undefined' valign='undefined'>sgl div</td> </tr> </tbody> </table>"; } ?> <? } ?>
  16. Thanks, it works but just outputs what the original file did (displayname and image). How do I tie in the age from the profiles table (you can see the fields in my first post).
  17. I have bookmarked http://www.tizag.com/mysqlTutorial/mysqljoins.php. That seems like a very simple example. Mine seems a lot more involved. Still, it is great reading. Thanks
  18. Got an error: Couldn't execute query. Here's the full new code: <?php //Prevent the included file from being called directly. if(basename($_SERVER['PHP_SELF']) == "newestmember.inc.php") { header("Location: /index.php"); exit; } $connection = @mysql_connect("$db_host", "$db_user", "$db_pass") or die("Couldn't connect."); $db = @mysql_select_db($db_name, $connection) or die("Couldn't select database."); $sql = "SELECT p.*, i.* FROM images i JOIN profile p ON p.profile_id = i.image_id WHERE i.displayname != 'Community' AND default_pic = 'yes' ORDER BY image_id DESC LIMIT 0, 5"; $result = @mysql_query($sql,$connection) or die("Couldn't execute query."); $num=mysql_num_rows($result); if($num < 1){ echo "<center>No Members with pictures found.</center>"; } else { ?> <table align="center" cellpadding="4" cellspacing="0" width="100%"> <? while ($row = mysql_fetch_array($result)) { $url = $row['url']; $image = $row['image']; $member = $row['displayname']; $fullurl = "$userurl/$url"; $src = "$userdir/$url/$image"; echo "<table style='text-align: left; width: 100%;' border='0' cellpadding='0' cellspacing='0'> <tbody> <tr> <td>new to lounge{in}</td> </tr> </tbody> </table> <table style='text-align: left; width: 100%;' border='0' cellpadding='0' cellspacing='0'> <tbody> <tr> <td><a href=\'$fullurl\'><img src=\'thumbs/phpThumb.php?src=/$src&w=50\' border=\'0\' alt=\'$member\'></a></td> <td align='undefined' valign='undefined'> <table style='text-align: left; width: 100%;' border='0' cellpadding='0' cellspacing='0'> <tbody> <tr> <td><a href=\"$fullurl\">$member</a> $age</td> </tr> <tr> <td align='undefined' valign='undefined'>location</td> </tr> </tbody> </table> </td> </tr> <tr> <td align='undefined' valign='undefined'>sgl div</td> <td align='undefined' valign='undefined'>sgl div</td> </tr> </tbody> </table>"; } ?> <? } ?> Also, how do I output the age from the profiles table? Sorry to be a bother, this is driving me nuts. I have been trying to read how to fix this literally all day. Thanks.
  19. SELECT p.*, i.* FROM profile p LEFT JOIN image i ON i.image_id = p.profile_id; Is that to be done in a separate query than the image/displayname query? $sql = "SELECT * FROM $tbl_images WHERE displayname != \"Community\" AND default_pic = \"yes\" ORDER BY image_id DESC LIMIT 0, 2"; $result = @mysql_query($sql,$connection) or die("Couldn't execute query."); $num=mysql_num_rows($result); if($num < 1){ echo "<center>No Members with pictures found.</center>"; } else { Thanks again.
  20. Thanks corbin, I am REALLY new to php/mysql. I really don't understand JOIN. When you get time could you write something up so I can study it (that's how I learn the best - by dissecting the code, reading directions is not my thing). Any help is greatly appreciated.
  21. The image_id (image table) and the profile_id (profile table) are relative to each member (they match).
  22. Kind of hard to explain in words, but here goes... I have two tables: 1. images Fields: image_id, directory, image, url, displayname, default_pic 2. profiles Fields: profile_id, directory, dark_color, light_color, panel_text, table_color, font_color, font_style, font_size, profile_url, page_name, ratings, p_name, location, gender, age, marital, about_me, hobbies The file is a list New Members by their display name and their uploaded image. That file works fine. <?php $connection = @mysql_connect("$db_host", "$db_user", "$db_pass") or die("Couldn't connect."); $db = @mysql_select_db($db_name, $connection) or die("Couldn't select database."); $sql = "SELECT * FROM $tbl_images WHERE displayname != \"Community\" AND default_pic = \"yes\" ORDER BY image_id DESC LIMIT 0, 2"; $result = @mysql_query($sql,$connection) or die("Couldn't execute query."); $num=mysql_num_rows($result); if($num < 1){ echo "<center>No Members with pictures found.</center>"; } else { ?> <table align="center" cellpadding="4" cellspacing="0" width="100%"> <? while ($row = mysql_fetch_array($result)) { $url = $row['url']; $image = $row['image']; $member = $row['displayname']; $fullurl = "$userurl/$url"; $src = "$userdir/$url/$image"; echo "<tr> <td width=\"52\" valign=\"middle\" class=\"newmem\"> <p><a href=\"$fullurl\"><img src=\"thumbs/phpThumb.php?src=/$src&w=50\" border=\"0\"></a></p> </td> <td valign=\"middle\" class=\"newmem\"> <p><a href=\"$fullurl\">$member</a></p> </td> </tr>"; } ?> </table> <? } ?> I wanted to add some other information (members age) from the profiles table. I need to search and match the members image and displayname from the images table with their age from the profiles table. How can I search and match the current information with the correct information from the profiles table?
  23. Not sure if that works because I am getting an error before that point: Couldn't execute code check query. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE code = 'uPkVZv'' at line 1 Here is the code for the above error: $checkref = "SELECT * FROM $tbl_profiles WHERE profile_url = ".quote_smart($referral).""; $check_ref = @mysql_query($checkref,$connection) or die("Couldn't execute referral check query.<br>".mysql_error()); if(mysql_num_rows($check_ref) < 1){ $referral_err = "The referral name you used is not in the database."; $error = "1"; } $checkrefcode = "SELECT * FROM $tbl_ref_code WHERE code = ".quote_smart($refcode).""; $check_refcode = @mysql_query($checkrefcode,$connection) or die("Couldn't execute code check query.<br>".mysql_error()); if(mysql_num_rows($check_refcode) < 1){ $refcode_err = "The referral code you entered is not in the database."; $error = "1"; } $referralname = mysql_real_escape_string($_POST['referral']); $referralcode = mysql_real_escape_string($_POST['refcode']); $sql = "SELECT my_name, code FROM ref_code WHERE my_name = '$referral' && code = '$refcode'"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { // match found, do whatever. } else { echo "Match not found"; } } Any help greatly appreciated.
  24. For first part see this post http://www.phpfreaks.com/forums/index.php/topic,222013.0.html Now here is part 2 to my registration problem. I got the referral check to work by username. Now I also want to verify a referral code. The thing is, I want to verify that the referral code matches the code from a particular member by name. Here's how the referral registration works: 1. Current member sends a "tell-a-friend" email to a friend to join the website. The "tell-a-friend" form has a randomly generated string and stores the current members name and the generated string that was sent to friend in mysql. 2. The friend goes to website and registers. When registering he must enter the current members name along with the randomly generated string from the "tell-a-friend" form. What I want to do is have the registration form check the database for the current member and the random string and make sure they match or are equal. If they do, registration complete. If they don't match, registration fails. I want to search to make sure my_name (Tom) and code (5gT8Cx) exist then make sure they match. Example: Code: [select] +--------+ | Field | +--------------+ | my_name = Tom | code = 5gT8Cx | fr_emaile +--------------+ Help please. Where you at CroNiX? Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.