Jump to content

jcbones

Staff Alumni
  • Posts

    2,653
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by jcbones

  1. Or, you could use native functions echo nl2br($text); nl2br()
  2. header() must be used before any output to the browser. So it must go at the very top of the script.
  3. Then put it in a sub-directory, and .htaccess it as "deny all". Then no-one can access it via browser. If they get it any other way, then you have much more to worry about.
  4. jcbones

    date/week

    The good thing about PHP is that it can be done multiple ways. <?php $sw = strtotime('2010W30'); echo date('m-d-Y',$sw) . '<br/>' . date('m-d-Y',strtotime('+6 days',$sw)); ?>
  5. Try it using this query $sql = "SELECT DISTINCT(followed_post) FROM subscriptions WHERE username = '$username'";
  6. $offset = (isset($_GET['start'])) ? (int)$_GET["start"] : 0; $rowsPerPage = (isset($_GET['count'])) ? (int)$_GET["count"] : 10; $next = "<li><a href=\"all.php?start=" . ($offset + $rowsPerPage) . "&count={$rowsPerPage}\" target=\"_replace\">View More</a></li>";
  7. I hate using @, but this is as good of a case as any. else { if(!@mail($to, $subject, $message, $headers)) { echo 'There was an error sending the email, please try again.'; } else { echo "Your email has been sent! <a href='view.php?id=".$id."'>Return to the listing.</a>"; } } You may not even have to use the @ symbol for this to suppress the error.
  8. $result = mysql_query($q) or die('<br />Query string: ' . $q . '<br />Produced error: ' . mysql_error() . '<br />'); $row = mysql_fetch_array($result) or die(mysql_error()); if($row['count'] == 3){ die("You have already attacked this person 3 times this hour."); }
  9. I didn't see a form on that page, so try your Post or Session data like this. $gender= (isset($_POST["gender"])) ? $_POST['gender'] : $_SESSION['gender']; $genderPref= (isset($_POST["genderPref"])) ? $_POST['genderPref'] : $_SESSION['genderPref']; $ageMin= (isset($_POST["ageMin"])) ? $_POST['ageMin'] : $_SESSION['ageMin']; $ageMax= (isset($_POST["ageMax"])) ? $_POST['ageMax'] : $_SESSION['ageMax']; $today = date("Y"); $year1 = $today-$ageMin; $year2 = $today-$ageMax; $_SESSION['gender'] = $gender; // store session data $_SESSION['genderPref'] = $genderPref; // store session data $_SESSION['ageMin'] = $ageMin; // store session data $_SESSION['ageMax'] = $ageMax; // store session data //$_SESSION['today'] = $today; // store session data (NOT NEEDED, as date('Y') will return today. //$_SESSION['year1'] = $year1; // store session data (NOT NEEDED, Let the calcs work. //$_SESSION['year2'] = $year2; // store session data (NOT NEEDED, Let the calcs work.
  10. > equals "greater than" < equals "less than" The point always points at the lower value. if($number_messages < 200) { echo "The maximum message amount is 200."; //IF $number_messages is LESS THAN 200, print this message. }
  11. Is your database column a date or timestamp column? If so. SELECT * FROM table WHERE MONTH(datecolumn) < MONTH(NOW()) AND YEAR(datecolumn) = YEAR(NOW());
  12. I would be more than happy to tell you. But, you have confused me so much on what you want, I don't know what "right" is.
  13. Try: //Change: window.setInterval(autoSave, 20000); // 20 seconds //To: window.setInterval("autoSave()", 20000); // 20 seconds //Change: var params = "?status=" + status; //To var params = "status="+status; After all of that, open the page in firefox, and select 'Tools->Error Console'. Watch the error console for any errors the script might throw.
  14. This line: $z = @mysql_fetch_row($z); Would make the array; $z[0] = 5; //the id. $z[1] = 'Team'; //team name.
  15. Maybe adding a drop down for the time, or rather 3 drop downs "hour" "minute" "am/pm" And for the date, I use the jQuery datepicker
  16. I think you need to use setInterval(). <script type="text/javscript"> var seconds = 5; var interval = seconds * 1000; setInterval('ajaxFunction', interval); //AJAX Function </script>
  17. From looking at your code, the Team id would be. Either: $row['team']; OR, $z[0];
  18. Try: //*Edit*// if(isset($_REQUEST['update_listing'])) { list($month, $day, $year) = explode('/', $_REQUEST['date']); if(strlen($month<2)){$month = "0".$month;} if(strlen($day<2)){$day = "0".$day;} if(strlen($year<4)){$year = "20".substr($year,-2);} $date = $year."-".$month."-".$day; Also, you are getting header errors, make sure your file has no spaces above, or in front of, the "<?php", or after the "?>" in your index file, and your included file.
  19. I think if you changed the line: mysqli_query($dbc, $query); to mysqli_query($dbc, $query) or die(mysqli_error($dbc)); You would find that there is an error in: $query = "UPDATE userDB SET currentdate = '$currentdate', bodyweight = '$bodyweight', bmi = '$bmi', bloodpressure = '$bloodpressure', hdl = '$hdl', ldl = '$ldl' "." totalcholesterol = '$totalcholesterol', triglycerides = '$triglycerides', glucoselevels = '$glucoselevels', bodycomposition = '$bodycomposition', waist = '$waist', hip = '$hip' WHERE user_id = '" . $_SESSION['user_id'] . "'"; HERE: ldl = '$ldl' "." totalcholesterol = '$totalcholesterol' Should be changed to: ldl = '$ldl', totalcholesterol = '$totalcholesterol'
  20. '".$siteCode." <- MISSING a single quote('); Full Line: $dbQuery = mysql_query("INSERT INTO user_signup(event_id, firstname, lastname, email, phone, state, sitecode, ip_address, date) VALUES (".$event.", '".$fistName."', '".$lastName."', '".$email."', '".$phone."', '".$state."', '".$siteCode."', '".$ipAddress."', ".time().")", $dbConn);
  21. You need to take the array one step further: Setting an input element into an array, makes the $_POST array into a multidimensional array. //dump the array to the page to get a look at how it is built. echo '<pre>'; print_r($_POST); echo '</pre>'; //To get the values from the checkboxes. foreach($_POST['cp_checkbox_help'] as $value) { echo '<br />' . $value; }
  22. I added some de-bugging into this script. PS. save this as index2.php, so you don't overwrite what is already there, and user's won't see the de-bugging. <?php include("includes/connections.php"); $datetoday = date("Y-m-d"); $futuredate = "2074-12-12"; $pastdate = "2000-12-12"; //************COMP UPDATE*****************// if(isset($_REQUEST['listing_id'])) { if(isset($_REQUEST['delete'])) { mysql_query("DELETE FROM listing WHERE listing_id = ".$_REQUEST['listing_id']."") or die('Delete Error: ' . mysql_error()); header("Location:index.php#".$_REQUEST['listing_id'].""); } } //*Edit*// if(isset($_REQUEST['update_listing'])) { list($month, $day, $year) = explode('/', $_REQUEST['date']); if(strlen($month<2)){$month = "0".$month;} if(strlen($day<2)){$day = "0".$day;} $date = "20".$year."-".$month."-".$day; mysql_query("UPDATE listing SET date='".$date."', bands='".$_REQUEST['bands']."', venue='".$_REQUEST['venue']."',venue_url='".$_REQUEST['venue_url']."',age_id='".$_REQUEST['age_id']."',cost='".$_REQUEST['cost']."',door_cost='".$_REQUEST['door_cost']."',venue_start='".$_REQUEST['venue_start']."',music_start='".$_REQUEST['music_start']."',comments='".$_REQUEST['comments']."' WHERE listing_id = ".$_SESSION['listing_id']."") or die('Update Error ' . mysql_error()); unset ($_SESSION['listing_id']); } /*ADD COMP*/ if(isset($_REQUEST['add_listing'])) { list($month, $day, $year) = explode('/', $_REQUEST['date']); if(strlen($month<2)){$month = "0".$month;} if(strlen($day<2)){$day = "0".$day;} $date = "20".$year."-".$month."-".$day; if($_REQUEST['venue_start']=='HH:MM') $venue_start=""; else $venue_start=$_REQUEST['venue_start']; if($_REQUEST['music_start']=='HH:MM') $music_start=""; else $music_start=$_REQUEST['music_start']; mysql_query("INSERT INTO listing (date, bands, venue, venue_url, age_id, cost, door_cost, venue_start, music_start, comments, approved) VALUES ('".$date."', '".$_REQUEST['bands']."', '".$_REQUEST['venue']."', '".$_REQUEST['venue_url']."', '".$_REQUEST['age_id']."', '".$_REQUEST['cost']."', '".$_REQUEST['door_cost']."', '".$venue_start."', '".$music_start."', '".$_REQUEST['comments']."', '0')") or die('Insert error: ' . mysql_error()); unset ($_SESSION['listing_id']); header("Location:index.php?thanks"); } //*************END COMP UPDATE***************// //Include header include("includes/header.php"); //Top Bar info/Nav $pagetitle = "Portland, Salem, Eugene Metal Show Listings"; $to = "admin@portlandmetal.net"; $subject = "New show"; $body = ""; echo "<div class='titlebox'>".$pagetitle.""; echo "</div><div class='contentbox'>"; if(isset($_REQUEST['thanks'])) { echo "<div class='thanksbox'>"; echo "Thanks for submitting a show. If you don't see it listed here within 24 hours, please contact me at admin@portlandmetal.net (we have experienced a lot of issues with the code and need to troubleshoot!)."; echo "</div>"; mail($to, $subject, $body); } //*************************************************RACE REGISTRATION FUNCTION************************* if(isset($_REQUEST['upcoming'])) { $listingstring = "SELECT listing_id, date, bands, venue, venue_url, age_id, cost, door_cost, venue_start, music_start, comments FROM listing WHERE approved = '1' AND date BETWEEN '".$datetoday."' AND '".$futuredate."' ORDER by approved, date"; } else if(isset($_REQUEST['archives'])) { $listingstring = "SELECT listing_id, date, bands, venue, venue_url, age_id, cost, door_cost, venue_start, music_start, comments FROM listing WHERE approved = '1' AND date BETWEEN '".$pastdate."' AND '".$datetoday."' ORDER by approved, date DESC"; } else { $listingstring = "SELECT listing_id, date, bands, venue, venue_url, age_id, cost, door_cost, venue_start, music_start, comments FROM listing WHERE approved = '1' AND date BETWEEN '".$datetoday."' AND '".$futuredate."' ORDER by approved, date"; } $listingquery = mysql_query($listingstring) or die('Error in: ' . $listingstring . ' <br />' . mysql_error()); ?> <form method="POST" action="index.php"> <div class="graybox margin"> <?php if(isset($_REQUEST['upcoming'])) { echo "<strong>Current Upcoming Shows</strong> <a href='index.php?archives'>See Archives</a><br /><br />"; } else if(isset($_REQUEST['archives'])) { echo "<strong>Past Shows</strong> <a href='index.php?upcoming'>See Upcoming Listings</a><br /><br /><br />"; } else { echo "<strong>Current Upcoming Shows</strong> <a href='index.php?archives'>See Archives</a><br /><br />"; } ?> <table width="100%" cellpadding="8px"> <?php while($row = mysql_fetch_assoc($listingquery)) { $bands = $row['bands']; if(strlen($bands)>200) { $bands = substr($bands, 0, 200)."..."; } //IF THE USER SELECTED TO EDIT A RACE// if(isset($_REQUEST['details'])) { if($_REQUEST['listing_id']==$row['listing_id']) { $_SESSION['listing_id']=$row['listing_id']; ?> <tr> <td width="90%" colspan="7" class="listing_details"> <a name="details"></a> <h2><?php echo $row['bands'];?></h2> <h3><?php echo date("l, F jS Y",strtotime($row['date']));?></h3> <strong><a href="<?php echo $row['venue_url'];?>" target="blank"><?php echo $row['venue'];?></a></strong> <?php if($row['age_id']==1) echo "All Ages";?> <?php if($row['age_id']==2) echo "18+";?> <?php if($row['age_id']==3) echo "21+";?><br /> <?php if(empty($row['cost'])) { echo "$".$row['door_cost']." at the door"; } else if(empty($row['door_cost'])) { echo "$".$row['cost']; } else { echo "$".$row['cost'].", $".$row['door_cost']." at the door"; } echo "<br />"; if($row['venue_start']=="00:00:00") echo date("g:i a",strtotime($row['music_start'])); else if($row['music_start']=="00:00:00") echo date("g:i a",strtotime($row['venue_start'])); else echo "Doors Open at ".date("g:i a",strtotime($row['venue_start'])).", Music Starts at ".date("g:i a",strtotime($row['music_start'])); ?><br /> <?php if(empty($row['comments'])){} else{ echo "<br /><strong>Additional Comments</strong><br />"; echo $row['comments']; }?> <br /> <input type="hidden" name="listing_id" value="<?php $row['listing_id']?>" /> <?php if(isset($_REQUEST['archives'])) { echo "<input type='hidden' name='archives'/>"; } ?> </td> <td width="10%" class="listing_details"> <input type="submit" name="cancel_listing" value="Close Details" /> </td> </tr> <?php } else{ echo "<tr>"; echo "<td width='8%'><a name='".$row['listing_id']."'></a>".date("M j (D)",strtotime($row['date']))."</td>"; echo "<td width='8%'><strong>".$bands."</strong></td>"; echo "<td width='8%'>".date("g:i a",strtotime($row['venue_start']))."</td>"; if(empty($row['cost'])) { echo "<td width='16%'>$".$row['door_cost']." at the door</td>"; } else if(empty($row['door_cost'])) { echo "<td width='16%'>$".$row['cost']."</td>"; } else { echo "<td width='16%'>$".$row['cost'].", $".$row['door_cost']." at the door</td>"; } echo "<td width='16%'><a href='".$row['venue_url']."' target='blank'>".$row['venue']."</a></td>"; echo "<td width='8%'>"; if($row['age_id']=='1')echo "All Ages"; else if($row['age_id']=='2')echo "18+"; else if($row['age_id']=='3')echo "21+"; echo "</td>"; echo "<td width='26%'>"; echo "</td>"; echo "<input type='hidden' value='".$row['listing_id']."' name='listing_id'>"; if(isset($_REQUEST['archives'])) { echo "<td width='10%'> <a href='index.php?archives&listing_id=".$row['listing_id']."&details=1#details'>Details</a></td>"; } else{ echo "<td width='10%'> <a href='index.php?listing_id=".$row['listing_id']."&details=1#details'>Details</a></td>"; } echo "</tr>"; } } else{ echo "<tr>"; echo "<td width='8%'><a name='".$row['listing_id']."'></a>".date("M j (D)",strtotime($row['date']))."</td>"; echo "<td width='24%'><strong>".$bands."</strong></td>"; if($row['venue_start']=="00:00:00") echo "<td width='8%'>".date("g:i a",strtotime($row['music_start']))."</td>"; else if($row['music_start']=="00:00:00") echo "<td width='8%'>".date("g:i a",strtotime($row['venue_start']))."</td>"; else echo "<td width='8%'>".date("g:i a",strtotime($row['venue_start']))."</td>"; if(empty($row['cost'])) { echo "<td width='16%'>$".$row['door_cost']." at the door</td>"; } else if(empty($row['door_cost'])) { echo "<td width='16%'>$".$row['cost']."</td>"; } else { echo "<td width='16%'>$".$row['cost'].", $".$row['door_cost']." at the door</td>"; } echo "<td width='16%'><a href='".$row['venue_url']."' target='blank'>".$row['venue']."</a></td>"; echo "<td width='8%'>"; if($row['age_id']=='1')echo "All Ages"; else if($row['age_id']=='2')echo "18+"; else if($row['age_id']=='3')echo "21+"; echo "</td>"; echo "<td width='16%'>"; echo "</td>"; echo "<input type='hidden' value='".$row['listing_id']."' name='listing_id'>"; if(isset($_REQUEST['archives'])) { echo "<td width='20%'> <a href='index.php?archives&listing_id=".$row['listing_id']."&details=1#details'>Details</a></td>"; } else{ echo "<td width='20%'> <a href='index.php?listing_id=".$row['listing_id']."&details=1#details'>Details</a></td>"; } echo "</tr>"; echo "</tr>"; } } echo "</table>"; echo "<a name='new_listing'></a>"; if(isset($_REQUEST['new_listing'])) { $_SESSION['listing_id']=$row['listing_id']; ?> <div class="addnewcontainer"><div class="addnewtitle"></div></div> <div class="add_listing_public"> <label for="date">Date: </label><input name="date" type='text' value="MM/DD/YY"/><br /> <label for="bands">Bands: </label><input style="width:350px" name="bands" type="text"/><br /> <label for="venue">Venue: </label><input style="width:300px;" name="venue" type="text" /><br /> <label for="venue_url">Website: </label><input style="width:300px;" name="venue_url" type="text" value="http://" /><br /> <label for="age_id">Age: </label> <select name="age_id"> <option value="1">All Ages</option> <option value="2">18+</option> <option value="3">21+</option> </select><br /> <label for="cost">Cost: $</label><input style="width:3em;" name="cost" type="text" /><br /> <label for="door_cost">Door Cost: $</label><input style="width:3em;" name="door_cost" type="text" /><br /> <label for="venue_start">Venue Start: </label><input name="venue_start" type="text" value="HH:MM" /> <span class='notes'>(Military Time)</span><br /> <label for="music_start">Music Start: </label><input name="music_start" type="text" value="HH:MM"/> <span class='notes'>(Military Time)</span><br /> <label for="comments">Comments: </label><br /> <textarea cols="60" rows="4" name="comments" type="text" /></textarea><br /> <input type="submit" name="add_listing" value="Add" /> <input type="submit" name="cancel_listing" value="Cancel" /> <?php } ?> <br /> <?php if(isset($_REQUEST['new_listing'])) echo""; else{?> <div class="listshow">Know about a show? Submit one! <br /> It's free and fast (no account required):<br /> <br /> <input type="submit" name="new_listing" value="Submit New Show" /></div> <?php } ?> </div></div> </div> </form> <?php //*************************************************END RACE REGISTRATION FUNCTION************************* echo"</div>"; //INCLUDE FOOTER include("includes/footer.php"); ?>
  23. And to use Mchl's function in a loop to show multiple numbers. $result = 1; for($i = 0; $i < 100; $i++) { $result = nextNumber($result); echo $result . '<br />'; }
  24. Any variable declared in an included page, is available on any other page in the include structure. Try this: Test1.php <?php include('Test2.php'); echo $test; ?> Test2.php <?php include('Test3.php'); ?> Test3.php <?php $test = 'This is only a Test'; ?> Now run "Test1.php".
  25. I assumed (that gets you in trouble), that your users table, and the userstats table is tied together with "id". I tried to incorporate all of your request in this script. It may or may not work as I didn't test it. But, that is all you can expect for free <?php session_start(); include_once('../inc/connect.php'); $today = date("Y-m-d"); $sort = $_GET['sort']; $delete = $_GET['delete']; $dir = $_GET['dir']; $id = (isset($_GET['id']) && preg_match('~^[0-9]+$~',$_GET['id'])) ? $_GET['id'] : false; $submit = $_POST['submit']; switch($dir) { case 'ASC': $dir = 'DESC'; break; case 'DESC'; $dir = 'ASC'; break; default: $dir = 'ASC'; } switch($sort) { case 'username': $sorted = 'u.username'; break; case 'email': $sorted = 'u.email'; break; case 'type': $sorted = 'u.type'; break; case 'referrer': $sorted = 'u.referrer'; break; case 'level': $sorted = 's.level'; break; case 'exp': $sorted = 's.exp'; break; case 'credits': $sorted = 's.credits'; break; default: $sorted = 'u.id'; } //Assuming the tables user and userstats are tied together with the id. $sql = "SELECT u.*,s.level,s.exp,s.credits FROM users as u, userstats as s WHERE u.id = s.id ORDER BY $sorted $dir"; if ($delete==true && $id !== false){ //Assuming that users and userstats are tied together with the id. mysql_query("DELETE FROM users WHERE id='$id' LIMIT 1"); mysql_query("DELETE FROM userstats WHERE id='$id' LIMIT 1"); } if ($ban==true){ } // head echo " <html> <head> <title>Users</title> <style> a:link{ text-decoration: none; color: #519904; } a:visited{ text-decoration: none; color: #519904; } a:hover{ text-decoration: none; color: #4296ce; } #joined{ position: absolute; width: 200px; top: 35px; left: 465px; } </style> </head> <body> "; echo "<h2 align='center'>Members</h2><br /><table border='1' align='center'> <tr> <th bgcolor='#cccccc'><a href='users.php?sort=id&dir=" . $dir . "'>ID</a></th> <th bgcolor='#cccccc'><a href='users.php?sort=username&dir=" . $dir . "'>Username</a></th> <th bgcolor='#cccccc'><a href='users.php?sort=email&dir=" . $dir . "'>Email</a></th> <th bgcolor='#cccccc'><a href='users.php?sort=type&dir=" . $dir . "'>Type</a></th> <th bgcolor='#cccccc'><a href='users.php?sort=referrer&dir=" . $dir . "'>Referrer</a></th> <!-- Level, Exp, and Credits are in the table called userstats --> <th bgcolor='#cccccc'><a href='users.php?sort=level&dir=" . $dir . "'>Level</a></th> <th bgcolor='#cccccc'><a href='users.php?sort=exp&dir=" . $dir . "'>Exp</a></th> <th bgcolor='#cccccc'><a href='users.php?sort=credits&dir=" . $dir . "'>Credits</a></th> </tr><form>"; $result = mysql_query($sql); $recentmembers = 0; while($row = mysql_fetch_array($result)) { $joined = $row['joindate']; if ($joined==$today){ $recentmembers += 1; } echo "<tr>"; echo "<td align='center' width='40'>" .$row['id']. "</td>"; echo "<td align='center' width='130'><input type='text' name='username' value='" .$row['username']. "'></td>"; echo "<td align='center' width='230'><input type='text' name='email' value='" .$row['email']. "' size='35'></td>"; echo "<td align='center' width='10'><input type='text' name='member' value='" .$row['member']. "' size='2'></td>"; echo "<td align='center' width='175'><input type='text' name='referrer' value='" .$row['referrer']. "' size='25'></td>"; echo "<td align='center' width='10'><input type='text' name='level' value='" .$row['level']. "' size='2'></td>"; echo "<td align='center' width='10'><input type='text' name='exp' value='" .$row['exp']. "' size='10'></td>"; echo "<td align='center' width='10'><input type='text' name='credits' value='" .$row['credits']. "' size='20'></td>"; echo "<td align='center' width='10'><a href='users.php?delete=true&id=" .$row['id']. "' onclick=\"return confirm('Are you sure you wish to Delete this user?');\">Delete</a></td>"; echo "</tr>"; } echo "</table><br /><center><input type='submit' name='submit' value='Submit Changes'><input type='reset' name='reset' value='Reset'></form></center>"; echo "<br /><div id='joined'>Joined Today: ".$recentmembers."</div>"; // Footer echo " </body> </html> "; // Change User's Information if (isset($submit)){ // UPDATE USERS INFORMATION FOR ONLY THE ROWS THAT HAVE BEEN MODIFIED } ?>
×
×
  • 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.