Jump to content

runnerjp

Members
  • Posts

    2,214
  • Joined

  • Last visited

Everything posted by runnerjp

  1. here is what my current form looks like <?php $result = mysql_query("SELECT * FROM pb where uid='".$getuser['ID']."' Order by pb") or die(mysql_error()); $num2 = mysql_num_rows($result); echo "<table class=\"profilepbs\" width=195 align=\"center\" cellpadding=\"0\" cellspacing=\"0\"> <tr><td width=105 ><div align=\"center\">Distance</div></td><td width=125><div align=\"center\">Pb</div></td></tr> <tr> <td height=\"1\" colspan=\"2\" bgcolor=\"#000000\"></td> <td height=\"1\" colspan=\"2\" bgcolor=\"#000000\"></td> </tr> "; while ( $row = mysql_fetch_array($result) ) {echo "<tr><td bgcolor=\"#FFFFFF\"><center>" . $row["distance"] . "</center></td><td bgcolor=\"#FFFFFF\"><center>" . $row["pb"] . "</center></td></tr>"; } if($num2 < 1) {echo "<tr><td bgcolor=\"#FFFFFF\" ><center> N/A </center></td><td bgcolor=\"#FFFFFF\"><center> N/A </center></td></tr>";} echo "</table> <p>"; ?> 10k Road 32:10.1 100m 9.3 3000m 9:07.2 i would like it to go in time order so the shorter the distances appear at the top like so 100m 9.3 3000m 9:07.2 10k Road 32:10.1 i just can figure out how to do this with the format thats used to enter the times
  2. i get Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/runningp/public_html/members/include/profile.php on line 139 user has yet to make a post.
  3. stick the session destroy on the logout.php page.. then add a redirect to the home page!
  4. i need to be able to display a message if a users has not posted anything in the forum.... im not sure how to get this right... here is my attempt <?php $sql = "Select * FROM forumtutorial_posts where author = '$profilename' ORDER BY `showtime` DESC LIMIT 0, 5"; $postsresult = mysql_query($sql) or die("Could not get threads"); while($row = mysql_fetch_assoc($postsresult)) { echo ' <a id="posts" href="http://www.runningprofiles.com/members/index.php?page=message&forum='.$row['forum'].'&id='.$row['postid'].'&pagenum=last">'.$row['title'].'</a> <br />' ;} [b]if ($postresults < 0)[/b] {echo 'user has yet to make a post.';}?>
  5. humm i get nothing ...bu i should do here is my form <form name="Submit" method="post" action="index.php?page=delete"> </p> <table width="80%" class='forum'> <tr> <td><table width="100%" class='maintable'> <tr class='headline'> <td align="center"><b><u>Select</u></b></td> <td align="center">Status</td> <td align="center">Sender</td> <td align="center">Image</td> <td><b><u>Subject</u></b></td> <td>Sent On</td> </tr> <?php //Ok cool, now we stick it all into an array and we will dispaly it now while($inbox = mysql_fetch_array($sqlinbox)) { //These are the variables we have the id of the private message, we have the person who sent the message, we have the subject of the message, and yeah thats it $pm_id = $inbox['id']; $sender = $inbox['sender']; $subject = $inbox['subject']; $time = $inbox['time']; $new = $inbox['recieved']; //So lets show the subject and make that a link to the view message page, we will send the message id through the URL to that page so it can be displayed //And also let the person wee who sent it to them, if you want you can make that some sort of a link to view more stuff about the user, but Im not doing that here, I did it for my game though, pretty much same as the viewmsg.php page but a different page, and with the senders id //And finally the checkboxes that are all stuck into an array and if they are selected we stick the private message id into the array //I will only let my users have a maximum of 50 messages, remeber that ok? Because that's the value I will use later for things ?> <tr <?php if($important==1) { $class = "mainrow1"; } else { $class = "mainrow"; } ?> class="<? echo $class?>"> <td width="5%" height="18" align="center" valign="top"><input type="checkbox" name="selection[]" value="<?php echo $pm_id; ?>" /> <td width="6%" height="18" align="center" valign="top"><?php if ($new == 0 ){echo 'Unread';} else {echo 'Read';} ?> <td width="9%" align="center" valign="top"><p><a href="http://www.runningprofiles.com/members/<?php echo $sender; ?>"><?php echo $sender; ?></a></p> <p><a href="http://www.runningprofiles.com/members/<?php echo $sender; ?>"></a></p> <p> </p> <td width="9%" align="center" valign="top"><a href="http://www.runningprofiles.com/members/<?php echo $sender; ?>"> <?php $sender = $inbox['sender']; $getuser="SELECT * FROM users WHERE Username = '$sender' "; $getuser2=mysql_query($getuser) or die("Could not get user") ; while($getuser3=mysql_fetch_array($getuser2)){ $getuser3['image']=strip_tags($getuser3['image']); $image = $getuser3['image']; echo "<img src=\"http://www.runningprofiles.com/members/images/mini/$image\" border=\"1\" />"; }?> </a> <td width="37%" align="center" valign="top"><p align="left"><a href="index.php?page=viewmsg&msg_id=<?php echo $pm_id; ?>"><?php echo $subject; ?></a> </td> <td align="left" valign="top"><?php $time1 = date("F j Y, g:i a", $time); echo $time1; ?> <div align="left"></div></td> </tr> <? } ?> <tr <?php if($important==1) { $class = "mainrow1"; } else { $class = "mainrow"; } ?> class="<? echo $class?>"> <td height="19" colspan="6" align="center" valign="middle"><input type="submit" name="operation" value="Delete" /> <input type="submit" name="operation" value="Move" /> </form> ?>
  6. im using implode for my check boxes but i get this error Warning: implode() [function.implode]: Invalid arguments passed in /home/runningp/public_html/members/include/delete.php on line 4 Error: 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 ')' at line 1 what do i seem to be doing wrong :S <?php $delete="DELETE FROM messages WHERE id in (".implode(',', $_POST['pms']).")"; mysql_query($delete) or die("Error: " . mysql_error()); //insert post?> i have only selected 1 check box to delete
  7. its ok i used implode...all of a sudden it came to me lol
  8. ok here is an example of a inbox im making for my website <?php // Test data $messages[] = array('id'=>'1', 'subject'=>'Message1', 'date'=>'20090408'); $messages[] = array('id'=>'2', 'subject'=>'Message2', 'date'=>'20090408'); $messages[] = array('id'=>'3', 'subject'=>'Message3', 'date'=>'20090408'); $messages[] = array('id'=>'4', 'subject'=>'Message4', 'date'=>'20090408'); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Temp</title> <style type="text/css"> </style> </head> <body> <form method="post" action="<?php echo $_SERVER['PHP_SELF']?>"><!-- you should always use the POST method to make changes to your database --> <input type="submit" name="operation" value="Delete" /> <input type="submit" name="operation" value="Move" /> <table> <thead> <tr><th>select</th><th>Subject</th><th>Date</th></tr> </thead> <tbody> <?php foreach($messages as $message) { ?> <tr><td><input type="checkbox" name="selection[]" value="<?php echo $message['id']; ?>" /></td><td><?php echo $message['subject']; ?></td><td><?php echo $message['date']; ?></td></tr> <?php } ?> </tbody> </table> </form> <pre> <?php var_dump($_POST); ?> </pre> </body> </html> the thing is if i wanted to use $delete="DELETE FROM messages WHERE id= then how would i get which textboxes are checked so i can delete the messages?
  9. after running the following code <?php if (!isset($_REQUEST['Submit'])) { //stop flooding $query = "SELECT max(unix_timestamp(`time`)) as t FROM messages WHERE reciever='$reciever' AND sender='$username'"; $res = mysql_query($query); if (!$res) { $errmsg = mysql_errno() . ' ' . mysql_error(); echo "<br/>QUERY FAIL: "; echo "<br/>$sql <br/>"; die($errmsg); } $num = mysql_num_rows($res); if (!$num) { echo "<br/>QUERY FOUND NO DATA: "; echo "<br/>$sql <br/>"; } else { echo "<br/>QUERY FOUND $num ROWS OF DATA "; echo "<br/>$sql <br/>"; } if(!$res) die("Query: $query\nError: ".mysql_error()); $lastMessageTime = mysql_num_rows($res) == 1 ? array_shift(mysql_fetch_array($res)) : 0; if ($lastMessageTime > 0 && $lastMessageTime < strtotime('+2 Minutes', $timestamp)) { $errors[] = 'Please wait 2 minutes between each message'; } ?> it says that i have QUERY FOUND 1 ROWS OF DATA ... so why does it not apply the code if i submit the code twice within 10 seconds
  10. oh yes opps lol. i dont seem to be able to find why the flood control does not work :S any 1 see why
  11. i have tried finding the error <?php //Get their private message count $sql = mysql_query("SELECT pm_count FROM users WHERE Username='$reciever'"); $res = mysql_query($sql); // $row = mysql_fetch_array($sql); if (!$res) { $errmsg = mysql_errno() . ' ' . mysql_error(); echo "<br/>QUERY FAIL: "; echo "<br/>$sql <br/>"; die($errmsg); } ?> which gives the following output QUERY FAIL: Resource id #12 1064 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 'Resource id #12' at line 1 butim confused by what Resource id #12 is
  12. but it inserts as i can get the data and time by doing this <?php $time = $inbox['time']; $time1 = date("F j Y, g:i a", $time); echo $time1; ?> the problem is using it as the flood prevention
  13. like so <?php $timestamp = time(); $update = mysql_query("INSERT INTO messages (time,reciever, sender, subject, message) VALUES('$timestamp','$reciever', '$username', '$subject', '$message')") or die(mysql_error());?>
  14. im using a ajax form and basicly its easy to flood the form.. so what i did was type up this bit of code <?php if (!isset($_REQUEST['Submit'])) { //stop flooding $query = "SELECT max(`time`) as t FROM messages WHERE reciever='$reciever' AND sender='$username'"; $res = mysql_query($query); if(!$res) die("Query: $query\nError: ".mysql_error()); $lastMessageTime = mysql_num_rows($res) == 1 ? array_shift(mysql_fetch_array($res)) : 0; if ($lastMessageTime > 0 && $lastMessageTime < strtotime('+2 Minutes', $timestamp)) { $errors[] = 'Please wait 2 minutes between each message'; }?> the thing is it does not work, no errors or anything but it does not show the error message and allows re submittance of the form, right away ?!?!?! in the db time is stored as time();
  15. for some reason i get this error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource for here $lastMessageTime = mysql_num_rows($res) == 1 ? array_shift(mysql_fetch_array($res)) : i dont understand as all it should be doing is finding if user is flooding :S here is full code <?php session_start(); require_once '../../settings.php'; include "../../info.php"; // sets username/id ect $reciever = mysql_real_escape_string($_POST['username']); $subject = mysql_real_escape_string($_POST['subject']); $message = mysql_real_escape_string($_POST['message']); $timestamp = time(); if (!isset($_REQUEST['Submit'])) { //stop flooding $query = "SELECT max(`time`) as t FROM messages WHERE receiver='$receiver' AND username='$username'"; $res = mysql_query($query); $lastMessageTime = mysql_num_rows($res) == 1 ? array_shift(mysql_fetch_array($res)) : 0; if ($lastMessageTime > 0 && $lastMessageTime < strtotime('+2 Minutes', $timestamp)) { $errors[] = 'Please wait 2 minutes between each message'; } //Get their private message count $sql = mysql_query("SELECT pm_count FROM users WHERE Username='$reciever'"); $row = mysql_fetch_array($sql); $pm_count = $row['pm_count']; //You cant have more than 50 private messages, if they try sending a message to a user with a full inbox return an error message if (pm_count >= '1') { $errors[] = 'The user you are trying to send a message to has 50 private messages, sorry but we cant send your message untill that user deletes some of their messages.'; } //find errors in form if ($_POST['subject'] == '' || strlen($_POST['subject']) < 3) { $errors[] = 'A subject is required and must contain 3 characters or more'; } if ($_POST['message'] == '' || strlen($_POST['message']) < 3) { $errors[] = 'A message is required and must contain 3 characters or more'; } if (is_array($errors)) { echo '<p class="error"><b>The following errors occured</b></p>'; while (list($key, $value) = each($errors)) { echo '<span class="error">' . $value . '</span><br />'; } } else { //Are the trying to send a message to a real user or to something they just made up? $user_check = mysql_query("SELECT * FROM `friends` WHERE `username`= '$username' and friendname = '$reciever' "); $user_check = mysql_num_rows($user_check); //The user is real and not made up if this is true if ($user_check > 0) { $pm_count = $pm_count + '1'; //Update Them $userpmupdate = mysql_query("UPDATE users SET pm_count='$pm_count' WHERE username='$reciever'") or die(mysql_error()); ; $update = mysql_query("INSERT INTO messages (time,reciever, sender, subject, message) VALUES('$timestamp','$reciever', '$username', '$subject', '$message')") or die(mysql_error()); echo 'Your profile has been update!'; } else { echo 'You may only message friends!'; } } } ?>
  16. i was thinging it would get it from the initial page its on but obviusly not lol thanks
  17. im using tabs to display different types of inforamtion on a profile page.... <div align="center" class="style5"> <p class="style9"><u>Welcome to Admins profile</u></p> <p class="style9"> </p> </div> <ul id="countrytabs" class="shadetabs"> <li><a href="#" rel="#default" class="selected">About me</a></li> <li><a href="include/profiletab/showgoals.php" rel="countrycontainer">Goals</a></li> <li><a href="include/profiletab/external3.htm" rel="countrycontainer">Idols</a></li> <li><a href="include/profiletab/external4.htm" rel="#iframe">Thanks to</a> </li> </ul> <div id="countrydivcontainer" style="border:1px solid gray; width:800px; margin-bottom: 1em; padding: 10px"> <?php echo $getuserprofile['about_me']?></div> <script type="text/javascript"> var countries=new ddajaxtabs("countrytabs", "countrydivcontainer") countries.setpersist(true) countries.setselectedClassTarget("link") //"link" or "linkparent" countries.init() </script> the thing is when i click on one of the tabs such as <li><a href="include/profiletab/showgoals.php" rel="countrycontainer">Goals</a></li>, then the php on the page wont work <?php session_start(); require_once '../../../settings.php'; include "../../../info.php"; // sets username/id ect $go= $_GET['username']; echo $go; $getuser = mysql_fetch_assoc(mysql_query("SELECT * from users where Username='$profilename'")); $getuserprofile = mysql_fetch_assoc(mysql_query("SELECT * from profile where ID='".$getuser['ID']."'")); echo $getuserprofile['mygoals']; ?> the reason for this seams to be the fact that $_GET['username']; does not grab the username in the url... how can i carry the url to one of the linked pages so that i can get information in the tabs dependent on the users profile page?
  18. ok getting sumwhere !!! this is what was outputted sql is INSERT INTO pb (uid, distance, pb) values (1,'withoutMinutes|100m','10.1') Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in /home/runningp/public_html/do5.php on line 93 The database was not updated. pb was 10.1 dist was withoutMinutes|100m uid was 1.sql is INSERT INTO pb (uid, distance, pb) values (1,'withoutMinutes|100m','10.1') Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in /home/runningp/public_html/do5.php on line 93 Your profile has been update again! now it says withoutMinutes|100m but im using javascript that should change this function validateTime(nDistance) { var useDistance = nDistance.split("|"); var valid = true; var nTimeField = document.forms[0]['userDistance']; var nTime = document.forms[0]['userDistance'].value; if (useDistance[0] == "withHours") { if (nTime == "") { return false; } if (!/^\d{1,2}[:\-]\d{1,2}[:\-]\d{1,2}$/.test(nTime) && !/^\d{1,2}[:\-]\d{1,2}[:\-]\d{1,2}\.\d{1,2}$/.test(nTime)) { alert('Hours, Minutes and Seconds must be separated\n' + 'by a : (colon) or, - (hyphen) \n' + 'Seconds may be expressed in tenths or hundreths:\n' + 'ss.ss or, s.ss or, s.s or, ss.s'); return false; } nTime = nTime.replace(/[:\-]/g, "|").split("|"); nTime[0] > 23 ? valid = false : nTime[1] > 59 ? valid = false : nTime[2] > 59.99 ? valid = false : null; if (!valid) { alert('Invalid time'); nTimeField.value = ""; nTimeField.focus(); } } if (useDistance[0] == "withoutHours") { if (nTime == "") { return false; } if (!/^\d{1,2}[:\-]\d{1,2}$/.test(nTime) && !/^\d{1,2}[:\-]\d{1,2}\.\d{1,2}$/.test(nTime)) { alert('Minutes and Seconds must be separated\n' + 'by a : (colon) or, - (hyphen) \n' + 'Seconds may be expressed in tenths or hundreths:\n' + 'ss.ss or, s.ss or, s.s or, ss.s'); return false; } nTime = nTime.replace(/[:\-]/g, "|").split("|"); nTime[0] > 59 ? valid = false : nTime[1] > 59.99 ? valid = false : null; if (!valid) { alert('Invalid time'); nTimeField.value = ""; nTimeField.focus(); } } if (useDistance[0] == "withoutMinutes") { if (nTime == "") { return false; } if (!/^\d{1,2}$/.test(nTime) && !/^\d{1,2}\.\d{1,2}$/.test(nTime)) { alert('Seconds may be expressed in tenths or hundreths:\n' + 'ss.ss or, s.ss or, s.s or, ss.s'); return false; } nTime = nTime.replace(/[:\-]/g, "|").split("|"); nTime[0] > 59.99 ? valid = false : null; if (!valid) { alert('Invalid time'); nTimeField.value = ""; nTimeField.focus(); } } return true; } function setDistance(nDistance){ var useDistance = nDistance.split("|"); var nTimeField = document.forms[0]['userDistance']; nTimeField.value = ""; document.forms[0]['userDistance'].parentNode.firstChild.data = useDistance[1] + ": "; if (useDistance[0] == "#") { nTimeField.readOnly = true; return; } nTimeField.readOnly = false; } function init(){ document.forms[0]['userDistance'].onblur = function() { validateTime(document.forms[0]['distance'].value); } } navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false); could this be the problem?
  19. ermm im not calling mget yet... but i am calling insert(); just below the insert <?php function insert($uid,$dist,$pb) //insert new or update existing record { echo "<h1>Got in</h1>"; if (!$uid) return; //should validate here echo "<h1>1</h1>"; if (!$dist) return; echo "<h1>2</h1>"; if (!$pb) return; echo "<h1>Got to here</h1>"; //if(!isset($uid)) return; //see if already exists $sql1 = "SELECT * FROM pb WHERE uid=$uid AND distance='$dist'"; $result = mysql_query($sql1) or die(mysql_error()); if (mysql_num_rows($result) >=1) { //already exists $sql2 = "UPDATE pb Set pb = '$pb' WHERE uid=$uid AND distance='$dist'"; //try updating in case already exists $result = mysql_query($sql2) or die(mysql_error()); } else { //need a new record $sql3 = "INSERT INTO pb (uid, distance, pb) values ($uid,'$dist','$pb')"; echo 'sql is ' . $sql3 . '<br>'; $result = mysql_query($sql3) or die(mysql_error()); echo $sql2; echo $sql3; } } insert($uid,$dist,$pb);?> i got rid of ob_start("ob_gzhandler");... i have also tried to find an error in my code so i did this <?php function insert($uid,$dist,$pb) //insert new or update existing record { echo "<h1>Got in</h1>"; if (!$uid) return; //should validate here echo "<h1>1</h1>"; if (!$dist) return; echo "<h1>2</h1>"; if (!$pb) return; echo "<h1>Got to here</h1>"; //if(!isset($uid)) return; //see if already exists $sql1 = "SELECT * FROM pb WHERE uid=$uid AND distance='$dist'"; $result = mysql_query($sql1) or die(mysql_error());?> and all i get is 'Got in 1' its not updating though as im checking my db also. i used your code premiso and i got the db was not updated sadly
  20. sorry i should have added this... the file i included (info.php) sets the user id ect <?php /* user sessions */ $username= get_username($_SESSION['user_id']); // gest username of online user $id = $_SESSION['user_id']; // gets the online users id ?> i tried to echo it in the statement and nothing sadly...it is echoing 'Your profile has been update again!' though...
  21. for some reason my sql statements wotn insert into my db ? i tried to echo the sql statements yet i get no ouput :S can any1 figure out why? <?php ob_start("ob_gzhandler"); session_start(); error_reporting(E_ALL); require_once 'settings.php'; include "info.php"; // sets username/id ect //insert any new entry into the database $uid = $id; $dist = mysql_real_escape_string($_POST['dist']); $pb = mysql_real_escape_string($_POST['pb']); $result = mysql_query("SELECT * FROM pb") or die(mysql_error()); insert($uid,$dist,$pb); /*-------------------------------------------------------------------------------*/ function insert($uid,$dist,$pb) //insert new or update existing record { if (!$uid) return; //should validate here if (!$dist) return; if (!$pb) return; //if(!isset($uid)) return; //see if already exists $sql1 = "SELECT * FROM pb WHERE uid=$uid AND distance='$dist'"; $result = mysql_query($sql1) or die(mysql_error()); if (mysql_num_rows($result) >=1) { //already exists $sql2 = "UPDATE pb Set pb = '$pb' WHERE uid=$uid AND distance='$dist'"; //try updating in case already exists $result = mysql_query($sql2) or die(mysql_error()); } else { //need a new record $sql3 = "INSERT INTO pb (uid, distance, pb) values ($uid,'$dist','$pb')"; echo 'sql is ' . $sql3 . '<br>'; $result = mysql_query($sql3) or die(mysql_error()); } } /*-------------------------------------------------------------------------------*/ //when I want to get a key that may not exist without php warnings function mget($mynam,$myarray) { if (is_array($myarray)|| is_object($myarray)) { if (array_key_exists($mynam, $myarray)) { return htmlentities($myarray[$mynam]); //remove any unsafe html in case of malicious user } } return ''; } echo $sql2; echo $sql3; echo 'Your profile has been update again!'; /*-------------------------------------------------------------------------------*/ ?>
  22. currently i have function checkit(which) { var tim = which.value; var flag = 0; if (!/^\d{1,2}[-:\.]\d{2}/.test(tim)) { // basic format flag = 1; } tim = tim.replace(/[-\.]/g,":"); tim = tim.split(/:/); if ((tim[0] > 23) || tim[1] > 59) { // hour or minute values too great flag = 1; } if (flag == 1) { alert ("This field requires a valid time!" ); which.value = ""; which.focus(); return false; } } but the thing is it wont allow i time such as 45.6's to be entred...how could i chnage this?
×
×
  • 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.