Jump to content

Unholy Prayer

Members
  • Posts

    166
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Unholy Prayer's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  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.
×
×
  • 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.