php-general Digest 23 Sep 2007 01:39:00 -0000 Issue 5033
Topics (messages 262367 through 262378):
Re: php personal project
262367 by: Børge Holen
262368 by: Børge Holen
262370 by: Guillaume Theoret
Re: MAX_FILE_SIZE not working with file uploads
262369 by: Jeff Cohan
262373 by: Dan Parry
262374 by: Jeff Cohan
262375 by: Dan Parry
262377 by: Ray
262378 by: Dan Parry
Re: Limiting connection to mysql using old mysql module (not mysqli)
262371 by: Stut
Re: Access name of variable in $_POST array
262372 by: Dan Parry
Re: str_replace oddity
262376 by: heavyccasey.gmail.com
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
On Saturday 22 September 2007 02:33:57 Crayon Shin Chan wrote:
> On Friday 21 September 2007, Karl james wrote:
> > I am in need of some help.
> > I would love to get some assistance on this.
> > I need to start creating a database for my website.
> > This will be for a fantasy football league website.
> > To store stats on the database for archive purposes,
> > And be able to pull them out on html reports.
>
> You've been working on this "fantasy football league" thing for *years*.
> You mean you still haven't gotten it off the ground yet?
is this the same dude with the same question from last year?
omg
>
> --
> Crayon
--
Børge Holen
--- End Message ---
--- Begin Message ---
On Saturday 22 September 2007 12:06:27 Karl James wrote:
> HAHAHA!! VERY FUNY!!!!!!
>
> Apparently, no one wants to help.
> So, much for the sympathy factor.
>
> Karl
>
>
> ----Original Message----
> From: Børge_Holen <[EMAIL PROTECTED]>
> Sent: 09/22/07 12:29 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] php personal project
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
> On Saturday 22 September 2007 02:33:57 Crayon Shin Chan wrote:
> > On Friday 21 September 2007, Karl james wrote:
> > > I am in need of some help.
> > > I would love to get some assistance on this.
> > > I need to start creating a database for my website.
> > > This will be for a fantasy football league website.
> > > To store stats on the database for archive purposes,
> > > And be able to pull them out on html reports.
> >
> > You've been working on this "fantasy football league" thing for *years*.
> > You mean you still haven't gotten it off the ground yet?
>
> is this the same dude with the same question from last year?
> omg
>
> > --
> > Crayon
>
> --
> Børge Holen
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
Yes, well... What most people pick up very fast around here is the rule of
help people help themselves.
You want the whole freakin page without actually have to start anythin
yourself. Show up some code, something that youre pondering about...
anything.
Start storing whatever results from yer database fix codes and expand it with
your own enhancing capabilities.
I would very much recon that the knowledge residing within this email
community is bought the hard way, hell... most of these ppl probably bought a
php book out of some sort of problem or they needed for some background
information on a specific topic or maby as a souvenir, I don't know but they
did not learn php from the book (did you?).
--
Børge Holen
--- End Message ---
--- Begin Message ---
* Disclaimer: The following may sound condescending (I hope not) but
you said you're a newbie so I'll try to start with the very basics.
For your database tables questions you basically want the tables to
represent real life "things". For example, a player, a team, etc.
So let's make a quick list of things you might want to store information about:
Players (an NFL player)
Teams (a NFL team)
Coaches (a NFL coach)
Fantasy Owners (one of your friends who has a fantasy team)
Now that we have that list we have to decide what information we want
to keep about each.
For example a player will need a name, an age, a salary, possible
other stuff that's unique to him alone. Same for teams, coaches and
fantasy owners.
Now that we have a little information about each we need to decide how
to link everything together. In order to properly link things together
(to keep each database record (or row) unique) we need to give each
record a unique id. An auto-incremented integer serves perfecly. So
we'll have player_id, team_id, coach_id, owner_id.
Teams have many players but players only play on one team. In this
case we have a "one to many" relationship between teams and players.
In this case you want to store the team_id in the player table.
The relationship between fantasy owners and players can be more
complicated however. Depending on the rules you set up owners will
surely have several players but players may be owned by several
owners. Here we have a "many to many" relationship. In this case we
need what's called a "middle table", basically a table whose sole
purpose is to link 2 other tables together. We'll call this table
owners_players and it will only have 2 fields: owner_id and player_id.
So when you want all players on an owner's team you select * from
owners_players where owner_id = x and with each of those results you
look up the player's information from his unique id (though it's
easier to do a join but I don't want to get into table joins right now
that's more complicated).
I've shown the two more complicated types of relationship but there's
still another: one to one. In this case you can put the id of the
linked-to record of the other table in either table, it doesn't
particularly matter, put it where you think it makes most sense.
This should be enough to at least get you started collecting some data.
On 9/21/07, Karl james <[EMAIL PROTECTED]> wrote:
> Team,
>
>
>
> I am in need of some help.
>
> I would love to get some assistance on this.
>
> I need to start creating a database for my website.
>
> This will be for a fantasy football league website.
>
> To store stats on the database for archive purposes,
>
> And be able to pull them out on html reports.
>
>
>
> I want to do something similar to this site here.
>
> http://www.webleaguemanager.com/demo/reports/FantasyStandingsRpt.html
>
>
>
> Please review the reports page on the left.
>
>
>
> I want to do all except for real time scoring.
>
> Do not have the monies to purchase that yet, LOL.
>
>
>
> I will be extracting the data from other sites, like NFL.com and ESPN.com
>
>
>
> I know I need to create the players, members, stats tables.
>
> But, I am not sure how to set them up correctly.
>
> I can send you all a word file if you private message me.
>
> It will show what I am looking for.
>
>
>
> Here is a link on my wish list at the moment.
>
>
>
> http://www.theufl.com/ufl_project.htm
>
>
>
> I want to do all the work. I basically just need a instructor to help me
> along the way
>
> To, the end. I seem to never get any one to help me on this. Maybe, because
> I am
>
> A newbie and not sure what to do or what right questions to ask as well.
>
>
>
> Any help in this ordeal would be greatly appreciated. I have NO TIME TABLE
> on this.
>
> Just, a personal goal of mine for me and my friends.
>
>
>
> Please help me through this! :-)
>
>
>
>
>
>
>
> Karl James
>
> [EMAIL PROTECTED]
>
> www.theufl.com
>
>
>
>
>
>
--- End Message ---
--- Begin Message ---
Chris wrote:
> [error] => 2
> And also gives you an error code.
Yes, I know and knew that. That's why the upload ultimately fails
(which is okay).
My point is that when a file's size exceeds the MAX_FILE_SIZE value,
I want the browser to (a) detect that it's too large BEFORE
attempting to upload it and (b) report the file size back to the
user. That's what's not happening.
--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Jeff Cohan [mailto:[EMAIL PROTECTED]
> Sent: 23 September 2007 00:02
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] MAX_FILE_SIZE not working with file uploads
>
> Chris wrote:
> > [error] => 2
> > And also gives you an error code.
>
> Yes, I know and knew that. That's why the upload ultimately fails
> (which is okay).
>
> My point is that when a file's size exceeds the MAX_FILE_SIZE value,
> I want the browser to (a) detect that it's too large BEFORE
> attempting to upload
I might be wrong but this would be classed as 'exploitable'... Webservers
should not be allowed to read from or write to clients... Of course there is
ActiveX...
Dan
--- End Message ---
--- Begin Message ---
Dan Parry wrote:
> I might be wrong but this would be classed as
> 'exploitable'... Webservers should not be allowed
> to read from or write to clients... Of course there
> is ActiveX...
I think we're off the point.
My script is simply interrogating the value of the
$_FILES[userfile][size] array element. It's coming up as ZERO if it
exceeds the MAX_FILE_SIZE. That seems odd to me. But maybe that's
the way it's SUPPOSED to work. That's why I started this thread out
with "What am I missing?".
Said another way:
It seems that the server had to know the size of the file in order
to know it exceeded MAX_FILE_SIZE. So how can my script find out the
size?
--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Jeff Cohan [mailto:[EMAIL PROTECTED]
> Sent: 23 September 2007 02:45
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] MAX_FILE_SIZE not working with file uploads
>
>
>
> Dan Parry wrote:
> > I might be wrong but this would be classed as
> > 'exploitable'... Webservers should not be allowed
> > to read from or write to clients... Of course there
> > is ActiveX...
>
> I think we're off the point.
>
> My script is simply interrogating the value of the
> $_FILES[userfile][size] array element. It's coming up as ZERO if it
> exceeds the MAX_FILE_SIZE. That seems odd to me. But maybe that's
> the way it's SUPPOSED to work. That's why I started this thread out
> with "What am I missing?".
>
> Said another way:
>
> It seems that the server had to know the size of the file in order
> to know it exceeded MAX_FILE_SIZE. So how can my script find out the
> size?
I'm not sure it can... The server has to accept the file before it can
process any details on it
The MAX_FILE_SIZE input field is notoriously unreliable... I think if it
returns zero (0) then the PHP limit is reached
Dan
--- End Message ---
--- Begin Message ---
On Saturday 22 September 2007 7:44:55 pm Jeff Cohan wrote:
> Dan Parry wrote:
> > I might be wrong but this would be classed as
> > 'exploitable'... Webservers should not be allowed
> > to read from or write to clients... Of course there
> > is ActiveX...
>
> I think we're off the point.
>
> My script is simply interrogating the value of the
> $_FILES[userfile][size] array element. It's coming up as ZERO if it
> exceeds the MAX_FILE_SIZE.
Exactly, no valid file was uploaded. The size of the valid file is therefore
zero.
> That seems odd to me.
> But maybe that's
> the way it's SUPPOSED to work. That's why I started this thread out
> with "What am I missing?".
>
> Said another way:
>
> It seems that the server had to know the size of the file in order
> to know it exceeded MAX_FILE_SIZE. So how can my script find out the
> size?
Can you use Javascript to check file size client side, send data via AJAX then
issue warnings? (Remember the php mantra: "PHP is a server side language" )
As noted in the php.net documentation you quoted, and as mentioned previously,
MAX_FILE_SIZE is a _hint_ to the browser. some browsers just don't take
hints.
Ray
--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Ray [mailto:[EMAIL PROTECTED]
> Sent: 23 September 2007 02:25
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] MAX_FILE_SIZE not working with file uploads
>
> On Saturday 22 September 2007 7:44:55 pm Jeff Cohan wrote:
> > Dan Parry wrote:
> > > I might be wrong but this would be classed as
> > > 'exploitable'... Webservers should not be allowed
> > > to read from or write to clients... Of course there
> > > is ActiveX...
> >
> > I think we're off the point.
> >
> > My script is simply interrogating the value of the
> > $_FILES[userfile][size] array element. It's coming up as ZERO if it
> > exceeds the MAX_FILE_SIZE.
>
> Exactly, no valid file was uploaded. The size of the valid file is
> therefore
> zero.
>
> > That seems odd to me.
> > But maybe that's
> > the way it's SUPPOSED to work. That's why I started this thread out
> > with "What am I missing?".
> >
> > Said another way:
> >
> > It seems that the server had to know the size of the file in order
> > to know it exceeded MAX_FILE_SIZE. So how can my script find out the
> > size?
>
> Can you use Javascript to check file size client side, send data via
> AJAX then
> issue warnings
This would be the exploitable 'feature' I mentioned... Client-side files
should never be readable
Dan
--- End Message ---
--- Begin Message ---
Per Jessen wrote:
Stut wrote:
Stefano Esposito wrote:
i'm in need to limit the numbers of conection to the database,
whithout loose of functionality. There is a general strategy to
achieve this?
1) Caching
2) Caching
3) Caching
And if all that fails...
4) Caching
And mysqls query cache does that pretty well.
http://dev.mysql.com/doc/refman/5.0/en/query-cache.html
Indeed, but only if you're making a lot of repetitive queries to the
database. However, since the OP wants to reduce the number of
connections to the database, query caching may reduce the time each
connection is held for it will not reduce the overall number of connections.
The point I'm trying to make is that while the query cache can be a huge
improvement to some websites it's not a substitute for query optimisation.
-Stut
--
http://stut.net/
--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Daniel Brown [mailto:[EMAIL PROTECTED]
> Sent: 21 September 2007 23:27
> To: Stut
> Cc: Eric Lommatsch; [EMAIL PROTECTED]
> Subject: Re: [PHP] Access name of variable in $_POST array
>
> On 9/21/07, Stut <[EMAIL PROTECTED]> wrote:
> > Please include the list when replying.
> >
> > Eric Lommatsch wrote:
> > > -----Original Message-----
> > > From: Stut [mailto:[EMAIL PROTECTED]
> > > Sent: Friday, September 21, 2007 3:09 PM
> > > To: Eric Lommatsch
> > > Cc: [EMAIL PROTECTED]
> > > Subject: Re: [PHP] Access name of variable in $_POST array
> > >
> > > Eric Lommatsch wrote:
> > >> I am writing a PHP script that is going to accept variables that
> are
> > >> passed from a PDF form and should write both the name of the
> variable
> > >> and its value to a text file.
> > >>
> > >>
> > >> I can get the value that I want to retrieve with out problem.
> However,
> > >> even though I have searched through the PHP.net site and googled
> this
> > >> as well I have not yet been able to find the syntax that I need to
> get
> > >> the names of the variables in the $_Post array.
> > >>
> > >> Can someone point me to the place in the PHP manual where I can
> find
> > >> the syntax to get the name of a variable in the $_POST array?
> > >
> > > http://php.net/array_keys
> > >
> > > As in...
> > >
> > > $varnames = array_keys($_POST);
> > >
> > > -Stut
> > >
> > > --
> > > http://stut.net/
> > >
> > > Hello Stut,
> > >
> > > That is not exactly what I am looking for. If I try using that in
> My PHP
> > > script what I get as a result of that is repeatedly the Phrase
> "Post Array"
> > > when I check the values there. The PDF form that is posting to the
> PHP script
> > > is passing variable names like "Employer_name" or "Employee_Name".
> I am
> > > hoping to get those variable names.
> >
> > Put this line at the top of the script that the form posts to...
> >
> > print '<pre>'.print_r($_POST, true).'</pre>'; exit;
> >
> > That will display the contents of the $_POST array and you should be
> > able to figure out where everything is.
> >
> > By the sounds of it the posted values are actually in $_POST['Post
> > Array'] but use the above line to be sure.
> >
> > -Stut
> >
> > --
> > http://stut.net/
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> Maybe this will get you started and give you some ideas.
>
> <?
> foreach($_POST as $p => $v) {
> $$p = $v;
> echo $p." = ".$v."\n";
> }
> ?>
I might be missing something but I fail to see the point of the variable
variable assignation (which is best to be avoided :) )
Dan
--- End Message ---
--- Begin Message ---
So replace ' \" ' instead of ' " '.
On 9/22/07, Jim Lucas <[EMAIL PROTECTED]> wrote:
> Kevin Waterson wrote:
> > I am using str_replace to strip double quotes.
> >
> > $string = 'This string has "quotes" in it';
> >
> > $string = str_replace('"', '', $string);
> >
> > this seems to work, yet when I put the $string into mysql,
> > it uses backslashes to escape where the quotes were. The
> > double-quotes are gone, yet it still escapes the 'ghost'
> > where they were.
> >
> > I even tried
> > str_replace(array("\x8c", "\x9c", "'", '"'), '', $string)
> > but the ghost remains and mysql continues to escape them.
> >
> > I check the charsets, and the db is Latin-1 and the sting is ISO-8859-1
> >
> > Any thoughts on this would be most graciously accepted.
> > Kind regards
> > kevin
> >
> >
> is $string honestly something that you are getting via a form submit?
>
> if so, your system might have magic quotes enabled.
>
> This would automatically escape quotes with the attempt to make the
> values safer, and then you go and run your str_replace command and
> remove the double quotes, you end up leaving the '\' that the system
> automatically put in the value for you.
>
> read up on magic quote gpc
>
> hope this helps.
>
> Jim
>
> --
> Jim Lucas
>
>
> "Perseverance is not a long race;
> it is many short races one after the other"
>
> Walter Elliot
>
>
>
> "Some men are born to greatness, some achieve greatness,
> and some have greatness thrust upon them."
>
> Twelfth Night, Act II, Scene V
> by William Shakespeare
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---