Jump to content

alphamoment

Members
  • Content Count

    31
  • Joined

  • Last visited

Community Reputation

1 Neutral

About alphamoment

  • Rank
    Member
  1. I'm trying to upload .doc .docx and .txt files to my server but it keeps failing. I get a white screen and nothing in my uploads folder. This is my index.php <body> <form action="upload.php" method="post" enctype="multipart/form-data"> <input type="file" name="pic" /> <button type="submit" name="btn-upload">upload</button> </form> </body> Then this is my upload.php <?php if ($_POST['Upload'] == 'Upload') { $goodExtensions = array( '.doc', '.docx', '.txt', ); $error = ''; $uploaddir = './uploads '; $name = $_FILES['filename']['name']; $min_filesize = 10; $stem = substr($name, 0, strpos($name, '.')); $extension = substr($name, strpos($name, '.') , strlen($name) - 1); if (!in_array($extension, $goodExtensions)) $error.= 'Extension not allowed<br />'; echo "<span> </span>"; if (filesize($_FILES['filename']['tmp_name']) < $min_filesize) $error.= 'File size too small<br />' . "\n"; $uploadfile = $uploaddir . $stem . $extension; $filename = $stem . $extension; if ($error == 'wtf') { if (move_uploaded_file($_FILES['filename']['tmp_name'], $uploadfile)) { echo 'File Uploaded. Thank You.'; } } else echo $error; } ?> I'm running a DebianOS. I have the /uploads folder chmod at 777. My logs say: Warning: move_uploaded_file(./uploads uploadtest.txt): failed to open stream: Permission denied in /var/www/upload.php What am I missing? thank you in advance Also my files are /www/index.php /www/upload.php /www/uploads/ EDIT: Script is working fine, I just had to restart apache2 to pick up the path. If it's okay I'll leave this here if anyone needs to use this.
  2. Thank you for the reply. The 0's 1's 2's were just examples. I appreciate the responses as they have helped me greatly!
  3. I'm using this current PHP Code in my Index.php; <?php $page = $_GET['page']; if (!isset($page)) { include('home.php'); } if ($page == "Home") { include('home.php'); } if ($page == "0101") { include('0101.php'); } if ($page == "0202") { include('0202.php'); } ?> Then I'm using this for my Navigation link; <li><a href="?page=0101">Members</a></li> Which displays as index.php?page=0101 But on those pages I want to go into another page off of them, for example; index.php?page=0101&subpage=0102 index.php?page=0202&subpage=0201 How can I achieve this?
  4. Hi I'm using PHP for my Navigation Menu, My navbar is in a file named "home.php" looks like this: <ul class="nav navbar-nav navbar-right"> <li><a href="?page=home">Home</a></li> <li><a href="?page=about">About</a></li> <li><a href="?page=services">Services</a></li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="?page=service2">Service 2</a></li> </ul> </ul> Then in my index.php: $page = $_GET['page']; if (!isset($page)) { include('home.php'); } if ($page == "home") { include('home.php'); } if ($page == "about") { include('about.php'); } if ($page == "services") { include('services.php'); } if ($page == "service2") { include('service2.php'); } It all works how I want it to except for one thing; I'd like to add; <li class="active"> To the page that is currently being viewed. How can I do this? Thank you in advance.
  5. Got it! Barand MVP. I really appreciate your help, Thank you once again.
  6. That's a lot cleaner thanks! If I wanted to limit the results to 50 rows being displayed how can I come about that? (Sorry for all the questions)
  7. Haha, thanks! Works perfect, Thank you so much Barand. One last question; for the echo I've used $row['COUNT(t1.ID)'] How can I get it to ORDER BY the highest count descending ORDER BY t1.COUNT(t1.ID) DESC This doesn't seem to do the trick! Edit: I got it working using; ORDER BY COUNT(*) DESC Thank you!
  8. Hello Barand, Thanks for the quick reply. I've tried your Query and the results displayed only 1 row ID COUNT 4017 85 Not quite sure how it got 85 when there is only 3 listings for ID 4017. Hmmmm
  9. Hello. I'm trying to get this piece of code finished but it's not going my way, if anyone could help me out that would be great. Here whats I'm trying to do: Table1 Table2 ---------------- --------------------------------- ID | | PlayerID | PlayerName | ---------------- -------------------------------- 1393 | | 1393 | Player1 | 2097 | | 2097 | Player2 | 3888 | | 3888 | Player3 | 3888 | | 4017 | Player4 | 3888 | --------------------------------- 4017 | 4017 | 4017 | ---------------- I Want to Count the entries in Table1 (3888 has 3 entries so it will display like "3888: 3") Then I want to join Table1 and Table2 using the ID so I can get the players name (3888=Player3 so it would display like Player3 : 3) Here's the code I'm using: <?php //connect to db $query = "SELECT * FROM Table1 INNER JOIN Table2 WHERE Table1.PlayerID = Table2.ID"; $query2 = "SELECT ID, SUM(ID=0) AS n0, SUM(ID=1) AS n1, COUNT(*) AS total FROM Table1 GROUP BY ID"; $result = mysql_query($query) or die($query."<br/><br/>".mysql_error()); $result2 = mysql_query($query2) or die($query2."<br/><br/>".mysql_error()); echo "<table border='1'> <tr> <th>PlayerName</th> <th>Entries</th> </tr>"; while($row2 = mysql_fetch_array($result2)) while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['ID'] . "</td>"; echo "<td>" . $row['PlayerName'] . "</td>"; echo "<td>" . $row2['Total'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($link); ?> If I use $query on its own it joins perfectly, If I use $query2 on its own, it displays the results exactly how I want them listed but with the ID instead of the PlayerName, I tried putting them both together as shown above but I can't get them to work together. What I want my end Result to be Player1 1 Player2 1 Player3 3 Player4 3 How it keeps coming out; 1393 1 2097 1 3888 3 4017 3 Can anyone see where I'm going wrong? Thank you!!
  10. I'm running Phpbb3 Version: 3.0.12. I'm trying to get all the topics from my "NEWS" Category posted on to the index.php of my Website. With the code I'm using I can get this working perfectly fine, in it's own .php file. But as soon as I add it into my index.php all of the PHP code below the forum code doesn't show. For example my layout is > Header > Login Function > Blank Space in the middle (Using this for the forum code) > 2 other PHP Scripts. As soon as I apply the forum code the 2 other PHP scripts and their markups completely dissapear from my website. The only way I can prevent this is by putting the Forum code at the bottom of my index.php but then it displays on the far left and I want it in the middle. I have tried putting it in it's own file and doing <?php include_once('external_page.php'); ?> but the same problem persists. Here is my forum code; <?php /* * home.php * Description: example file for displaying latest posts and topics * by battye (for phpBB.com MOD Team) * September 29, 2009 */ define('IN_PHPBB', true); $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './forum/'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); include($phpbb_root_path . 'includes/bbcode.php'); include($phpbb_root_path . 'includes/functions_display.php'); // Start session management $user->session_begin(); $auth->acl($user->data); $user->setup('viewforum'); $search_limit = 7; $posts_ary = array( 'SELECT' => 'p.*, t.*, u.username, u.user_colour', 'FROM' => array( POSTS_TABLE => 'p', ), 'LEFT_JOIN' => array( array( 'FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = p.poster_id' ), array( 'FROM' => array(TOPICS_TABLE => 't'), 'ON' => 'p.topic_id = t.topic_id' ), ), 'WHERE' => ' t.topic_status <> ' . ITEM_MOVED . ' AND t.topic_approved = 1', 'ORDER_BY' => 'p.post_id DESC', ); $posts = $db->sql_build_query('SELECT', $posts_ary); $posts_result = $db->sql_query_limit($posts, $search_limit); while( $posts_row = $db->sql_fetchrow($posts_result) ) { $topic_title = $posts_row['topic_title']; $post_author = get_username_string('full', $posts_row['poster_id'], $posts_row['username'], $posts_row['user_colour']); $post_date = $user->format_date($posts_row['post_time']); $post_link = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p=" . $posts_row['post_id'] . "#p" . $posts_row['post_id']); $post_text = nl2br($posts_row['post_text']); $bbcode = new bbcode(base64_encode($bbcode_bitfield)); $bbcode->bbcode_second_pass($post_text, $posts_row['bbcode_uid'], $posts_row['bbcode_bitfield']); $post_text = smiley_text($post_text); $template->assign_block_vars('announcements', array( 'TOPIC_TITLE' => censor_text($topic_title), 'POST_AUTHOR' => $post_author, 'POST_DATE' => $post_date, 'POST_LINK' => $post_link, 'POST_TEXT' => censor_text($post_text), )); } page_header('External page'); $template->set_filenames(array( 'body' => 'external_body.html' )); page_footer(); ?> Thanks in advance.
×
×
  • 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.