 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
 |
|
 |
07-17-2009, 05:05 AM
|
#1 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
PHP Answer Then PHP Question
Hey, So cecilia made Answer Then ask, so i made this,
PHP Answer Then PHP Question,
Quote:
Example of use:
-Post 1
Q: What is the difference between mysql_connect() and mysql_pconnect()?
--Post 2
Answer :
in short mysql_pconnect() makes a persistent connection to the database which means a SQL link that do not close when the execution of your script ends.
And then your turn to ask a php question.
|
I made this thread because sometimes, fast answer can save you from the monsters ;)
Enjoy..
PS: Try and keep the question and answer short if possible.
Last edited by codefreek : 07-17-2009 at 08:20 AM.
|
|
|
|
07-18-2009, 02:43 AM
|
#2 (permalink)
|
|
The Addict
Join Date: Jun 2008
Posts: 335
Thanks: 2
|
mysqli_connect makes use of the MySQLimproved library which is faster than the old mysql_* function - how ever the OO approached is preferred.
|
|
|
|
07-18-2009, 05:40 AM
|
#3 (permalink)
|
|
The Addict
Join Date: May 2009
Posts: 287
Thanks: 5
|
This will be a short/simple answer.
What's the difference between include and require (with standard/default error_reporting).
|
|
|
|
07-18-2009, 05:24 PM
|
#4 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
A: "For" i mainly to state one action to do, and while is to do while something else is done at the same time if that makes any sense..
Q: How do I find out if an array has values posted to each of its elements? I need to know that EVERY element has been filled out.
PS: I know the answer to this question but to keep the minds flowing i shall ask
questions,
|
|
|
|
07-20-2009, 02:22 AM
|
#5 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
something like this maybe :)
A:
PHP Code:
$q = mysql_query("SELECT LENGTH(firstname) AS thelength FROM myfriends ORDER BY thelength DESC LIMIT 1");
$longestname = mysql_result($q,0,0);
echo "The longest first name is $longestname letters long!";
Q: How To generate a random number between 0 and 100 ?
srand((double)microtime()*1000000);
echo rand(0,100);
|
|
|
|
07-20-2009, 02:42 AM
|
#6 (permalink)
|
|
The Addict
Join Date: May 2009
Posts: 287
Thanks: 5
|
A:
PHP Code:
echo rand(0,100);
Q: How can you move a file which has been uploaded? (Assume that it is in the $_FILES array).
Last edited by codefreek : 07-20-2009 at 03:24 AM.
Reason: php tags added
|
|
|
|
07-20-2009, 03:31 AM
|
#7 (permalink)
|
|
Wizard
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
|
Quote:
Originally Posted by adamdecaf
A:
PHP Code:
echo rand(0,100);
Q: How can you move a file which has been uploaded? (Assume that it is in the $_FILES array).
|
move_uploaded_file();
Why is MIME type a bad way to validate your uploads?
|
|
|
|
07-20-2009, 03:35 AM
|
#8 (permalink)
|
|
The Addict
Join Date: May 2009
Posts: 287
Thanks: 5
|
A: You can hide files in any format you want.
Q: What is a good way to validate file uploads?
|
|
|
|
07-20-2009, 03:39 AM
|
#9 (permalink)
|
|
Wizard
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
|
Quote:
Originally Posted by adamdecaf
A: You can hide files in any format you want.
Q: What is a good way to validate file uploads?
|
Short answer: File extension
Long answer: File extension will suffice, but actually validating the content is the best way (although this is rarely practical).
Which of the following will NOT locally work with PHP on a *nix machine
MySQL
SQL Server 2005
PostgreSQL
|
|
|
|
07-20-2009, 04:12 AM
|
#10 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
A: SQL Server 2005 (if i remember correctly)
Q: Can you store unlimited data in a cookie ?
|
|
|
|
07-20-2009, 04:18 AM
|
#11 (permalink)
|
|
The Addict
Join Date: May 2009
Posts: 287
Thanks: 5
|
A: No, unlimited data does not exist. It is physically impossible to store an infinite amount of data. I think you can store 4 kilobytes.
Q: What is the best way to sort 1,000,000 32-bit integers.
|
|
|
|
07-20-2009, 07:12 AM
|
#12 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
A:
PHP Code:
function my_function($var1,$var2,$var3){
// Place to enter code here.
$var=$var1+$var2+$var3;
return $var;
}
$my_val=my_function(5,6,8);
echo "The return value= $my_val";
// The above line will print the sum of the three variables.
Q: Can anything be stored in a cookie ?
|
|
|
|
07-20-2009, 06:15 PM
|
#13 (permalink)
|
|
Wizard
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
|
Quote:
Originally Posted by codefreek
A:
PHP Code:
function my_function($var1,$var2,$var3){ // Place to enter code here. $var=$var1+$var2+$var3; return $var; } $my_val=my_function(5,6,8); echo "The return value= $my_val"; // The above line will print the sum of the three variables.
Q: Can anything be stored in a cookie ?
|
No. HTTP limits the cookie header to 4kb.
At what version did PHP add respectable OOP functionality.
|
|
|
|
07-20-2009, 07:19 PM
|
#14 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
A: PHP4..
Q: How can I create thumbnails using PHP?
Last edited by codefreek : 07-21-2009 at 07:17 AM.
Reason: Q: Edit..
|
|
|
|
07-18-2009, 05:05 PM
|
#15 (permalink)
|
|
The Addict
Join Date: May 2009
Posts: 287
Thanks: 5
|
Quote:
Originally Posted by knight13
A: I believe if include(); fails it will produce a warning and if require fails it will produce a fatal error and it will not process the page..Hopefully that is right and what you were asking.
Q: What is the difference between $_GET and $_POST ?
|
Ya, I wanted the question to be simple..
A: $_GET will retrieve parameters from the URI, it is publicly viewable and editable. $_POST grabs the parameters from the HTTP header (?right?) and it is harder to edit or "hack" but not impossible.
Q: What is the difference from a "for" and a "while" loop?
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|