SitePoint Sponsor |
|
User Tag List
Results 1 to 25 of 219
Thread: PHP Quiz
-
Apr 3, 2003, 15:32 #1
PHP Quiz
Hey everyone,
How about a little quiz? I'll post a question and if you can answer it correctly you can post your own PHP question
Try to answer the question without just running the code
PHP Code:<?php
$i = 'Z';
echo ++$i;
?>
SeanHarry Potter
-- You lived inside my world so softly
-- Protected only by the kindness of your nature
-
Apr 3, 2003, 15:39 #2
- Join Date
- Aug 2000
- Location
- Houston, TX, USA
- Posts
- 6,455
- Mentioned
- 11 Post(s)
- Tagged
- 0 Thread(s)
It prints AA. Come on give me something hard
ssegraves [at] gmail.com
On Image Use, Abuse, and Where We're Headed
stephan | XMLHttpRequest Basics
flickr | last.fm | Cogentas, LLC
-
Apr 3, 2003, 15:44 #3
Originally Posted by seanf
Only joking! Where's your question?
SeanHarry Potter
-- You lived inside my world so softly
-- Protected only by the kindness of your nature
-
Apr 3, 2003, 15:51 #4
- Join Date
- Aug 2000
- Location
- Houston, TX, USA
- Posts
- 6,455
- Mentioned
- 11 Post(s)
- Tagged
- 0 Thread(s)
haha
hmmm... I gotta think of a good one.ssegraves [at] gmail.com
On Image Use, Abuse, and Where We're Headed
stephan | XMLHttpRequest Basics
flickr | last.fm | Cogentas, LLC
-
Apr 3, 2003, 16:24 #5
- Join Date
- Jan 2003
- Location
- Calgary, Canada
- Posts
- 2,063
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
well now he said AA, and everyone knows... ok the answer is AA, can i ask a question now?
Who walks the stairs without a care
It shoots so high in the sky.
Bounce up and down just like a clown.
Everyone knows its Slinky.
-
Apr 3, 2003, 16:30 #6
- Join Date
- Aug 2000
- Location
- Houston, TX, USA
- Posts
- 6,455
- Mentioned
- 11 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by cyborg from dh
ssegraves [at] gmail.com
On Image Use, Abuse, and Where We're Headed
stephan | XMLHttpRequest Basics
flickr | last.fm | Cogentas, LLC
-
Apr 3, 2003, 16:31 #7
Nope, wait for Stephan!
Let's hope he comes up with something soon!
[EDIT] He wimped out!
SeanHarry Potter
-- You lived inside my world so softly
-- Protected only by the kindness of your nature
-
Apr 3, 2003, 16:34 #8
- Join Date
- Jan 2003
- Location
- Calgary, Canada
- Posts
- 2,063
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
ok give me a few minutes here.. I'll think of something...
Who walks the stairs without a care
It shoots so high in the sky.
Bounce up and down just like a clown.
Everyone knows its Slinky.
-
Apr 3, 2003, 16:34 #9
I'm going to bed. Night all
SeanHarry Potter
-- You lived inside my world so softly
-- Protected only by the kindness of your nature
-
Apr 3, 2003, 16:41 #10
- Join Date
- Jan 2003
- Location
- Calgary, Canada
- Posts
- 2,063
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
dang, this is harder than I thought it would be.
Who walks the stairs without a care
It shoots so high in the sky.
Bounce up and down just like a clown.
Everyone knows its Slinky.
-
Apr 3, 2003, 17:18 #11
- Join Date
- Jan 2003
- Location
- Calgary, Canada
- Posts
- 2,063
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
how about a question i actually need answered:
i need a regex to match any numerical number, (including a decimal)
(trying not to make it too hard)
Who walks the stairs without a care
It shoots so high in the sky.
Bounce up and down just like a clown.
Everyone knows its Slinky.
-
Apr 3, 2003, 17:45 #12
- Join Date
- Mar 2001
- Location
- Philadelphia, US
- Posts
- 2,205
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
By decimal, you mean full-stop, right?
TuitionFree — a free library for the self-taught
Anode Says... — Blogging For Your Pleasure
-
Apr 3, 2003, 17:51 #13
- Join Date
- Mar 2001
- Location
- Mexico
- Posts
- 1,287
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Code:#[0-9]{1,M}\.[0-9]{1,N}#
-
Apr 3, 2003, 18:28 #14
- Join Date
- Jan 2003
- Location
- Calgary, Canada
- Posts
- 2,063
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
i need it to match any length of numbers before the decimal, and any length after, as well as not requiring the decimal.
Who walks the stairs without a care
It shoots so high in the sky.
Bounce up and down just like a clown.
Everyone knows its Slinky.
-
Apr 3, 2003, 18:31 #15
- Join Date
- Mar 2001
- Location
- Mexico
- Posts
- 1,287
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
done
Code:#^[0-9]+(\.[0-9]+)?$#
-
Apr 3, 2003, 18:40 #16
- Join Date
- Jan 2003
- Location
- Calgary, Canada
- Posts
- 2,063
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
good work, you win.
(That one was way too easy, but I couldn't think of anything, lol)Who walks the stairs without a care
It shoots so high in the sky.
Bounce up and down just like a clown.
Everyone knows its Slinky.
-
Apr 3, 2003, 19:40 #17
- Join Date
- Mar 2001
- Location
- Mexico
- Posts
- 1,287
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
ok, my turn.
This one is mysql & php:
you got 3 tables
table1
-------------------------------
ID name
table2
------------------------------
ID filename TypeID
table3
---------------------------
ID type
The chanllenge is make a query to fetch the following fields, table1.ID, name, filename and type and store them into a new table
newtable
-----------------
ID (must same as table1.id)
name
fliename
type
NOTE: TypeID could be NULL.
Good Luck
-
Apr 3, 2003, 19:59 #18
- Join Date
- Jul 2001
- Location
- Missouri
- Posts
- 3,428
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
you didn't say how the tables are related so i will assume that table2.TypeID references table3.ID and table1.ID references table2.ID (???).
no PHP needed, just 1 query:
Code:CREATE TABLE newtable ( ID SMALLINT UNSIGNED NOT NULL, name VARCHAR(64) NOT NULL, filename VARCHAR(64) NOT NULL, type VARCHAR(16), PRIMARY KEY (ID) ) SELECT t1.ID, t1.name, t2.filename, t3.type FROM table1 t1, table2 t2 LEFT JOIN table3 t3 ON (t3.ID=t2.TypeID) WHERE t2.ID=t1.ID ORDER BY t1.ID;
- Matt** Ignore old signature for now... **
Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
"Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR
-
Apr 3, 2003, 20:00 #19
- Join Date
- Jan 2003
- Location
- Calgary, Canada
- Posts
- 2,063
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
PHP Code:$query = mysql_query("SELECT
table1.ID,
table1.name,
table2.filename,
table2.TypeID,
table3.type
FROM
table1,table2,table3
WHERE (table1.ID=table2.ID AND table2.ID=table3.ID);");
while ($result = mysql_fetch_array($query))
{
$result['ID'] = (int) $result['ID'];
$result['name'] = addslashes($result['name']);
$result['filename'] = addslashes($result['filename']);
$result['type'] = addslashes($result['type']);
mysql_query("INSERT INTO newtable (ID, name, filename, type) VALUES
($result[ID], '$result[name]', '$result[filename]', '$result[type]');");
}
Who walks the stairs without a care
It shoots so high in the sky.
Bounce up and down just like a clown.
Everyone knows its Slinky.
-
Apr 3, 2003, 20:01 #20
- Join Date
- Jan 2003
- Location
- Calgary, Canada
- Posts
- 2,063
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
TypeID is never used in the new table...
Who walks the stairs without a care
It shoots so high in the sky.
Bounce up and down just like a clown.
Everyone knows its Slinky.
-
Apr 3, 2003, 20:18 #21
- Join Date
- Mar 2001
- Location
- Mexico
- Posts
- 1,287
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Edit:
That's right, TypeID is not used.
Actually Type ID is not needed in the new table.
Let me check the code ...Last edited by Paul S; Apr 3, 2003 at 20:26.
-
Apr 3, 2003, 20:23 #22
- Join Date
- Mar 2001
- Location
- Mexico
- Posts
- 1,287
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Great! All would share my opinion, due easiness, Matt is the winner, your turn.
(I love when you can reduce all your problems to a single line of code.)
-
Apr 3, 2003, 20:23 #23
- Join Date
- Feb 2003
- Location
- Norway
- Posts
- 109
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hmm, can I ask one? :)
If I may ask one, let's try this then:
Ok, it's not that hard at all, just to test you guys
What does this do?
<?PHP echo $HTTP_SERVER_VARS["REMOTE_ADDR"]; ?>If pigs could fly, the prize of bacon would reach the sky.
www.dosspirit.net - Norwegian reviews of DOS games
-
Apr 3, 2003, 20:25 #24
- Join Date
- Jan 2003
- Location
- Calgary, Canada
- Posts
- 2,063
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
echo's the remote ip address of the user accessing the script, unless it is the isp, in which case, usually, HTTP_X_FORWARDED_FOR is set.
Who walks the stairs without a care
It shoots so high in the sky.
Bounce up and down just like a clown.
Everyone knows its Slinky.
-
Apr 3, 2003, 20:27 #25
- Join Date
- Jan 2003
- Location
- Calgary, Canada
- Posts
- 2,063
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by Paul S
(i just didn't see anyone names matt post... i might not know some names though)
Who walks the stairs without a care
It shoots so high in the sky.
Bounce up and down just like a clown.
Everyone knows its Slinky.
Bookmarks