Archive for September, 2010

Best site to learn to program in PHP and flash?

I want to start learning PHP and flash, but I don’t know which site offers the best free tutorials. Also, is the Flash sdk free? I don’t even think there is a flash sdk anymore. I keep seeing Adobe lite and Adobe Air.

Any help from PHP developers and Flash developers will be most appreciated. Cheers

Try w3schools.com

PHP Question on even numbers?

I’m new to it and I’m not sure how to properly do this properly. I need help to build the following PHP code. Please help.

1- Write a PHP program that goes through all integers between 1 and 100 (excluding
1 and 0) and displays each even number on a separate line.

2- Re-write the program in question 1 but this time use a function to go through the
numbers and display them.

If I can get at least the first one from someone that would be great. Thanks in advance for your help!!
Thanks Sean, but how do I display them on a separate line?
What’s the difference between question number 1 and 2? What would I do different between them two? THANKS IN ADVANCE!

just a simple loop with a modulus function

for ($i = 2; $i <= 100; $i++) {
if ($i % 2 == 0) {
print $i . ‘html break tag’;
}
}

sry the actual html break tag wasnt showing up

as for the function part

function printEvens() {
//stuff from above
}

and the difference is you just put the loop in the php part on the first question the second question you put the function in the php and call the function

How do you make a login system with PHP?

Please, no MySQL, I would like this to be connected to a txt file- I know this is less secure, but I don’t know MySQL at all, and I know there is a way to create a login system with just a txt file.

PS
An explanation of the code would be good as well, because I am not a great programmer (I am an eighth grader who took a two week course on java and php programming).

Download the free "Login script" from http://www.web2coders.com
It is more complete than the one described above, and it is commented.

how to run programme in php?

hey frnds i have wamp5 s/w . and dreamwear after writing a code i dont know how to run programme to show the output .
plz help me i m mew in php

Hi there! I have WAMP as well!

Here’s what you do when you’ve created a file in Dreamweaver. Save the PHP file, then move it to C:\WAMP\www (or find WAMP in any directory).

Then, visit http://localhost/NAMEOFFILE.php

You must run under localhost to execute PHP.

http://localhost/ is relative to the \www\ directory. Here a few examples:
Normal: C:\WAMP\www\hi.php
Localhost: localhost/hi.php

Normal: C:\WAMP\www\hello\hi.php
Localhost: localhost/hello/hi.php

Hope that helped you!

PHP vs Perl? For web programming..?

For web programming? Which is: easier to learn and more efficient? I’m new to programming. Also, what can I do with these languages as far as web development goes.

P.s: after I learn one of these, will it be a good idea to learn Python after since it’s more for applications, and will it be a better idea to learn python first and then one of those two? Thankz in advance!!!!!

Python and Ruby are much more common for newer web apps than PHP and Perl. The Django and Rails frameworks are far more comprehensive than PHP. And PHP is just a simplified version of Perl anyway. Also, Django and Rails promote far more secure practices than PHP. Many sites written in PHP are vulnerable to SQL Injection attacks, which is a simple hack that allows people to steal all your info.

how to know how many Saturdays were there in 2010 January by PHP?

how to know how many Saturdays were there in 2010 January by php program?
will you write some valid codes for this for me?

Play with "mktime" and few loops:

<?php
$day = "Saturday";
$month = 1;
$year = 2010;

$d = date("t", mktime(0,0,0,$month,1,$year));
$n = 0;
echo "<b>".$day."’s</b> found:<br>";
for ($i = 1; $i <= $d; $i++) {
  $c = date("l", mktime(0,0,0,$month,$i,$year));
  if (strtolower($c) == strtolower($day)) {
    $n++;
    echo $n.". ".$i."/".$month."/".$year."<br>";
  }
}
?>

Just change the first three variables ($day, $month, $year) to whatever you need. The output of $n variable will give you the number of days. Enjoy!

Edit:
..also, for something more analytic try to change the loop from:

if (strtolower($c) == strtolower($day)) {
  $n++;
  echo $n.". ".$i."/".$month."/".$year."<br>";
}

to:

if (strtolower($c) == strtolower($day)) {
  echo "<b>".$i.". ".$c." ".$i."/".$month."/".$year."</b><br>";
} else {
  echo $i.". ".$c." ".$i."/".$month."/".$year."<br>";
}

Question Regareding PHP Programming?

How to execute the php programs in a normal pc. Which software should use to run php programs.

Go to Apachefriends.org and download XAMPP (free). Install it on your machine (root directory C:/xampp). Create a directory in c:/xampp/htdocs/newdirectory (the name of your "site").
Copy the files of your site into that directory.
Open c:/localhost/newdirectory/index.php
… and there you are!
Your PC now acts as a server, with Php and mysql.

how can i write a factorial of given no in php program?


This is hint for your homework.
If you can write factorial program in C / java any other language.
Then you just need to change syntax of variable & function declaration.

<?php

// —————————————————————–
function nfact($n)
{
if ($n == 0)
{
return 1;
}
else
{
return $n * nfact($n – 1);
}
}
// —————————————————————–

$num = 5;

echo $output = "\n\nFactorial " . $num . " = " . nfact($num) . "\n\n";
echo $output;

?>

How can I run a PHP program in windows XP?


Get a PHP/HTML server at http://www.wampserver.com/en/ and try opening it in your browser.