Jump to content

Unholy Prayer

Members
  • Posts

    166
  • Joined

  • Last visited

    Never

Everything posted by Unholy Prayer

  1. Like Mutley said, just use trial and error. But make sure you create backups of your files just incase.
  2. Is it possible to put an IF statement inside an array? I want to display a member's IP adderess but only to admins/moderators and need an if statement to do it. I have the address displayed in a template file in which i have arrays replacing words with strings. I don't want to have any php in the template file so would the following work? 'IP_ADDRESS' => if($perm == 1){ echo "$ip_address"; }, Would that work? If not, I know there are other ways to do it, but I'm not sure what they are. How else could I do this?
  3. Omg, thank you! You are my savior of the day.
  4. Ok the arrays are supposed to replace words in the forumlist_body.tpl file with whatever word matches. For example, 'FORUM_ID' => $fid, will replace whereever the word FORUM_ID is found in the contents of the file forumlist_body.tpl. My script partially does what it's supposed to, but it only displays where FORUM_ID and the other arrays are found but displays whatever $fid is equal to(In this case, it is in a loop that gets the primary key column from the database). There are html tags in forumlist_body.tpl and the strings such as $fid and $fname are supposed to be displayed in a table, but all my script does is display whatever the strings are equal to without the html.
  5. So does this mean I should eliminate my foreach statement? I tried this, but now the arrays don't work. :'(
  6. I still need help with this code. The variables are being replaced correctly, but I have a file with html content that I am using with the code but the html isn't being displayed, just the variables. This is my code: $array = array( 'FORUM_ID' => $fid, 'FORUM_NAME' => $fname, 'FORUM_DESC' => $fdescription, 'FORUM_STATUS' => $fstatus, 'FORUM_TYPE' => $ftype, 'FLASTPOST_AUTH' => $lastpostauth, 'FLASTPOST_DATETIME' => $lastpostdatetime, 'FORUM_THREADS' => $numthreads, 'FORUM_REPLIES' => $numreplies ); $buildforums = file_get_contents('templates/default/forumlist_body.tpl'); foreach($array as $buildforums) { print $buildforums; } I know the array is correct because on this page, it displays them but without the html tags from forumlist_body.tpl. That file contains html tables and what not but only lists whatever $fid, etc. is equal to even when I only use FORUM_ID to display $fid.
  7. It's kind of working now, but it's not displaying the html of the tpl file, just the variables. It doesn't display it in the tables it's supposed to. I'm using this code instead: $array = array( 'FORUM_ID' => $fid, 'FORUM_NAME' => $fname, 'FORUM_DESC' => $fdescription, 'FORUM_STATUS' => $fstatus, 'FORUM_TYPE' => $ftype, 'FLASTPOST_AUTH' => $lastpostauth, 'FLASTPOST_DATETIME' => $lastpostdatetime, 'FORUM_THREADS' => $numthreads, 'FORUM_REPLIES' => $numreplies ); $buildforums = file_get_contents('templates/default/forumlist_body.tpl'); foreach ($array as $buildforums) { echo htmlspecialchars($buildforums); }
  8. Just use a query to display the users in a list and then add a link to the word "Delete" so it would look sort of like this: echo "$username | $website | <a href='delete.php?username=$username'>Delete</a>"; This would be delete.php: <?php $username = $_GET['username']; $delete = mysql_query("DELETE FROM table WHERE username = $username") or die("Error: ".mysql_error()); echo "The user has been deleted"; ?>
  9. That did not work either. Here is my code. <?php session_start(); require_once('config.php'); $action = $_GET["action"]; $m_time = explode(" ",microtime()); $m_time = $m_time[0] + $m_time[1]; $starttime = $m_time; include('constants.php'); if(!$_SESSION['username']) { $user = "Guest"; } else { $user = $_SESSION['username']; $uidquery = mysql_query("SELECT * FROM vbb_members WHERE username='".$_SESSION['username']."'"); $get = mysql_fetch_array($uidquery); $uid = $get["uid"]; $last_login = $get["last_login"]; $perm = $get["perm"]; } include('templates/default/header_body.tpl'); if($action = ""){ $viewing = mysql_query("UPDATE vbb_members SET viewing='Index' WHERE uid='$uid'") or die ("Error: ".mysql_error()); } //If the user is viewing the regular index... if($action == ""){ //Display category head echo "<table align='center' width='75%' cellspacing='1' cellpadding='1' border='0'> <tr>"; //Fetch categories $categories = mysql_query("SELECT * FROM vbb_categories"); while($c=mysql_fetch_array($categories)) { //Display categories in loop $cid=$c["cid"]; $cname=$c["cname"]; $cdescription=$c["cdescription"]; $cstatus=$c["cstatus"]; include('templates/default/cat_body.tpl'); //Fetch forums for the current category $forums = mysql_query("SELECT * FROM vbb_forums where cid = $cid"); while($f=mysql_fetch_array($forums)) { $fid=$f["fid"]; $cid=$f["cid"]; $fname=$f["fname"]; $fdescription=$f["fdescription"]; $lastpostauth=$f["lastpost_auth"]; $lastpostdatetime=$f["lastpost_datetime"]; $fstatus=$f["fstatus"]; $ftype=$f["ftype"]; $views=$f["views"]; $replies=$f["replies"]; $lastpost = mysql_query("SELECT * FROM vbb_threads WHERE fid = $fid LIMIT 1"); $lp=mysql_fetch_array($lastpost); $lastthreadsubject=$lp["tsubject"]; $get_threads = "SELECT * FROM vbb_threads where fid = $fid"; $threads_result = mysql_query($get_threads); $threads = mysql_num_rows($threads_result); $get_posts = "SELECT * FROM vbb_threads WHERE tdatetime > $last_login AND fid = $fid"; $posts_result = mysql_query($get_posts); $newposts = mysql_num_rows($posts_result); $subforums = mysql_query("SELECT * FROM vbb_subforums where fid = $fid"); $sf=mysql_fetch_array($subforums); $sfid=$sf["sfid"]; $fid2=$sf["fid"]; $sfname=$sf["sfname"]; $csubforums = "SELECT * FROM vbb_subforums where fid = $fid"; $c_result = mysql_query($csubforums); $numsubs = mysql_num_rows($c_result); $threadquery = "SELECT * FROM vbb_threads WHERE fid='$fid'"; $threadresult = mysql_query($threadquery); $num_threads = mysql_num_rows($threadresult); if($num_threads > 0){ $memberid = mysql_query("SELECT * FROM vbb_members WHERE uid='$uid'"); $m=mysql_fetch_array($memberid); $name=$m["username"]; $threadname = mysql_query("SELECT * FROM vbb_threads WHERE fid='$fid' ORDER BY tid desc LIMIT 1"); $tn=mysql_fetch_array($threadname); $lastthreadtitle=$tn["tsubject"]; } $threadsquery = "SELECT * FROM vbb_threads"; $threadsresult = mysql_query($threadsquery); $numthreads = mysql_num_rows($threadsresult); $repliesquery = "SELECT * FROM vbb_replies"; $repliesresult = mysql_query($repliesquery); $numreplies = mysql_num_rows($repliesresult); $array = array( "FORUM_ID"=>"$fid", FORUM_NAME=>"$fname", FORUM_DESC=>"$fdescription", FORUM_STATUS=>"$fstatus", FORUM_TYPE=>"$ftype", FLASTPOST_AUTH=>"$lastpostauth", FLASTPOST_DATETIME=>"$lastpostdatetime", FORUM_THREADS=>"$numthreads", FORUM_REPLIES=>"$numreplies" ); foreach ($array as $key => $val){ $buildforums = file_get_contents('templates/default/forumlist_body.tpl'); $buildforums= str_replace($key, $val, $buildforums); } print $buildforums; } } echo "</table>"; $round = 3;// The number of decimal places to round the micro time to. $m_time = explode(" ",microtime()); $m_time = $m_time[0] + $m_time[1]; $endtime = $m_time; $totaltime = ($endtime - $starttime); $load = round($totaltime,$round); } if($action == "search"){ echo "<br><br><table align='center' cellspacing='1' cellpadding='1' border='0'> <tr> <td align='center' colspan='2' class='header'>Search Results</td> </tr><tr> <td align='center' class='title_posts'>Thread Name</td> <td class='title_posts'>Thread Creator</td> </tr><tr>"; if(empty($_POST['thread'])){ echo "<td class='light1' colspan='2'>You did not enter anything into the search field!</td>"; } // We will need to get the search keyword and put it into a varaible. if(isset($_POST['go'])){ $search = $_POST['thread']; $searchResults = mysql_query("SELECT * FROM vbb_threads WHERE tsubject LIKE '$search'"); $numresults = mysql_num_rows($searchResults); if($numresults < 1){ echo "<td class='light1' colspan='2'>Your search returned $numresults results.</td>"; } // This while loop will loop through the results until we get to the end. It will print out the title and //the description of the returned results. while($row = mysql_fetch_array($searchResults)){ $tsubject=$row['tsubject']; $tid=$row['tid']; $tcreator=$row['tcreator']; include('templates/default/searchresults_body.tpl'); } echo "</table>"; } } $usersquery = "SELECT * FROM vbb_members"; $usersresult = mysql_query($usersquery); $num_users = mysql_num_rows($usersresult); include('templates/default/stats_body.tpl'); include('templates/default/footer_body.tpl'); ?>
  10. Didn't work. :'( I tried using the file_get_contents but now it doesn't display anything after the category headers...
  11. So if my code were: $array = array( FORUM_ID=>"$fid", FORUM_NAME=>"$fname", FORUM_DESC=>"$fdescription", FORUM_STATUS=>"$fstatus", FORUM_TYPE=>"$ftype", FLASTPOST_AUTH=>"$lastpostauth", FLASTPOST_DATETIME=>"$lastpostdatetime", FORUM_THREADS=>"$threads" ); $template = include('templates/default/forumslist_body.tpl'); I would do this? foreach ($array as $key => $val) { $template = str_replace($key, $val, $template); }
  12. I would still have to use php in my tpl file though, right?
  13. Ok, I have all my variables declared with my arrays, but how do I get it to replace the text in included files? For example: I used FORUM_ID=>"$fid", to declare the forum's id. I have a tpl file included after the variables. How do I get the arrays to be used in the template file so if the contents of the tpl file were <a href='viewforum.php?id=FORUM_ID'>FORUM_NAME</a>?
  14. well the error that is displayed is Error: Unknown column 'April 1, 2007' in 'where clause' so I know the variables are right. It's supposed to display the events for the date being displayed on a calendar.
  15. Well the date column is a varchar field. I tried changing the "date" column to "edate" and it still doesn't work.
  16. I can't figure out what's wrong the my SELECT sql syntax. I'm trying to select an event from a table for the date being displayed. This is my code: $events = mysql_query("SELECT * FROM vbb_events WHERE date = $monthname $counter, $thisyear") or die("Error: ".mysql_error()); Any help is appreciated.
  17. yeah but how do they switch from the user is logged in to the user is logged out without a php code? that's the only thing i see.
  18. i've seen on alot of forums, such as PHPbb2, that in their template files, they use lines such as <!-- BEGIN switch_user_logged_out --> I was wondering if you use functions to do that and if so, how?
  19. I'm having more problems with my login script. I'm successful logging in, but when I refresh my page or go to a different one, it says I'm logged in as someone else. My friend just registered and when I refreshed the page it said i was logged in as his username. This is my page header script: <?php $action = $_GET["action"]; $m_time = explode(" ",microtime()); $m_time = $m_time[0] + $m_time[1]; $starttime = $m_time; session_start(); ob_start(); require_once('config.php'); include('constants.php'); if(!session_is_registered("username")){ $user = "Guest"; } if(session_is_registered("username")){ $user = $_SESSION['username']; $uidquery = mysql_query("SELECT * FROM vbb_members WHERE username='".$_SESSION['username']."'"); $get=mysql_fetch_array($uidquery); $uid=$get["uid"]; } Thanks in advance.
  20. I have more than one result. I used that script and got the row with the uid of 1. I want it to display the newest record... in simpler terms I just want it to display the newest registered user so it should order it in descending order. But pocubueno's worked. Thank you.
  21. How do I order my sql results in descending order? This is my query: mysql_query("SELECT * FROM members order by uid limit 1 descending");
  22. I've seen in PHPbb2 and Invision Power Board where in their template files it says <!-- Some Command --> so they don't have to include the entire code in the template file. For example, to switch the user logged out function, PHPbb2 uses <!-- BEGIN switch_user_logged_out --> to display links that should display only if the user is logged out. How do I do this?
  23. Thank you. I have been trying to figure that out forever.
  24. I changed it, but it's still the same error.
  25. My registration script won't work because of an issue with my mysql_query syntax but I can't figure out what the problem is. When I click the register button, it displays a message that says 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 ''Test2' at line 1 This is my code: <?php //Connect to the database... this is definitely an essential. require_once('config.php'); include('constants.php'); //Get the server date... $date = date("F j, Y"); //Include the header body/functions include('templates/default/header_body.tpl'); $action = $_GET["action"]; if($action == ""){ //What is this user's member number? $members = mysql_query("SELECT * FROM vbb_members"); $number = mysql_num_rows($members); $mem_no = $number + 1; $errors = "0"; //If the register button was not click clicked... if(empty($_POST['register'])) { echo "</tr><tr>"; //Display the form include('templates/default/register_body.tpl'); } //If it was clicked... if(isset($_POST['register'])) { //Transform inputs into strings for mysql insertion... $user = $_POST['username']; $password = md5($_POST['password']); $password_conf = md5($_POST['password_conf']); $email = $_POST['email']; $reg_date = $_POST['reg_date']; $mem_no = $_POST['mem_no']; $perm = $_POST['perm']; //Is the user name in use? $membername = "SELECT * FROM vbb_members WHERE username='$user"; $name_result = mysql_query($membername) or die("Error: ".mysql_error()); $name = mysql_num_rows($name_result); //Is the user's email already in use? $emails = "SELECT * FROM vbb_members WHERE email='$email''"; $getemails = mysql_query($emails) or die("Error: ".mysql_error()); $num_emails = mysql_num_rows($getemails); if($num_emails == 1){ echo "</tr><tr><td align='center' class='inputrow'>There is already an account registered with that email address. Please go back and choose another.</td></tr><tr>"; } //If it is in use... if($name == 1){ echo "</tr><tr><td align='center' class='inputrow'>The username you entered is already in use. Please go back and choose another.</td></tr><tr>"; $errors = $errors + 1; } //Check if any fields are blank and display error messages if they are. if(empty($_POST['username'])){ echo "<td align='center' class='inputrow'>You left the username field blank. Please go back and choose one.</td></tr><tr>"; $errors = $errors + 1; } if(empty($_POST['password'])){ echo "<td align='center' class='inputrow'>You left the password field blank. Please go back and choose a password.</td></tr><tr>"; $errors = $errors + 1; } if(empty($_POST['password_conf'])){ echo "<td align='center' class='inputrow'>You did not confirm your password. Please make sure your password is correct by filling in the confirm password field.</td></tr><tr>"; $errors = $errors + 1; } if(empty($_POST['email'])){ echo "<td align='center' class='inputrow'>You did not enter an email address. Please go back and tell us your email address.</td></tr><tr>"; $errors = $errors + 1; } //Did the passwords match? if($password != $password_conf){ //If they didn't match, display an error message. echo "<td align='center' class='inputrow'>Your passwords did not match. Please go back and re-enter your passwords so they match.</td></tr><tr>"; $errors = $errors + 1; } if($errors == 0) { mysql_query("INSERT INTO `vbb_members` (`username`,`password`,`email`,`reg_date`,`mem_no`,`perm`) values (`$user`, `$password`, `$email`, `$reg_date`, `$mem_no`, `$perm`)") or die("Error: ".mysql_error()); //Display a welcome to the forums message. echo "<td align='center' class='light1'>Welcome to the forums, $user! You can now <a href='login.php'>login</a> with the information you just provided.</td>"; } if($errors > 0) { echo "There were $errors errors with the data you provided."; } } } //And we're done! For now, at least. ?> Thanks in advance for the help.
×
×
  • 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.