Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. Yea it does help if you showed your actual array structure when you posted orginally But anyway. If are using PHP5.5 or greater you could use $uc_sids = array_column($uc_sid, 'sid'); foreach ($sectors as $sector) { $y = in_array($sector['sid'], $uc_sids) ? '*' : ''; echo $y.$sector['sid'].'<br />'; } Otherwise you'd need to do something like foreach ($sectors as $sector) { $y = ''; // reset $y to empty string for each value foreach($uc_sid as $uc) { if($sector['sid'] == $uc['sid']) $y = '*'; } echo $y.$sector['sid'].'<br />'; }
  2. There will be a difference yes. When ran from the browser file paths will be relative to your document root. But with the command line files paths will be relative from where the command was executed from. Try setting the full file path to examplefile.log in your PHP script.
  3. Rather have the second foreach use in_array to check to see if the current value is in the second array. Example foreach($a as $aVal) { if(in_array($aVal, $b)) echo "*"; echo "$aVal<br />"; }
  4. Please wrap code within tags when posting code. I have edited your post for you
  5. Some of the values you are inserting in the query contain strings. String values need to be wrapped in quotes. They should also be sanitized so they are are handled safely in the query.
  6. You need to create the parent directories first before creating the file. You'd use mkdir to do this by setting the $recursive flag to true. Your method of uploading the file is odd. Why is it being uploaded in base64 encoding? You can upload files by using a file input field and setting the forms enctype to multipart/form-data, eg <form action="upload.php" method="post"> File to upload: <input type="file" name="file" /> <input type="submit" value="Upload" /> </form> You can then retrieve the uploaded file using the $_FILES superglobal array. See this manual page for more information on how PHP handles file uploads.
  7. CroNix is referring to your PHP code. On line 48 of functions.php you are calling the my_sermon_query() function. This function only returns a resultset (object) not the posts themselves. According to the Wordpress docs on the WP_Query() function you can use get_posts() to get the posts returned by the query. Example $query = my_sermon_query($mk, $mv); // perform query $posts = get_posts(); // returns posts in an array echo json_encode($posts); // json encode the posts array
  8. So this is solved?
  9. You'd modify the code in the for loop here to make the players name a link // put exploded data in as <td> element for ($j = 0; $j <= $columns; $j++) { $data[$j] = str_replace('"','',$data[$j]); if ($j == 0) echo '<td><img src="' . $flag_dir . $countries[$data[$j]] . '.jpg" alt="' . $data[$j] . '" /></td>'; else echo '<td>' . $data[$j] . '</td>'; } Basically When $j is equal to 1 then $data[$j] will contain the players name. You'd wrap that variable in a anchor tag to make it a link. Example ... // players country flag if ($j == 0) { echo '<td><img src="' . $flag_dir . $countries[$data[$j]] . '.jpg" alt="' . $data[$j] . '" /></td>'; } // the players name column - output it as a link elseif($j == 1) { echo '<td><a href="player_details.php?player=' . urlencode($data[$j) . '" alt="View ' . htmlentities($data[$j]) . ' Info">' . htmlentities($data[$j]) . '</a></td>'; } else echo '<td>' . $data[$j] . '</td>'; ... In player_details.php you'd use $player = urldecode($_GET['player']); to get the players name. But where are the players details kept? Or have you not implemented that yet?
  10. IMO use node.js if you want to use javascript server side.
  11. Yes. You'd use a (for) loop to to create however many graphs you need.
  12. To submit the form you'd need to use javascript when the user selects a radio button. Example using JQuery <form action="process.php" method="post" id="myForm"> <input type="radio" class="color_select" name="color" value="red" /> Red<br /> <input type="radio" class="color_select" name="color" value="blue" /> Blue<br /> <input type="radio" class="color_select" name="color" value="green" /> Green<br /> </form> <script src="https://code.jquery.com/jquery-2.1.1.min.js"></script> <script> // apply on click handler to radio buttons $('.color_select').on('click', function(e) { $('#myForm').submit(); // submit the form }); </script>
  13. You will first need to edit your PHP script so it outputs the links in the new format. Eg <a href="/user/1">FooBar</a> Then in .htaccess file in the your sites document root. You can use the following rule RewriteEngine On RewriteRule user/(\d+) board/profile.php?user=$1 [NC] To map /user/x to /board/profile.php?user=x
  14. As you're using wordpress then make sure you are using the latest version. The hacker most likely used a known vulnerability for the version of wordpress you're currently using.
  15. Why would it? I see no attachment? Solve what?
  16. Each images associted with the post you will get duplicated results. Example result from my example query +----+--------+-------------------------+---------------------+------------+ | id | title | content | created_at | image | +----+--------+-------------------------+---------------------+------------+ | 3 | Post 3 | This is post 3 content | 2014-09-10 00:00:00 | image3.jpg | | 1 | Post 1 | Hello world | 2014-09-05 00:00:00 | image1.jpg | | 1 | Post 1 | Hello world | 2014-09-05 00:00:00 | image2.jpg | | 2 | Post 2 | This is post 2 contewnt | 2014-09-06 00:00:00 | NULL | | 4 | Post 4 | Post 4 content | 2014-09-06 00:00:00 | NULL | +----+--------+-------------------------+---------------------+------------+ As you can see the post with the id of 1 has two images associated to it. Its data is duplicated twice (the data from the post table will be duplicated for how many images are associated to it) In PHP you'd process the results grouping the results into an array. Example code $posts = array(); while($row = mysql_fetch_assoc($result)) { if(!isset($posts[$row['id']]) { $posts[$row['id']] = array( 'title' => $row['title'], 'content' => $row['content'], 'created_at' => $row['created_at'], 'images' => array() ); } $posts[$row['id']]['images'][] = $row['image']; } And then you'd loop over the $posts array to output the posts. Basic example <h1>Posts</h1> <?php foreach($posts as $post_id => $post): ?> <h3><?=$post['title']?></h3> <p>Posted On: <?=$post['created_at'];</p> <p><?=$post['content'];?><p> <p>Images:<br /> <?php foreach($post['images'] as $image): ?> <img src="<?=$image?>" /> <?php endforeach; endforeach ?> If you used GROUP BY only the last image associated to the post will be returned.
  17. Google "phpbb3 meeting mod" click second link (german user oxpus has ported it to phpbb3)
  18. For the others see point b) of mac_gyver's post. You might find reading the PHP documentation on how PHP deals with forms and the bit about GET and POST here helpful As for PHP_SELF remove it. There is no need for it. Set the form action to a blank to submit the form to itself. Basically your code is outdated. It was coded in PHP4.x era (when a setting called regsiter_globals was enabled). In year 2002 (over 10 years ago) this setting was turned off by default but lazy programmers back then opted to keep the setting enabled. Your host has recently upgraded their severs to PHP5.4 (or newer) a lot has changed since PHP4 this is why your code is not functioning correctly.
  19. Most modern framework use autoloaders to including classes Also see http://php.net/manual/en/function.spl-autoload-register.php http://www.php-fig.org/
  20. When you say video do you mean only youtube videos? If so then you dont need to do anything. The user just needs to give the url to the youtube video. You'd save that link to your database then you'd use youtube player api to embed that video in your webpage. If the user is linking to videos from other video sharing sites (eg vimeo, metacafe etc) then you'd need to use their receptive video player api's for embedding those videos in your webpage too. The only time you;d need to use ffmpeg will be if the user uploads raw video file (mpg, avi etc) from their device. With ffmpeg you can generate the preview image. In order to use ffmpeg you'd need to check with your host to see if it is available as it is not a standard feature that comes with PHP. ffmpeg is a third party command line tool. In order to use it you need to send commands to it to tell it what to do. Each available command are described here I cannot tell you what specific commands you need to perform to do what you want to do as I have never used ffmpeg. But as I said before google "php ffmpeg video gif" and you should find many examples of how to do video previews using ffmpeg and PHP.
  21. For youtube videos you need to use youtube's player api instead
  22. You need to reformat your code. Business logic should not be mixed in with your HTML. If you are using header after output has been made you need rethink your logic. An absolute last resort would be to use output buffering or use the HTML meta redirect tag.
  23. You can use ffmpeg to read the video and produce a preview (still or animated) gif image of the video. Google "php ffmpeg video gif" yields many results. To have the video play you could use the HTML5 media player
  24. You shouldn't need to do that. If you are storing the images in a separate table to the posts stored in the posts table then you'd use a LEFT JOIN to retrieve the images associated to each post. Then you can sort the results accordingly. Example query SELECT p.id, p.title, p.content, p.created_at, # get these columns from the posts table i.image # get these columns from the images table FROM posts p LEFT JOIN images i ON i.post_id = p.id # join images table ORDER BY i.image IS NOT NULL DESC, p.created_at DESC # order the results so post with images are listed first and then sort by the date posted in descending order
  25. Why are you using mysql_ and mysqli_ functions? The mysql and mysqli functions are not compatible with each other. Use one or the other, preferably mysqli as the mysql_* functions are deprecated and no longer supported. Never use raw user input in your queries as this will lead to SQL Injection. If you are using mysqli then use prepared queries . Prepared queries help to eliminate sql injection from occurring. However you should still sanitize the users data before displaying it in the browser to prevent other attacks such as Cross Site Scripting (XSS).
×
×
  • 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.