TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 07-17-2009, 05:05 AM   #1 (permalink)
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Default 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.
codefreek is offline  
Reply With Quote
Old 07-18-2009, 02:43 AM   #2 (permalink)
The Addict
 
Enfernikus's Avatar
 
Join Date: Jun 2008
Posts: 335
Thanks: 2
Enfernikus is on a distinguished road
Default

mysqli_connect makes use of the MySQLimproved library which is faster than the old mysql_* function - how ever the OO approached is preferred.
__________________
My Blog
Enfernikus is offline  
Reply With Quote
Old 07-18-2009, 05:40 AM   #3 (permalink)
The Addict
 
Join Date: May 2009
Posts: 287
Thanks: 5
adamdecaf is on a distinguished road
Default

This will be a short/simple answer.

What's the difference between include and require (with standard/default error_reporting).
__________________
My Site
adamdecaf is offline  
Reply With Quote
Old 07-18-2009, 05:24 PM   #4 (permalink)
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Default

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,
codefreek is offline  
Reply With Quote
Old 07-20-2009, 02:22 AM   #5 (permalink)
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Default

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);
codefreek is offline  
Reply With Quote
Old 07-20-2009, 02:42 AM   #6 (permalink)
The Addict
 
Join Date: May 2009
Posts: 287
Thanks: 5
adamdecaf is on a distinguished road
Default

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).
__________________
My Site

Last edited by codefreek : 07-20-2009 at 03:24 AM. Reason: php tags added
adamdecaf is offline  
Reply With Quote
Old 07-20-2009, 03:31 AM   #7 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by adamdecaf View Post
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?
__________________

Village Idiot is offline  
Reply With Quote
Old 07-20-2009, 03:35 AM   #8 (permalink)
The Addict
 
Join Date: May 2009
Posts: 287
Thanks: 5
adamdecaf is on a distinguished road
Default

A: You can hide files in any format you want.

Q: What is a good way to validate file uploads?
__________________
My Site
adamdecaf is offline  
Reply With Quote
Old 07-20-2009, 03:39 AM   #9 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by adamdecaf View Post
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
__________________

Village Idiot is offline  
Reply With Quote
Old 07-20-2009, 04:12 AM   #10 (permalink)
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Default

A: SQL Server 2005 (if i remember correctly)


Q: Can you store unlimited data in a cookie ?
codefreek is offline  
Reply With Quote
Old 07-20-2009, 04:18 AM   #11 (permalink)
The Addict
 
Join Date: May 2009
Posts: 287
Thanks: 5
adamdecaf is on a distinguished road
Default

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.
__________________
My Site
adamdecaf is offline  
Reply With Quote
Old 07-20-2009, 07:12 AM   #12 (permalink)
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Default

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 ?
codefreek is offline  
Reply With Quote
Old 07-20-2009, 06:15 PM   #13 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by codefreek View Post
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.
__________________

Village Idiot is offline  
Reply With Quote
Old 07-20-2009, 07:19 PM   #14 (permalink)
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Default

A: PHP4..

Q: How can I create thumbnails using PHP?

Last edited by codefreek : 07-21-2009 at 07:17 AM. Reason: Q: Edit..
codefreek is offline  
Reply With Quote
Old 07-18-2009, 05:05 PM   #15 (permalink)
The Addict
 
Join Date: May 2009
Posts: 287
Thanks: 5
adamdecaf is on a distinguished road
Default

Quote:
Originally Posted by knight13 View Post
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?
__________________
My Site
adamdecaf is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP IDE question DotNetTim Absolute Beginners 13 06-23-2009 03:51 PM
10 PHP Myths Dispelled Wildhoney General 9 06-15-2009 06:55 AM
quick question regarding c and php. masfenix General 6 07-10-2008 04:50 PM
PHP Compressor Kalle Script Giveaway 8 05-28-2008 12:14 AM
I present... my first original script obolus Absolute Beginners 14 12-29-2007 04:05 AM


All times are GMT. The time now is 07:42 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design