Jump to content

downah

Members
  • Posts

    127
  • Joined

  • Last visited

Everything posted by downah

  1. It was about the script above it, so the code was there either way I fixed it so thanks to everyone who tried to help
  2. I see, the script does not work though, neither when I go to image.php and set the id to a member
  3. Hi guys I have this script here, which counts the characters and lines, now currently though it still allows lines and characters to go into minus, but I would like it to also put up a warning box so it stops the user from being able to put in more text, could you help me out? javascript: function textCounter(theField,theCharCounter,theLineCounter,maxChars,maxLines,maxPerLine) { var strTemp = ""; var strLineCounter = 0; var strCharCounter = 0; for (var i = 0; i < theField.value.length; i++) { var strChar = theField.value.substring(i, i + 1); if (strChar == '\n') { strTemp += strChar; strCharCounter = 1; strLineCounter += 1; } else if (strCharCounter == maxPerLine) { strTemp += '\n' + strChar; strCharCounter = 1; strLineCounter += 1; } else { strTemp += strChar; strCharCounter ++; } } theCharCounter.value = maxChars - strTemp.length; theLineCounter.value = maxLines - strLineCounter; } and used in code: <textarea name="comment" cols="50" rows="10" wrap="VIRTUAL" onKeyUp="textCounter(theForm.comment,theForm.remChars,remLines,900,30,50);"></textarea> <br><input name=remChars type=text value="900" size=3 maxlength=3 readonly> characters left <br><input name=remLines type=text value="30" size=3 maxlength=3 readonly> lines left<br>
  4. Haha just tryed it out works perfect, didn't think it would, I solved my own topic in post 1
  5. <?php $year = date('Y', strtotime($row['dob'])); $month = date('m', strtotime($row['dob'])); $day = date('d', strtotime($row['dob'])); ?> You mean this jesi? I hadn't actually tried it yet just thought of it while I was writing the topic
  6. This is what I have.. I am not too sure with what you mean, I am using this exact script in another page and it is working fine, it seems because of the $strWhere ? <?php session_start(); include 'connect.php'; require_once('calendar/classes/tc_calendar.php'); if(!isset($_SESSION['username'])) { echo '<div align="center">'; echo 'You have to be a registered member to be able to view events.<br><br> <a href="register.html">Click here to register</a>'; echo '<br><br><br><br>Or if you are already a member, please login to use this area.<br>'; echo ' <form method="POST" action="loginverification.php"> <table border="0"> <tr><td> Username: </td><td><input type="text" name="username" size="15" /></td></tr> <tr><td>Password:</td><td> <input type="password" name="password" size="15" /></td></tr> </table> <div align="center"> <p><input type="submit" value="Login" /></p> </div> </form>'; echo '</div>'; } else{ $page_name="searchevents.php"; // If you use this code with a different page ( or file ) name then change this $start=$_GET['start']; if(strlen($start) > 0 and !is_numeric($start)){ echo "Data Error"; exit; } $eu = ($start - 0); $limit = 20; // No of records to be shown per page. $this1 = $eu + $limit; $back = $eu - $limit; $next = $eu + $limit; /////////////// WE have to find out the number of records in our table. We will use this to break the pages/////// $theDate = isset($_REQUEST["date1"]) ? $_REQUEST["date1"] : ""; $eventcounty = $_POST['county']; $eventdescriptionheader = $_POST['eventdescriptionheader']; $hoster = $_POST['hoster']; $arrWhere = array(); if($_POST['searchcounty'] == "yes") { $arrWhere['eventcounty'] = mysql_real_escape_string($eventcounty); } if($_POST['searchdate'] == "yes") { $arrWhere['eventdate'] = mysql_real_escape_string($theDate); } if($_POST['searchtitle'] == "yes") { $arrWhere['eventdescriptionheader'] = mysql_real_escape_string($eventdescriptionheader); } if($_POST['searchhoster'] == "yes") { $arrWhere['hoster'] = mysql_real_escape_string($hoster); } if($_POST['dogfriendly'] == "No") { $dogfriendly = $_POST['dogfriendly']; $arrWhere['dogfriendly'] = mysql_real_escape_string($dogfriendly); } if($_POST['dogfriendly'] == "Yes") { $dogfriendly = $_POST['dogfriendly']; $arrWhere['dogfriendly'] = mysql_real_escape_string($dogfriendly); } if($_POST['childfriendly'] == "No") { $childfriendly = $_POST['childfriendly']; $arrWhere['childfriendly'] = mysql_real_escape_string($childfriendly); } if($_POST['childfriendly'] == "Yes") { $childfriendly = $_POST['childfriendly']; $arrWhere['childfriendly'] = mysql_real_escape_string($childfriendly); } if($_POST['singlesonly'] == "No") { $singlesonly = $_POST['singlesonly']; $arrWhere['singlesonly'] = mysql_real_escape_string($singlesonly); } if($_POST['singlesonly'] == "Yes") { $singlesonly = $_POST['singlesonly']; $arrWhere['singlesonly'] = mysql_real_escape_string($singlesonly); } if($_POST['couplesonly'] == "No") { $couplesonly = $_POST['couplesonly']; $arrWhere['couplesonly'] = mysql_real_escape_string($couplesonly); } if($_POST['couplesonly'] == "Yes") { $couplesonly = $_POST['couplesonly']; $arrWhere['couplesonly'] = mysql_real_escape_string($couplesonly); } if($_POST['costinvolved'] == "No") { $costinvolved = $_POST['costinvolved']; $arrWhere['costinvolved'] = mysql_real_escape_string($costinvolved); } if($_POST['costinvolved'] == "Yes") { $costinvolved = $_POST['costinvolved']; $arrWhere['costinvolved'] = mysql_real_escape_string($costinvolved); } $strWhere = 'WHERE '; if(count($arrWhere)){ foreach($arrWhere as $strKey=>$strValue){ $strWhere .= ' '.$strKey.' = '.'"'.$strValue.'" AND '; } $strWhere .= ' 1 '; } else { $strWhere = ' 1'; // if you want all records to be selected if no radio is checked. if you want no records make this as '0' } $strSql = "SELECT * FROM Events $strWhere ORDER BY eventdate ASC limit $eu, $limit"; $query2="SELECT count(*) as cnt FROM Events $strWhere"; $result2 = mysql_query($query2); $row = mysql_fetch_array($result2); $nume = $row['cnt']; $result = mysql_query($strSql); echo '<br>'; echo "<table border='0'> <tr> <th>Date/Time</th> <th>Event</th> <th>Participants</th> <th>Hoster</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>"; print date('d M Y', strtotime($row['eventdate'])); echo " "; echo $row['starttime'] . "</td>"; echo '<td><a href="showevent.php?eventsID='; echo $row['eventsID']; echo '">'; echo $row['eventdescriptionheader']; echo "</a></td>"; echo "<td>" . $row['currentparticipants'] . "/" . $row['maxparticipants'] . "</td>"; echo "<td>" . $row['hoster'] . "</td>"; echo "</tr>"; } echo '</table>'; echo '<br><br><INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;">'; ////////////////////////////// End of displaying the table with records //////////////////////// /////////////////////////////// if($nume > $limit ){ // Let us display bottom links if sufficient records are there for paging /////////////// Start the bottom links with Prev and next link with page numbers ///////////////// echo "<table align = 'center' width='50%'><tr><td align='left' width='30%'>"; //// if our variable $back is equal to 0 or more then only we will display the link to move back //////// if($back >=0) { print "<a href='$page_name?start=$back'>PREV</a>"; } //////////////// Let us display the page links at center. We will not display the current page as a link /////////// echo "</td><td align=center width='30%'>"; $i=0; $l=1; for($i=0;$i < $nume;$i=$i+$limit){ if($i <> $eu){ echo " <a href='$page_name?start=$i'>$l</a> "; } else { echo "$l";} /// Current page is not displayed as link and given font color red $l=$l+1; } echo "</td><td align='right' width='30%'>"; ///////////// If we are not in the last page then Next link will be displayed. Here we check that ///// if($this1 < $nume) { print "<a href='$page_name?start=$next'>NEXT</a>";} echo "</td></tr></table>"; } } ?>
  7. The message should have its own unique ID
  8. Well that should be fixed first then, try changing $x = " --- <a href=main.php?username=$username&password=$password&action=delpost&id=$id>Delete Post</a>";} to $x = " --- <a href=main.php?username=$username&password=$password&id=$id&action=delpost>Delete Post</a>";} That is the first thing I'd try, not sure if it will work though.
  9. definitely, but I am working with that as a quick temporary solution, thought id share it
  10. So basically: $result = mysql_query("DELETE FROM `boards` WHERE `boardname`='$board' AND `id`='$id'") or die(mysql_error()); Although like jesi says you might be trying to delete the wrong part, don't you have a different table called post's / threads ? PS. jesi you might be able to know my problem and seem very knowledgeable, mind having a read in the topic below about splitting up data?
  11. simple temporary fix so only one person can delete <?php if($_SESSION['username'] == "theuserthatcandelete") { //delete button } else { //nodelete button } ?>
  12. Hmm try $result = mysql_query("DELETE * FROM `boards` WHERE `boardname`='$board', `id`='$id'"); to $result = mysql_query("DELETE FROM `boards` WHERE `boardname`='$board', `id`='$id'"); I don't think you need the star for delete
  13. Well then shouldnt you GET the id to delete it? redboard <? $command = 1; if (getlevel(get("plane"),coords(),"board") == "") echo "There is no bulletin board here.<br>\n"; else{ $board = getlevel(get("plane"),coords(),"board"); if ($admin == "Y+" || $admin == "Y"){ $x = " --- <a href=main.php?username=$username&password=$password&action=delpost&id=$id>Delete Post</a>";} $dbh=dbconnect() or die ("Userlist read error: " . mysql_error()."<br>"); mysql_select_db("XX"); $result = mysql_query("SELECT * FROM boards WHERE boardname='$board' ORDER BY id LIMIT 10"); $post = mysql_fetch_assoc($result); while ($row = mysql_fetch_array($result)){ echo stripslashes($row['message']) . "$x<br>" . " --- ".stripslashes($row['username']). " on ".stripslashes($row['time']) ."<hr width=90%>"; } } ?> delpost function delpost() { if (getlevel(get("plane"),coords(),"board") == "" && ( get("admin") == "Y+" || get("admin") == "Y")) echo "There is no bulletin board here.<br>\n"; else{ $board = getlevel(get("plane"),coords(),"board"); $dbh=dbconnect() or die ("Userlist read error: " . mysql_error()."<br>"); mysql_select_db("XX"); $id = $_GET['id']; $result = mysql_query("DELETE * FROM `boards` WHERE `boardname`='$board', `id`='$id'"); echo "Message deleted.<br>\n"; }} Doesn't this work?
  14. If I understand correctly.. does each post have a unique id? <a href=main.php?username=$username&password=$password&action=delpost>Delete Post</a> to <a href=main.php?username=$username&password=$password&action=delpost&postid=$postid>Delete Post</a> and $postid = $_GET['postid']; $result = mysql_query("DELETE * FROM `boards` WHERE `boardname`='$board', `id`='$id' AND postid='$postid'");
  15. Thanks a lot both of you, I used the list as it seemed very easy and straightforward, works perfect too, although I am trying to get the month to show as date(M) so it shows May instead of 05 - <?php list($year,$monthM,$day) = explode('-',$row['dob']); $month = date('M', $monthM); ?> as soon as I added $month = date('M', $monthM); Whatever month I choose it turns back 01 or Jan, what am I doing wrong?
  16. Basically I have a date of birth field (date) now how would I go about splitting that date field into 3 variables $year $month and $day? Any small push forward is much appreciated, I have searched but it seems that I might not be putting it into words correctly. Actually while writing this I suppose I might of thought of the solution <?php $year = date('Y', strtotime($row['dob'])); $month = date('m', strtotime($row['dob'])); $day = date('d', strtotime($row['dob'])); ?> Would that be how you would go about it?
  17. Yup the reason it doesn't work is because you don't declare $username in delete, make sure like aykay's script that you use $_GET['username'] and when linking to the delete add ?username=$username otherwise the GET can't get it
  18. Done that still not showing results on the other pages
  19. For anyone else who could help that would be great! Trying to insert pages, it is breaking it up right but when I click on 1 or next I get this syntax 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 '1 ORDER BY eventdate ASC' at line 1 <?php include 'connect.php'; require_once('calendar/classes/tc_calendar.php'); session_start(); if(!isset($_SESSION['username'])) { echo '<div align="center">'; echo 'You have to be a registered member to be able to view events.<br><br> <a href="register.html">Click here to register</a>'; echo '<br><br><br><br>Or if you are already a member, please login to use this area.<br>'; echo ' <form method="POST" action="loginverification.php"> <table border="0"> <tr><td> Username: </td><td><input type="text" name="username" size="15" /></td></tr> <tr><td>Password:</td><td> <input type="password" name="password" size="15" /></td></tr> </table> <div align="center"> <p><input type="submit" value="Login" /></p> </div> </form>'; echo '</div>'; } else{ $page_name="searchevents.php"; // If you use this code with a different page ( or file ) name then change this $start=$_GET['start']; if(strlen($start) > 0 and !is_numeric($start)){ echo "Data Error"; exit; } $eu = ($start - 0); $limit = 5; // No of records to be shown per page. $this1 = $eu + $limit; $back = $eu - $limit; $next = $eu + $limit; /////////////// WE have to find out the number of records in our table. We will use this to break the pages/////// $theDate = isset($_REQUEST["date1"]) ? $_REQUEST["date1"] : ""; $eventcounty = $_POST['county']; $eventdescriptionheader = $_POST['eventdescriptionheader']; $hoster = $_POST['hoster']; $arrWhere = array(); if($_POST['searchcounty'] == "yes") { $arrWhere['eventcounty'] = mysql_real_escape_string($eventcounty); } if($_POST['searchdate'] == "yes") { $arrWhere['eventdate'] = mysql_real_escape_string($theDate); } if($_POST['searchtitle'] == "yes") { $arrWhere['eventdescriptionheader'] = mysql_real_escape_string($eventdescriptionheader); } if($_POST['searchhoster'] == "yes") { $arrWhere['hoster'] = mysql_real_escape_string($hoster); } if($_POST['dogfriendly'] == "No") { $dogfriendly = $_POST['dogfriendly']; $arrWhere['dogfriendly'] = mysql_real_escape_string($dogfriendly); } if($_POST['dogfriendly'] == "Yes") { $dogfriendly = $_POST['dogfriendly']; $arrWhere['dogfriendly'] = mysql_real_escape_string($dogfriendly); } if($_POST['childfriendly'] == "No") { $childfriendly = $_POST['childfriendly']; $arrWhere['childfriendly'] = mysql_real_escape_string($childfriendly); } if($_POST['childfriendly'] == "Yes") { $childfriendly = $_POST['childfriendly']; $arrWhere['childfriendly'] = mysql_real_escape_string($childfriendly); } if($_POST['singlesonly'] == "No") { $singlesonly = $_POST['singlesonly']; $arrWhere['singlesonly'] = mysql_real_escape_string($singlesonly); } if($_POST['singlesonly'] == "Yes") { $singlesonly = $_POST['singlesonly']; $arrWhere['singlesonly'] = mysql_real_escape_string($singlesonly); } if($_POST['couplesonly'] == "No") { $couplesonly = $_POST['couplesonly']; $arrWhere['couplesonly'] = mysql_real_escape_string($couplesonly); } if($_POST['couplesonly'] == "Yes") { $couplesonly = $_POST['couplesonly']; $arrWhere['couplesonly'] = mysql_real_escape_string($couplesonly); } if($_POST['costinvolved'] == "No") { $costinvolved = $_POST['costinvolved']; $arrWhere['costinvolved'] = mysql_real_escape_string($costinvolved); } if($_POST['costinvolved'] == "Yes") { $costinvolved = $_POST['costinvolved']; $arrWhere['costinvolved'] = mysql_real_escape_string($costinvolved); } $strWhere = 'WHERE '; if(count($arrWhere)){ foreach($arrWhere as $strKey=>$strValue){ $strWhere .= ' '.$strKey.' = '.'"'.$strValue.'" AND '; } $strWhere .= ' 1 '; } else { $strWhere = ' 1'; // if you want all records to be selected if no radio is checked. if you want no records make this as '0' } $strSql = "SELECT * FROM Events $strWhere ORDER BY eventdate ASC limit $eu, $limit"; $query2="SELECT * FROM Events $strWhere ORDER BY eventdate ASC"; $result2=mysql_query($query2); echo mysql_error(); $nume=mysql_num_rows($result2); $result = mysql_query($strSql); echo '<br>'; echo "<table border='0'> <tr> <th>Date/Time</th> <th>Event</th> <th>Participants</th> <th>Hoster</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>"; print date('d M Y', strtotime($row['eventdate'])); echo " "; echo $row['starttime'] . "</td>"; echo '<td><a href="showevent.php?eventsID='; echo $row['eventsID']; echo '">'; echo $row['eventdescriptionheader']; echo "</a></td>"; echo "<td>" . $row['currentparticipants'] . "/" . $row['maxparticipants'] . "</td>"; echo "<td>" . $row['hoster'] . "</td>"; echo "</tr>"; } echo '</table>'; echo '<br><br><INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;">'; ////////////////////////////// End of displaying the table with records //////////////////////// /////////////////////////////// if($nume > $limit ){ // Let us display bottom links if sufficient records are there for paging /////////////// Start the bottom links with Prev and next link with page numbers ///////////////// echo "<table align = 'center' width='50%'><tr><td align='left' width='30%'>"; //// if our variable $back is equal to 0 or more then only we will display the link to move back //////// if($back >=0) { print "<a href='$page_name?start=$back'>PREV</a>"; } //////////////// Let us display the page links at center. We will not display the current page as a link /////////// echo "</td><td align=center width='30%'>"; $i=0; $l=1; for($i=0;$i < $nume;$i=$i+$limit){ if($i <> $eu){ echo " <a href='$page_name?start=$i'>$l</a> "; } else { echo "$l";} /// Current page is not displayed as link and given font color red $l=$l+1; } echo "</td><td align='right' width='30%'>"; ///////////// If we are not in the last page then Next link will be displayed. Here we check that ///// if($this1 < $nume) { print "<a href='$page_name?start=$next'>NEXT</a>";} echo "</td></tr></table>"; } } ?>
  20. I figured I send you a little PM if you don't mind! Small troubles with inserting this code within pages
  21. Nevermind silly question, got it all working with my modifications and a lot more search fields let this topic die
  22. Any idea on how I could incorporate any? <?php if($_POST['couplesonly'] == "Any") { $dogfriendly = "*"; $arrWhere['couplesonly'] = mysql_real_escape_string($couplesonly); } ?>
  23. Couple of tiny errors in there but got it working great! absolutely awesome thanks a lot, I really need to get my head around these arrays, I do understand your code when I read it slowly but writing that is still pretty advanced!
  24. Hey guys, at the moment I am trying to do an advanced search on events, 4 fields - county, date, title and hoster, so I am not really sure how to go about this but either way I started writing a script to do this, you learn from trying and mistaken right? Now I made sure the radio buttons all worked before I tryed this, checking the values of them on the form (seperate page) and if they get transferred correctly over to this page, basically for every field there are 2 radio boxes yes and No, which means for them to be included in the search or not, this is the code I have so far and if no radio buttons are selected and the fields are empty it comes up with the table and no results, when everything is set to no the page is blank, when everything is set to yes and I put the correct information in the fields then it comes up with the right data, so far it basically only works if all is yes (I will change it to LIKE later so they don't have to put in the exact information for certain fields) so I guess I am on the right way? Where and what am I doing wrong? <?php session_start(); include 'connect.php'; $username = $_SESSION['username']; if(!isset($_SESSION['username'])) { echo '<div align="center">'; echo 'You have to be a registered member to be able to view events.<br><br> <a href="register.html">Click here to register</a>'; echo '<br><br><br><br>Or if you are already a member, please login to use this area.<br>'; echo ' <form method="POST" action="loginverification.php"> <table border="0"> <tr><td> Username: </td><td><input type="text" name="username" size="15" /></td></tr> <tr><td>Password:</td><td> <input type="password" name="password" size="15" /></td></tr> </table> <div align="center"> <p><input type="submit" value="Login" /></p> </div> </form>'; echo '</div>'; } else{ $theDate = isset($_REQUEST["date1"]) ? $_REQUEST["date1"] : ""; $eventcounty = $_POST['county']; $eventdescriptionheader = $_POST['eventdescriptionheader']; $hoster = $_POST['hoster']; if($_POST['searchcounty'] == "No") { $result = mysql_query("SELECT * FROM Events WHERE eventdate = '$theDate' AND eventdescriptionheader = '$eventdescriptionheader' AND hoster = '$hoster' ORDER BY eventdate ASC")or die(mysql_error()); } elseif($_POST['searchdate'] == "No") { $result = mysql_query("SELECT * FROM Events WHERE eventcounty = '$eventcounty' AND eventdescriptionheader = '$eventdescriptionheader' AND hoster = '$hoster' ORDER BY eventdate ASC")or die(mysql_error()); } elseif($_POST['searchtitle'] == "No") { $result = mysql_query("SELECT * FROM Events WHERE eventcounty = '$eventcounty' AND eventdate = '$theDate' AND hoster = '$hoster' ORDER BY eventdate ASC")or die(mysql_error()); } elseif($_POST['searchhoster'] == "No") { $result = mysql_query("SELECT * FROM Events WHERE eventcounty = '$eventcounty' AND eventdate = '$theDate' AND eventdescriptionheader = '$eventdescriptionheader' ORDER BY eventdate ASC")or die(mysql_error()); } else { $result = mysql_query("SELECT * FROM Events WHERE eventcounty = '$eventcounty' AND eventdate = '$theDate' AND hoster = '$hoster' AND eventdescriptionheader = '$eventdescriptionheader' ORDER BY eventdate ASC")or die(mysql_error()); echo '<br>'; echo "<table border='0'> <tr> <th>Date/Time</th> <th>Event</th> <th>Participants</th> <th>Hoster</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>"; print date('d M Y', strtotime($row['eventdate'])); echo " "; echo $row['starttime'] . "</td>"; echo '<td><a href="showevent.php?eventsID='; echo $row['eventsID']; echo '">'; echo $row['eventdescriptionheader']; echo "</a></td>"; echo "<td>" . $row['currentparticipants'] . "/" . $row['maxparticipants'] . "</td>"; echo "<td>" . $row['hoster'] . "</td>"; echo "</tr>"; } echo '</table>'; $check = mysql_num_rows($result); if ($theDate == "0000-00-00") { echo 'You did not select a date.'; echo '<INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;">'; } elseif ($check == 0) { echo 'No results found.'; echo '<INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;">'; } echo '<br><INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;"> '; } } ?>
  25. Nope, got rid of markdown and still doing the same..
×
×
  • 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.