Jump to content

runnerjp

Members
  • Posts

    2,214
  • Joined

  • Last visited

Everything posted by runnerjp

  1. ok really i have 2 questions... here is my 1st for some reaosn when it gets my name from the db and i want to chnage anything it sys *First name can only contain letters *last name can only contain letters even though all thats outputted in the boxes is jarratt perkins how comes its doing this? the code is here <link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/css/login.css"> <link rel="stylesheet" type="text/css" href="include/profiletab/ajaxtabs/ajaxtabs.css"> <?php require_once '../settings.php'; checkLogin('1 2'); include "../info.php"; // sets username/id ect include "../getuser.php"; // records user view on page $getuser = mysql_fetch_assoc(mysql_query("SELECT * from users where Username='$username'")); $getuserprofile = mysql_fetch_assoc(mysql_query("SELECT * from profile where ID='" . $getuser['ID'] . "'")); $your_date = $getuserprofile['dob']; $splitDate = explode("-", $your_date); ?> <table width="100%" cellspacing="0" cellpadding="0"> <tr> <td width="10%"> </td> <td width="42%"> <div id="countrydivcontainer" style="border:1px solid gray; width:800px; margin-bottom: 1em; padding: 10px"> <? if(isset($_POST['submitted'])) { foreach($_POST as $field => $value) { if (($field != 'submit') && ((!$value) || (trim($value) == ''))) { $err .= "$field cannot be empty. <br>"; $warnings[$field] ="required"; } } if (!$_POST["first_name"] || !preg_match("/^[a-zA-Z]+$/", $_POST["first_name"])) { $warnings["first_name"] = " <label for=\"uname\" class=\"error\"><em>*</em>First name can only contain letters</label>"; } if (!$_POST["last_name"] || !preg_match("/^[a-zA-Z]+$/", $_POST["last_name"])) { $warnings["last_name"] = " <label for=\"uname\" class=\"error\"><em>*</em>Last name can only contain letters</label>"; } $count = count($warnings); } if($count === 0) { if(array_key_exists('submit', $_POST)) { $club = mysql_real_escape_string($_POST['club']); $first_name = mysql_real_escape_string($_POST['first_name']); $last_name = mysql_real_escape_string($_POST['last_name']); $gender = mysql_real_escape_string($_POST['gender']); $year = mysql_real_escape_string( $_POST['year']); $month = mysql_real_escape_string( $_POST['month']); $day = mysql_real_escape_string( $_POST['day']); $dob = $day.'-'.$month.'-'.$year; $update = "UPDATE profile SET dob='$dob', club= '$club', first_name = '$first_name', gender = '$gender', last_name = '$last_name' WHERE ID='$id' "; $result = mysql_query($update); // Check result // This shows the actual query sent to MySQL, and the error. Useful for debugging. if (!$result) { $er = 'Invalid query: ' . mysql_error() . "\n"; $er .= 'Whole query: ' . $query; die($er); }} echo ' <p class="error">' . $message . '</p>' . "\n"; } if ($err){?> <div class="errors"> <p align="center"><em>Oops... the following errors were encountered:</em></p> <div align="center"> <ul> <?php echo $err; ?> </ul> </div> <p align="center">Data has <strong>not</strong> been saved.</p> </div> <p> <?php } ?> <fieldset> <legend>Basic Information</legend> <p> </p> <form action='<?php "$_SERVER[php_SELF]" ?>' method="post" name="submit"> <label> <table width="75%" align="left" cellpadding="0" cellspacing="0"> <tr> <td height="30"width="28%"><div align="right">First Name:</div></td> <td width="2%"> </td> <td width="70%"><input name="first_name" id="first_name" <? if (count($warnings) > 0){ if ($warnings['first_name']) echo "class=\"inputerror\""; }?> value="<?php echo $getuserprofile['first_name'] ?>" /> <?php if (count($warnings) > 0){ echo $warnings["first_name"];} ?> </td> </tr> <tr> <td height="30"><div align="right">last_name: </div></td> <td><label></label></td> <td><input type="text" name="last_name" id="last_name" <? if (count($warnings) > 0){ if ($warnings['last_name']) echo "class=\"inputerror\"";} ?> value="<?php echo $getuserprofile['last_name'] ?>" /> <?php if (count($warnings) > 0){ echo $warnings["last_name"];} ?> </td> </tr> <tr> <td height="30"><div align="right">Birthday :</div></td> <td> </td> <td><?php $months = array (1 => 'January', 'February', 'March', 'April', 'May', 'June','July', 'August', 'September', 'October', 'November', 'December'); $weekday = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); $days = range (1, 31); $years = range (1910, 2015); //********************************************** echo "Day: <select name='day'>"; foreach ($days as $value) { echo '<option '; if($splitDate[0] == $value) echo 'selected="selected"'; echo ' value="'.$value.'">'.$value.'</option>\n'; } echo '</select>'; echo "Month: <select name='month'>"; foreach ($months as $value) { echo '<option '; if($splitDate[1]==$value) echo "selected='selected'"; echo 'value="'.$value.'">'.$value.'</option>\n'; } echo '</select>'; echo "Year: <select name='year'>"; foreach ($years as $value) { echo '<option '; if($splitDate[2]==$value) echo 'selected="selected"'; echo " value='".$value."'>".$value."</option>\n"; } ?> </td> </tr> <tr> <td height="30"><div align="right">Gender : </div></td> <td> </td> <td><select id="gender" name="gender"> <option value="Male" selected="<?php echo $getuserprofile['gender']; ?>" >Male</option> <option value="Female" selected="<?php echo $getuserprofile['gender']; ?>" >Female</option> </select></td> </tr> <tr> <td height="30"><div align="right">Club :</div></td> <td> </td> <td> <?php $lines = file('runningclubs.txt'); echo '<select class="inputedit" id="club" name="club">'; foreach($lines as $line) { if($getuserprofile['club'] == trim($line)){ echo '<option value="'.$line.'" selected="selected">'.$line.'</option>'; }else{ echo '<option value="'.$line.'">'.$line.'</option>'; } } echo "</select>"; ?> <input type="hidden" name="submitted" value="1" /> <input type="hidden" name="id" value="<?php echo $id ?>" /></td> </tr> <tr> <td colspan="3"><div align="center"> <input name="submit" type="submit" class="submit-btn" value="" /> </div></td> </tr> </table> </form> </fieldset> </div> </td> <td width="10%"> </td> </tr> </table> also an extra question is looking at the code can it be made better or shorter or anything?
  2. <?php foreach(explode("\n",$geturls['url1']) as $line) { print "/<a href=http://"'.$line.'"/>'.$line.'</a><br \>\n"; // this line here is'nt correct }?>
  3. i have some script set up to see if a website is vaild.. what im doing is on my 1st page using a textbox to add a number of websites wuch as website1 website2 then using the code to extract them sites from the db and provide links to them... <?php function url($link, $text='') { // Ensure $link is a valid URL $url = url_resolve($link); $fp = @fopen($url, 'r'); if (!$fp) { $title = (!$text ? $link : $text); return "(Broken Link: $link". ($text ? ": {$text}" : "") .")"; } // Grab <title>*</title> from the first "chunk" of data $title = url_grab_title($fp); // No <title> tag in first chunk... if (!$title) { $title = (!$text ? $link : $text); return "<a href='$url'>$title</a>"; } // User gave me some text to append to the link title if ($text) { $title .= ': '. $text; } return "<a href='$url'>$title</a>"; } function url_resolve($url) { global $url_site_domain; if (!preg_match('/^(http|ftp):/', $url)) { // assume it's not "server.tld" and instead "/dir/file.ext" if (!preg_match('/\.(com|net|org|co|uk|edu|info|biz)/', $url)) { $url = $url_site_domain .'/'. $url; } } return 'http://'. preg_replace('/\/\//', '/', $url); } // Fetch a "chunk" of data and look for <title> in it function url_grab_title($fp) { // How many bytes to grab in one chunk. // Most sites seem to have <title> within 512 $chunk_size = 512; $chunk = fread($fp, $chunk_size); $chunk = preg_replace("/(\n|\r)/", '', $chunk); // Look for <title>(.*?)</title> in the text if (preg_match('/<title>(.*?)<\/title>/i', $chunk, $matches)) { return $matches[1]; } return null; } // Run this to test the code function url_test() { print url('hurring.com') ."\n"; // <a href='http://hurring.com'>Hurring.com</a> print url('google.com') ."\n"; // <a href='http://google.com'>Google</a> print url('hurring.com', 'Append me') ."\n"; // <a href='http://hurring.com'>Hurring.com: Append me</a> print url('/code/php/') ."\n"; // <a href='http://hurring.com/code/php/'>Hurring.com: Code: PHP</a> print url('/code/php/', "Append me") ."\n"; // <a href='http://hurring.com/code/php/'>Hurring.com: Code: PHP: Append me</a> print url('groups.yahoo.com/groups/alhkjter/') ."\n"; // <a href='http://groups.yahoo.com/groups/alhkjter/'>groups.yahoo.com/groups/alhkjter/</a> print url('groups.yahoo.com/groups/alhkjter/', 'Pirates') ."\n"; // <a href='http://groups.yahoo.com/groups/alhkjter/'>Pirates</a> print url('garbage') ."\n"; // (Broken Link: garbage) print url('garbage', 'Pirates') ."\n"; // (Broken Link: garbage: Pirates) } mysql_connect("localhost", "runningp", "runnerjp2003") or die(mysql_error()); mysql_select_db("runningp_1") or die(mysql_error()); $code = $_GET['id']; $geturls = mysql_fetch_assoc(mysql_query("SELECT * from url where id='$code'")); if (!$geturls) { die(mysql_error()); } foreach(explode("\n",$geturls['url1']) as $line) { print url($line) ."\n";?> <br \> <? } ?> the thing is if i seem to add multipul addresses my code only works out 1 address and uses the rest as broken link... cna any 1 aid me in fixing this?
  4. thought i would show an exapmle seems im bored lol 1stpage.php <?php session_start(); $_SESSION['letmein'] = true; ?><a href="protected_page.php">Protected area</a> then on our protected_page.php <?php session_start(); if (!$_SESSION['letmein']) { header('Location: 1stpage.php'); echo 'Go through the <a href="1stpage.php">entry page</a> first.'; exit(); } // whatever happens to be at the protected page hope this helps
  5. how about creating a session on one page ( where you want them to come from) then check that session?
  6. go here free open source script for it http://www.smashingapps.com/2008/12/21/krunch-multiple-urls-into-one-short-url.html
  7. with this code <?php error_reporting(0); ini_set("display_errors", "On"); include '../settings.php'; $result = mysql_query("SELECT * FROM pb") or die(mysql_error()); //insert any new entry into the database $uid = mget('uid',$_POST); $dist = mget('dist',$_POST); $pb = mget('pb',$_POST); insert($uid,$dist,$pb); //now display all data $result = mysql_query("SELECT * FROM pb Order by uid,distance") or die(mysql_error()); echo "Current values:<br>"; echo "<table border=1><tr><td>Uid</td><td>Distance</td><td>Pb</td></tr>"; while ( $row = mysql_fetch_array($result) ) { echo "<tr><td>" . $row["uid"] . "</td><td>" . $row["distance"] . "</td><td>" . $row["pb"] . "</td></tr>"; } echo "</table>"; /*-------------------------------------------------------------------------------*/ function insert($uid,$dist,$pb) //insert new or update existing record { if (!$uid) return; //should validate here if (!$dist) return; if (!$pb) return; //see if already exists $sql = "SELECT * FROM pb WHERE uid=$uid AND distance=$dist"; $result = mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($result) >=1) { //already exists $sql = "UPDATE pb Set pb = $pb WHERE uid=$uid AND distance=$dist"; //try updating in case already exists $result = mysql_query($sql) or die(mysql_error()); } else { //need a new record $sql = "INSERT INTO pb SET uid=$uid,distance=$dist,pb=$pb"; echo 'sql is ' . $sql . '<br>'; $result = mysql_query($sql) 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 ''; } /*-------------------------------------------------------------------------------*/ ?> <form method="POST" action="<?php "$_SERVER[php_SELF]" ?>"> <br>Add a new personal best:<table><tr> <td>Uid: <input type=text id=uid name=uid></td><td>Distance: <?php $lines = file('runningevents.txt'); echo '<select class="inputedit" id="dist" name="dist">'; foreach($lines as $line) { echo '<option>'.$line.'</option>'; } echo "</select>"; ?></td> <td>Pb: <input type=text id=pb name=pb></td> </tr></table> <input type=submit value=Submit> </form> </body> </html> Unknown column '800m' in 'where clause' yet i can enter just 800?
  8. hey thnaks but i still get Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/runningp/public_html/members/test.php on line 47 and it wont update fields that are allready there?
  9. what im tryin to do is have it so users on my webpage can enter the personal bests for the distance they ran (its a running website) i have my db set out like so.. -- -- Table structure for table `pb` -- CREATE TABLE IF NOT EXISTS `pb` ( `id` int(11) NOT NULL auto_increment, `uid` int(11) NOT NULL default '0', `pb` int(11) NOT NULL default '0', `distance` int(11) NOT NULL default '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; and my code is as follows <?php include '../settings.php'; $result = mysql_query("SELECT * FROM pb"); //make the table if needed //insert any new entry into the database $uid = mget('uid',$_POST); $dist = mget('dist',$_POST); $pb = mget('pb',$_POST); insert($uid,$dist,$pb); //now display all data $result = mysql_query("SELECT * FROM pb Order by uid,distance"); if (!$result) { echo("<P>Error reading table: " . mysql_error() . "</P>"); exit(); } echo "Current values:<br>"; echo "<table border=1><tr><td>Uid</td><td>Distance</td><td>Pb</td></tr>"; while ( $row = mysql_fetch_array($result) ) { echo "<tr><td>" . $row["uid"] . "</td><td>" . $row["distance"] . "</td><td>" . $row["pb"] . "</td></tr>"; } echo "</table>"; /*-------------------------------------------------------------------------------*/ function insert($uid,$dist,$pb) //insert new or update existing record { if (!$uid) return; //should validate here if (!$dist) return; if (!$pb) return; //see if already exists $sql = "SELECT * FROM pbs WHERE uid=$uid AND distance=$dist"; $result = mysql_query($sql); if (mysql_num_rows($result) >=1) { //already exists $sql = "UPDATE pb Set pb = $pb WHERE uid=$uid AND distance=$dist"; //try updating in case already exists $result = mysql_query($sql); } else { //need a new record $sql = "INSERT INTO pb SET uid=$uid,distance=$dist,pb=$pb"; echo 'sql is ' . $sql . '<br>'; $result = mysql_query($sql); } if (!$result) { echo("<P>Error saving result into table: " . mysql_error() . "<br>" . $sql . "</P>"); } } /*-------------------------------------------------------------------------------*/ //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 ''; } /*-------------------------------------------------------------------------------*/ ?> <form method="POST" action="<?php "$_SERVER[php_SELF]" ?>"> <br>Add a new personal best:<table><tr> <td>Uid: <input type=text id=uid name=uid></td><td>Distance: <input type=text id=dist name=dist></td><td>Pb: <input type=text id=pb name=pb></td> </tr></table> <input type=submit value=Submit> </form> </body> </html> so basicly a user can enter the distance and personal best... it checks to see if the distance has allready been entred , if so updates it, if not enters it. thing is it doesent work! this is the errors i keep getting! i would also like to add once i get it working im going to use drop down menus for distance to narrow down choice! is there anything else you guys could also suggest?
  10. ermmm lol thats might have helped... you see i have been using it on all files through a diff file and seems i didnt use the file on this page then sessions did not start lol... i was really puzzeld lol ty
  11. ok this is very wired... i tried making a page called text.php and entering a bit of code to show my id so i did <?php require_once 'settings.php'; echo $_SESSION['user_id']; ?> and it shows nothing :S i go to an onld page and enter the code and it shows it??? how/why is this happening
  12. the thing is iv never had this problem before... only with this tab function
  13. even why i just try <?php error_reporting(E_ALL); include '../../../settings.php'; echo get_username($_SESSION['user_id']); ?> i get blank area within my tab
  14. thats intresting and coinfusing ok so i got Notice: Undefined index: id in /home/runningp/public_html/info.php on line 7 Notice: Undefined index: pagenum in /home/runningp/public_html/info.php on line 8 Notice: Undefined index: forum in /home/runningp/public_html/info.php on line 9 Notice: Undefined index: notify in /home/runningp/public_html/info.php on line 10 Notice: Undefined index: username in /home/runningp/public_html/info.php on line 12 Notice: Undefined index: HTTPS in /home/runningp/public_html/getuser.php on line 11 Notice: Undefined index: HTTPS in /home/runningp/public_html/getuser.php on line 11 but info.php relys on sessions <?php /* user sessions */ $username= get_username($_SESSION['user_id']); // gest username of online user $id = $_SESSION['user_id']; // gets the online users id /* forum sessions */ $forumpostid=$_GET['id'];// gets the forum post id $pagenum=$_GET['pagenum'];// gets the page number of the forum thread $forum=$_GET['forum']; // gets the forum board name $notify=$_GET['notify']; // see if users doesnt want any more replys $profilename=$_GET['username'];// gets the page number of the forum thread /* time and date functions */ $thedate=date("U"); //get unix timestamp /* get user info from profive via $getuserprofile['gender'] or $getuser['Username']*/ $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']."'")); ?>
  15. ok i have a tab area set up shown below <ul id="countrytabs" class="shadetabs"> <li><a href="#" rel="#default" class="selected">About me</a></li> <li><a href="hobbies.php" rel="countrycontainer">Hobbies</a></li> <li><a href="include/profiletab/external3.htm" rel="countrycontainer">Goals</a></li> <li><a href="include/profiletab/external4.htm" rel="#iframe">Films and Books</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> when i look at hobbies.php my php just wont show! any1 know why? hobbies.php <?php include '../../../settings.php'; include "../../../info.php"; // sets username/id ect $getuser = mysql_fetch_assoc(mysql_query("SELECT * from users where Username='$username'")); $getuserprofile = mysql_fetch_assoc(mysql_query("SELECT * from profile where ID='" .$getuser['ID'] . "'")); ?> <div align="center"> <p>About me <?php echo $id;?> </p> <p> <textarea onKeyPress="return taLimit(this)" onKeyUp="return taCount(this,'myCounter')" name="Description" rows=7 wrap="physical" cols=60><?php echo $username ?></textarea> <br> <br> You have <B><SPAN id=myCounter>255</SPAN></B> characters remaining</p> </div>
  16. i suppose he wants to block ips... but cant as he will be blockin everyone using that router
  17. ok im going with that what would you say is the best way of collecting th users id's and pb's ... this one has had me stumped.. textbox or drop down menus... how would i select how many to show? how would i show them so they can be edited?
  18. -- -------------------------------------------------------- -- -- Table structure for table `pbs` -- CREATE TABLE IF NOT EXISTS `pbs` ( `ID` tinyint(99) NOT NULL auto_increment, `100m` varchar(4) NOT NULL default '', `200m` varchar(4) NOT NULL default '', `300m` varchar(4) NOT NULL default '', PRIMARY KEY (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Dumping data for table `pbs` -- INSERT INTO `pbs` (`ID`, `100m`, `200m`, `300m`) VALUES (1, '10:0', '', '35:0');
  19. ID = 1 100m = 10:0 300m = 35:0 Array ( [iD] => 1 [100m] => 10:0 [200m] => [300m] => 35:0 ) maybe you can offer some advice how i can do this better.... i want users to be able to insert there personal bests.. so the output would look something like pb time 100m 11.00 200m 33.00 800m 2.07.4 but they can have an list of pbs to chose from 100/200/300/400/800/1000/3000/5000 ect.. but only the ones they chose and fill in get shown on their profile.. i have 2 problems realy.. how to get them to fill there pbs in and edit them and also how to show it on their profile page
  20. but my table looks liek this ID 100 200 300 400 1 11.0 2 12.0 3 11.5 ect lol
  21. I tried the code below <?php require_once 'settings.php'; $query = "SELECT * FROM pbs WHERE ID = '1'"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) $bestTimes[] = $row; foreach($bestTimes as $distance => $time) if(!empty($time)) echo $distance." = ".$time."<br>"; ?> but insted out getting the output 100m = 10.0 300m = 30.0 i just get array = 0 my table looks like this 100 200 300 10.0 30.0 im trying just to displays those entries that have a time in them
  22. but where does $numn come into it :S
  23. sorry i seem to be doing somethign wrong here as it displays the bottom of the menu rather then the selcted? <?php $your_date = $getuserprofile['dob']; $splitDate = explode("-", $your_date); echo $splitDate[0];//day echo $splitDate[1];//month echo $splitDate[2];//year // i have cut the code between out $months = array (1 => 'January', 'February', 'March', 'April', 'May', 'June','July', 'August', 'September', 'October', 'November', 'December'); $weekday = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); $days = range (1, 31); $years = range (1910, 2015); //********************************************** echo "Day: <select name='day'>"; foreach ($days as $value) { { echo '<option value="'.$value.'" selected="'.$splitDate[0].'">'.$value.'</option>\n'; } echo '</select>'; echo "Month: <select name='month'>"; foreach ($months as $value) { echo '<option selected="'.$splitDate[1].'" value="'.$value.'">'.$value.'</option>\n'; } echo '</select>'; echo "Year: <select name='year'>"; foreach ($years as $value) { echo '<option selected="'.$splitDate[2].'" value="'.$value.'">'.$value.'</option>\n'; } ?>
×
×
  • 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.