-
Posts
3,584 -
Joined
-
Last visited
-
Days Won
3
Everything posted by JonnoTheDev
-
Simpler implementation <?php $dayOfWeek = date("w"); switch($dayOfWeek) { case 2: ?><script language='JavaScript' src="http://a.admaxserver.com/servlet/ajrotator/414071/0/vj?z=admaxasia2&dim=280733&pid=7127b37b-3892-4347-8bae-3c9cccf05f6c&asid=1d4556ac-49ee-4004-a196-986327e519ee"></script><noscript><a href="http://a.admaxserver.com/servlet/ajrotator/414071/0/cc?z=admaxasia2&pid=7127b37b-3892-4347-8bae-3c9cccf05f6c&asid=1d4556ac-49ee-4004-a196-986327e519ee"><img src="http://a.admaxserver.com/servlet/ajrotator/414071/0/vc?z=admaxasia2&dim=280733&pid=7127b37b-3892-4347-8bae-3c9cccf05f6c&asid=1d4556ac-49ee-4004-a196-986327e519ee&abr=$imginiframe" width="300" height="250" border="0"></a></noscript><?php break; case 5: print "<b>Good Friday morning</b>\n"; break; default: print "<b>Good morning</b>\n"; break; } ?>
-
<?php $arr = array('111111' => 10, '222222' => 20); $result = mysql_query("SELECT * FROM table WHERE table.zip IN(".implode(",", array_keys($arr)).")"); ?>
-
<?php $arr = array('111111' => 10, '222222' => 20); $checkValue = '111111'; if(array_key_exists($checkValue, $arr)) { print $arr[$checkValue]; } else { print "no data found"; } ?>
-
You need content. Your homepage simply contains links to 3rd party websites. I click on a Honda & I am simply taken to Honda's website. A user would be on your site for all of 3 seconds. These links should go to pages on your own site with content about the vehicle. That detail page could have a link to the manufacturers website.
-
Use PHP not Javascript. <?php $dayOfWeek = date("w"); /* if tuesday */ if($dayOfWeek == 2) { ?> <script language='JavaScript' src="http://a.admaxserver.com/servlet/ajrotator/414071/0/vj?z=admaxasia2&dim=280733&pid=7127b37b-3892-4347-8bae-3c9cccf05f6c&asid=1d4556ac-49ee-4004-a196-986327e519ee"></script><noscript><a href="http://a.admaxserver.com/servlet/ajrotator/414071/0/cc?z=admaxasia2&pid=7127b37b-3892-4347-8bae-3c9cccf05f6c&asid=1d4556ac-49ee-4004-a196-986327e519ee"><img src="http://a.admaxserver.com/servlet/ajrotator/414071/0/vc?z=admaxasia2&dim=280733&pid=7127b37b-3892-4347-8bae-3c9cccf05f6c&asid=1d4556ac-49ee-4004-a196-986327e519ee&abr=$imginiframe" width="300" height="250" border="0"></a></noscript> <?php /* if friday */ } elseif($dayOfWeek == 5) { ?> <b>Good Friday morning</b> <?php /* any other day */ } else { ?> <b>Good morning</b> <?php } ?>
-
Fast Question : What does it means ! n\ and r\
JonnoTheDev replied to egturnkey's topic in PHP Coding Help
\n is a newline \r is a carraige return \t is a tab Thats it really. They are just for text documents. For instance take a look at: <?php print "<h1>Hello</h1>"; print "<p>This is some text</p>"; ?> Run this code and take a look at 'view source' in your browser. See how the text document displays the HTML. Now run this code and do the same. <?php print "<h1>Hello</h1>\n"; print "<p>This is some text</p>\n"; ?> -
No he isn't! Drupal is a CMS, not to be used for bespoke projects. This would be my preferred implementation. It is no less secure than any other method, after all, session data is stored server side and accessed via a key within a cookie. A session will expire. I would simply store an array of module statuses after the user has authenticated (logged in). If there are 5 modules you could store it as follows: <?php $modules[1] = true; $modules[2] = true; $modules[3] = false; $modules[4] = true; $modules[5] = false; $_SESSION['authdata']['modules'] = $modules; ?> You can use simple conditional statements whether to display links to each module or not based on its boolean value from the session. Also perform the same test on the actual script filename to redirect any users that are not valid if they were to discover the url. If more modules are added then you do not have to modify any code that stores access levels in the session. I have obviously used a static array in the example above, however in your code the data should come from the database.
-
<?php $news = array(); $result = mysql_query("SELECT id, title, date, YEAR(date) AS year, SUBSTRING(body,0,100) AS snippet FROM news ORDER BY date DESC"); while($row = mysql_fetch_assoc($result)) { $news[$row['year']][] = $row; } /* display news */ foreach($news as $year => $articles) { print "<h1>".$year."</h1>"; foreach($articles as $article) { print "<p>".$article['title']." - ".date("d/m/Y", strtotime($article['date']))." - ".$article['snippet']."</p>"; } } ?>
-
Show your database structure please.
-
I will be surprised if it isn't as the software needs to read the video file to take snaps from certain points in the video timeline. Yes, we do this on some of our video streaming sites where the videos are actually hosted elsewhere. What you must understand is that these videos come via data feeds, also with a series of images. What we are able to do is use the images provided to create an animation. The actual video is played from the remote url. This is a site that does what you are after. You must provide the video file. http://www.gifninja.com/ConvertVideoToGif.aspx On projects I have worked on that are basically YouTube clones this is a process that is done in the background once a video has been uploaded. If you have ever uploaded a video to YouTube it takes a short while after the video has been uploaded to it being displayed on the site. This is because there are loads of things happening in the background such as, file format conversion, video optimisation, snapshot images being created, video length stored, etc
-
This is only possible if you have the video files on your server. What happens is, you upload a video to the server. It then gets converted into swf or HTML5 video format or whatever you require. This is done using the likes of FFMPEG. Now, what this software can also do is take thumbnail images from any point in the video. So if the video was 6 minutes long I may take 5 images from the 1st, 2nd, 3rd, 4th, and 5th minute. Then I would use image manipulation software such as imagemagick to construct an animated gif from the 5 images taken. So, essentially you need a few bits of software on your server. Look at the commands available for each: http://www.ffmpeg.org/documentation.html http://www.imagemagick.org/script/command-line-tools.php This cannot be done with videos that are hosted elsewhere.
-
Multiple drops downs and disappearing variables.
JonnoTheDev replied to nhsal69's topic in PHP Coding Help
AJAX -
Multiple drops downs and disappearing variables.
JonnoTheDev replied to nhsal69's topic in PHP Coding Help
This is because you are refreshing the page a second time when the second form is submitted and resetting the value of country with the following lines: $country = $_POST["country"]; $_SESSION["country"] = $country; So when you submit the first form the value of $_POST["country"] is stored in the session variable $_SESSION["country"], no problem. Now, when you submit the second form there is no post data for country (as this form element only exists in the first form), so the the above php is setting the session variable to empty. What you must do is either one of two things: 1. Only set the session variable country when the first form is submitted and the player session variable when the second form is submitted. You can do this using hidden form fields lets say 'form1' and 'form2' in each form and detect them using a conditional statement such as: if($_POST['form1']) { $country = $_POST["country"]; $_SESSION["country"] = $country; } if($_POST['form2']) { $player = $_POST["player"]; $_SESSION["player"] = $player; } 2. Store the value on country in a hidden field within form 2 <input type='hidden' name='country' value='<?php print $_SESSION['country']; ?>' /> On a side note. It is best practice to do any form data processing at the very top of the script, i.e. prior to you displaying any HTML. So if you are setting session data, storing stuff in a database from a form, etc, always do this at the top of the script. This is because it is not uncommon for you to want to redirect users to another page after you have stored data from a form. You can only do this prior to anything being displayed on the screen. Also it makes your code much more readable. -
PFMaBiSmAd has given the solution. One user can be allocated many points. This is a one to many database table relationship. The image creation should not be inside the loop. You should loop over all the points per user from the database query and create an array. Then you can use the array data to draw the final image.
-
Please tell me you are not storing php code in a database table! If so, why? Also eval() is a function that you should really avoid due to the security risks it exposes.
-
How to code 2 queries with 'if' statement?
JonnoTheDev replied to RON_ron's topic in PHP Coding Help
You should write in pseudo code first. Basically just the text description of your program flow, in fact you have more or less done it in your post. Once you do this it is eacy to go over the pseudo code with real code. i.e // pseudo code example 1. Check if record exists in table a 2. If it does redirect the user to page 1 3. If not stay on the same page and display an error Here is the code for your post. Fill in the blanks. <?php /* check table applicant for text PendingGroupA */ $result = mysql_query("SELECT id FROM applicant WHERE username='' AND statusA='PendingGroupA' LIMIT 1"); if(mysql_num_rows($result)) { /* record exists */ print 'Message A: Record exists in applicant'; } else { /* no record exists, check comp table for user */ $result = mysql_query("SELECT id FROM comp WHERE username='' AND pass='' LIMIT 1"); if(mysql_num_rows($result)) { /* record exists */ print 'Message B: Record exists in comp'; } else { /* no record exists */ print 'Message C: No record exists in comp'; } } ?> -
Just use PHP and convert to JSON <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Sample</title> <script type="text/javascript"> <?php $html = file_get_contents("http://mcse.pair.com/html/tut1.html"); $html = json_encode($html); ?> function foobar() { var html = '<?php print $html; ?>'; alert(html); } window.onload = foobar; </script> </head> <body> </body> </html>
-
How to integrate Captcha code to webmail signup script?
JonnoTheDev replied to JimmY_BL's topic in PHP Coding Help
Just use recaptcha. Its easy to implement. Requires you to add about 1 line of code which is well documented, so you do not need any experience with php. Just look at the examples on the site. http://www.google.com/recaptcha -
Of course, but again this is down to bad design. A website should not contain internal links to old pages that redirect. All internal links on a website should point to final target URLs that return a 200 status. This is sometimes hard to implement on existing websites containing lots of pages, but you should have a central set of functions that control all mod rewritten links on your site. Therefore if you change a link it will be changed across the board and no old URLs will be left. You can then add the 301 redirect to your htaccess file to keep any current inbound links alive.
-
Yes, they will be. URLs that you intend to redirect should not be submitted in a Google sitemap. Only your final target URLs should be. If the original URL is indexed and you apply a 301, Google should pick this up when it spiders the site from it's current index. There will be no penalty as all you are stating is that you have changed the URL from x to y, x is redundant.
-
I've never seen this. Have you any info / links? I know there are issues if you supply too many redirects in one go as in a 404 followed by a 200 then a 301, but this is down to bad design. If you are redesigning a website the URLs may be different in a new version so you must ensure that you 301 redirect all your old URLs that are indexed in Google to your new pages. Also if pages don't exist any more a 404 ErrorDocument should be defined. You can also submit old URLs that no longer exist to Google so they can be de-indexed.
-
The url should be mod rewritten & contain a 301 redirect. There is no need for any redirect page as the redirect is done via a .htaccess. A redirect must be used if there are already inbound links using the old URL otherwise duplicate content will be picked up. What do you mean by this? Google will understand the status codes you provide. 301 Moved permanantly, 404 does not exist, etc
-
£ is not a valid character in all sets. UTF-8 it is. You should use the HTML entity for a £. <?php $value = '£20'; if(strstr(htmlentities($value), '£')) { echo htmlentities($value); } else { echo "£ is not in the string"; } ?>
-
Data protection for children - UK law question
JonnoTheDev replied to richrock's topic in Miscellaneous
Thats new to me however, as he has stated the client is CRB (Criminal Record Bureau) checked it is obvious that it is a UK company. If what you are stating is correct then how do the likes of Facebook, MySpace operate in other countries. I would say the majority of users are children and I have never heard of them changing the registration process for users in certain countries. Those sites hold more personal data on users than any other. The client should have a specification. If in any way they are not conforming to the letter of the law, this is not the web developers concern. The website belongs to the client, not the developer. -
Data protection for children - UK law question
JonnoTheDev replied to richrock's topic in Miscellaneous
If it is necessary for you to store the data (per the clients specification) then of course you can. If you are taking holiday bookings then knowing the names of the guests is essential. If you were to book a flight online for your family, you must provide names & details of all travellers. Where is the difference? What you must have is a privacy policy. This states that you will not pass the data on to any 3rd party companies, and essentially explains what data you are collecting and why you require it. If you are self employed and are making this website then you should make sure that you have Professional Indemnity Insurance. Hypothetically, if your website had security holes and unlawful access to data was achieved, then you will need to make sure that you are covered.