php-general Digest 12 Sep 2007 08:39:57 -0000 Issue 5014

Topics (messages 261974 through 261997):

Re: SEARCHING for an answer...
        261974 by: Jay Blanchard
        261975 by: Robert Cummings
        261976 by: Robert Cummings
        261977 by: Jay Blanchard
        261978 by: Jason Pruim
        261979 by: Jay Blanchard
        261980 by: Jason Pruim
        261981 by: Jason Pruim
        261982 by: Jay Blanchard
        261985 by: brian
        261986 by: mike
        261988 by: tedd

Re: Public Announcement
        261983 by: Greg Donald
        261987 by: Tom Ray [Lists]

Re: Using a variable for include statement
        261984 by: Tom Ray [Lists]

Re: MySQL upload problem
        261989 by: tedd
        261990 by: Chris
        261991 by: brian
        261992 by: Chris
        261993 by: brian
        261994 by: brian

Re: MIME type
        261995 by: heavyccasey.gmail.com

Just Thanks..
        261996 by: Shahrzad

html to xml?
        261997 by: Slith

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 ---
[snip]
Total length is 293 lines.

It redirects before any output of $search is visible.
I put it up as a .txt file at: raoset.com/oldb/index.txt for anyone  
who wants to see the code...

I know it repeats it's self, but I couldn't figure out how to get it  
to log in and stay logged in right without doing that... If anyone  
has any ideas on that as well... But that is a different issue :)
[/snip]

Use a SESSION to keep the user logged in. I am reading the code now. 

--- End Message ---
--- Begin Message ---
On Tue, 2007-09-11 at 15:42 -0400, Jason Pruim wrote:
>
> Total length is 293 lines.
> 
> It redirects before any output of $search is visible.
> I put it up as a .txt file at: raoset.com/oldb/index.txt for anyone  
> who wants to see the code...
> 
> I know it repeats it's self, but I couldn't figure out how to get it  
> to log in and stay logged in right without doing that... If anyone  
> has any ideas on that as well... But that is a different issue :)

*lol* I ALWAYS create a wrapper function to perform redirects so that in
times of confusion I can add a simple print_r( debug_backtrace() ) to
find out where the hell the redirect is occurring :) it's also simpler
for ensuring that I use the Location header properly (absolute URL) and
for saving me having to write header( 'Location: '.$wherever ) when it's
so much clearer to write: doRedirect( $wherever ).

Cheers,
Rob.
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

--- End Message ---
--- Begin Message ---
On Tue, 2007-09-11 at 15:42 -0400, Jason Pruim wrote:
> It redirects before any output of $search is visible.
> I put it up as a .txt file at: raoset.com/oldb/index.txt for anyone  
> who wants to see the code...

I took a look and now I can't get my eyes to stop bleeding. The horror,
the horror! Mixed PHP/HTML is yucky :)

Cheers,
Rob.
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

--- End Message ---
--- Begin Message ---
[snip]
> <td><a href='edit.php?Record={$row['Record']}'>Edit</a></td> is the
> ONLY reference to edit.php in the entire code of that page.
[/snip]

No it isn't. edit.php shows up a couple of times, not the least of which
is row 218;

echo "<form method='GET' action='edit.php'>";

Do you know where the closing form tag is for this? Line 288. If you
look at your source with the search form in place you will see that it
calls edit.php as your action. You left out a closing form tag
somewhere. 

--- End Message ---
--- Begin Message ---

On Sep 11, 2007, at 3:58 PM, Robert Cummings wrote:

On Tue, 2007-09-11 at 15:42 -0400, Jason Pruim wrote:
It redirects before any output of $search is visible.
I put it up as a .txt file at: raoset.com/oldb/index.txt for anyone
who wants to see the code...

I took a look and now I can't get my eyes to stop bleeding. The horror,
the horror! Mixed PHP/HTML is yucky :)


I know it's a bit of a mess now that I'm looking at it... The whole project has been done as a learning experience for me, And I have learned alot. NOW I just need to figure out how I am going to display the pages (I think use a .php extension and heredoc to serve up the HTML) and go through and convert it all over to a much nicer syntax... :)

--
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
[snip]
I took a look and now I can't get my eyes to stop bleeding. The horror,
the horror! Mixed PHP/HTML is yucky :)
[/snip]

8^{)}

Undoubtedly things could be organized better. Jason did you just sit
down and code or did you walk it through with paper and pencil (or
notepad even)?

--- End Message ---
--- Begin Message ---

On Sep 11, 2007, at 3:59 PM, Jay Blanchard wrote:

[snip]
<td><a href='edit.php?Record={$row['Record']}'>Edit</a></td> is the
ONLY reference to edit.php in the entire code of that page.
[/snip]

No it isn't. edit.php shows up a couple of times, not the least of which
is row 218;

echo "<form method='GET' action='edit.php'>";

Do you know where the closing form tag is for this? Line 288. If you
look at your source with the search form in place you will see that it
calls edit.php as your action. You left out a closing form tag
somewhere.


Son of a Bitch... Soon as I closed that down at line 265 the search now isn't redirecting to edit.php.... Do you debug by hand? Or do you have something that helps you to do that? I've been tearing my hair out for hours trying to find that and I couldn't see it...


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---

On Sep 11, 2007, at 4:02 PM, Jay Blanchard wrote:

[snip]
I took a look and now I can't get my eyes to stop bleeding. The horror,
the horror! Mixed PHP/HTML is yucky :)
[/snip]

8^{)}

Undoubtedly things could be organized better. Jason did you just sit
down and code or did you walk it through with paper and pencil (or
notepad even)?

I didn't go through and do a whole flow chart... I did write down the goals of the project though. I probably should have put more time into planning before starting to code it... With a well thought out plan I could have done some research and come to the conclusions that I have now and have to redo it :)

That one programming class in high school is starting to creep back into my brain about how to do stuff :)



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
[snip]
Son of a Bitch... Soon as I closed that down at line 265 the search  
now isn't redirecting to edit.php.... Do you debug by hand? Or do you  
have something that helps you to do that? I've been tearing my hair  
out for hours trying to find that and I couldn't see it...
[/snip]

Debugged by hand. And I never tried to load in a browser.

1. Searched for edit.php in the file to make sure it appeared nowhere
else.
2. When I found the form call I looked for the closing form tag. None
found till after your search query. BINGO! Knew that if you viewed the
source that your opening form tag (subsequent ones get ignored, you must
close each form tag first) would have an action of edit.php, not
PHP_SELF

Now, I am old school and your code had reasonable whitespace and
indentations...BUT NO COMMENTS! Well some, but not enough...you never
explain the logic, just things like // Show your login form here. YOU
MUST EXPLAIN THE LOGIC OR YOU WILL HAVE PROBLEMS MAINTAINING THE CODE 2
WEEKS FROM NOW MUCH LESS 2 MONTHS FROM NOW.

So Jason you learned three valuable lessons today.

a. plan your code (use paper and pencil or something like it)
b. always account for security
c. comment properly

Now, here is something you can do for a project; create a file parser
that will look for all opening/closing tag pairs. I did not need one in
this short code, but had it been longer I might have thrown something
like this at it.

--- End Message ---
--- Begin Message ---
Jay Blanchard wrote:

So Jason you learned three valuable lessons today.

a. plan your code (use paper and pencil or something like it)
b. always account for security
c. comment properly


I'll add two more:

d: Check the source that your script outputs. Send it to the W3C validator (WebDeveloper Firefox extension is one of your bestest ever friends).

e: (my personal opinion) Using echo() to spit out HTML will lead to *much* heartache and gnashing of teeth. Put a closing PHP tag ("?>") in there and let the parser spit out the markup without echo().

either:

-- snip --
while($row = mysql_fetch_assoc($result))
{
?>
  <tr>
  <td><?= $row['FName'] ?></td>
  <td><?= $row['LName'] ?></td>
  <td><?= $row['Add1'] ?></td>
...
<?php
}
-- snip --

or:

-- snip --
while($row = mysql_fetch_assoc($result))
{
?>
  <tr>
  <td><?php echo $row['FName'] ?></td>
  <td><?php echo $row['LName'] ?></td>
  <td><?php echo $row['Add1'] ?></td>
...
<?php
}
-- snip --

or, as i said, use a template system.

brian

--- End Message ---
--- Begin Message ---
On 9/11/07, brian <[EMAIL PROTECTED]> wrote:
> e: (my personal opinion) Using echo() to spit out HTML will lead to
> *much* heartache and gnashing of teeth. Put a closing PHP tag ("?>") in
> there and let the parser spit out the markup without echo().

i think this is quite opposite. i prefer echo'ing everything. it
allows me to indent the code perfectly in the right nested places. i
hate inline php/html mixes.

> or, as i said, use a template system.

a good presentation layer is always a good idea :)

--- End Message ---
--- Begin Message ---
At 4:01 PM -0400 9/11/07, Jason Pruim wrote:
Son of a Bitch... Soon as I closed that down at line 265 the search now isn't redirecting to edit.php.... Do you debug by hand? Or do you have something that helps you to do that? I've been tearing my hair out for hours trying to find that and I couldn't see it...

Yes, most of us debug by hand -- some of us still have hair.

It would probably help you if you would make your problems small ones and work in smaller incremental steps. It's far easier to debug 10-20 lines than 200-300 lines.

Cheers,

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
On Tue, 11 Sep 2007, Stut wrote:
> You didn't say what you have against mod_rewrite. I'll bet you mod_rewrite can
> parse a request and send it to the right script faster than your PHP
> implementation.

Has anyone tried Nginx?  The rewrite rules are a bit more clear than
those of the Apache mod_rewrite variety.

http://wiki.codemongers.com/NginxHttpRewriteModule


-- 
Greg Donald
Cyberfusion Consulting
http://cyberfusionconsulting.com/

--- End Message ---
--- Begin Message ---
Greg Donald wrote:
On Tue, 11 Sep 2007, Stut wrote:
You didn't say what you have against mod_rewrite. I'll bet you mod_rewrite can
parse a request and send it to the right script faster than your PHP
implementation.

Has anyone tried Nginx?  The rewrite rules are a bit more clear than
those of the Apache mod_rewrite variety.

http://wiki.codemongers.com/NginxHttpRewriteModule

But is it the greatest weapon system of our time? If its not then it's nothing to me.
--- End Message ---
--- Begin Message ---
Jeff Benetti wrote:
Sorry if this is a noob question, I have used PERL, TCL and VB but I am just
getting into PHP.  If there is a better place to ask noobie questions then
let me know.

I want to use the include statement but I want to pass the name of the file
rather than hard code it.  It seems that PHP needs the file to be in its
defined PATH in order to do this (or am I wrong?).

My code works OK if I use hard coding

Example (works)

include ('somefile.php')

Example (doesn't work)

$TheFile = "somefile.php"

include ($TheFile)

Am I trying to do  something that is impossible?

If it is a path problem then how do I get around this, I can control my
local server config but I only have a local server for development.

Thanks,
Jeff

Jeff, there are a couple ways you can do this.

1) include("/path/to/".$TheFile."/");

2) include $TheFile;

Notice the lack of brackets in the last one. Either way has worked for me.

--- End Message ---
--- Begin Message ---
At 4:46 PM +0100 9/11/07, Stut wrote:
tedd wrote:
I know that this is not a php question, but all of you are so smart I thought would ask anyway.

I need to upload a 5 Meg sql file to a client's database. However, his site's phpMyAdmin shows a maximum file size limit of 2 Meg.

Now, is this something that is controlled by his host, or is there a way for me to get around it without requiring his host to do something, or what? How can I do this?

Manually break the SQL file into several pieces. You may need to duplicate some statements at the top and tail of the main file in each part and also make sure that you duplicate any USE DATABASE statements to ensure you're on the right DB.

You'll also need to make sure you execute them on the server in order.

-Stut

-Stut:

This is a relational dB and the several times that I have attempted to load it in "in parts" has met with failure.

I was thinking that I could ftp the sql file to the clients server and then run a php script on his server, something like:

$sql = "mysql  -h$dbhost -u$dbuser -p$dbpass $dbname < $filename";
system($sql);

But, that didn't work -- however -- using mysqldump did download the file. So, I'm close.

I know that safe_mode is ON, but I'm not sure if that's what's causing the failure or something else.

There has to be a simple way to do this.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
tedd wrote:
At 4:46 PM +0100 9/11/07, Stut wrote:
tedd wrote:
I know that this is not a php question, but all of you are so smart I thought would ask anyway.

I need to upload a 5 Meg sql file to a client's database. However, his site's phpMyAdmin shows a maximum file size limit of 2 Meg.

Now, is this something that is controlled by his host, or is there a way for me to get around it without requiring his host to do something, or what? How can I do this?

Manually break the SQL file into several pieces. You may need to duplicate some statements at the top and tail of the main file in each part and also make sure that you duplicate any USE DATABASE statements to ensure you're on the right DB.

You'll also need to make sure you execute them on the server in order.

-Stut

-Stut:

This is a relational dB and the several times that I have attempted to load it in "in parts" has met with failure.

Split the database up per table - I have a perl script if you want it.

Upload each table separately.

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
tedd wrote:
I was thinking that I could ftp the sql file to the clients server and then run a php script on his server, something like:

$sql = "mysql  -h$dbhost -u$dbuser -p$dbpass $dbname < $filename";
system($sql);

But, that didn't work -- however -- using mysqldump did download the file. So, I'm close.

I know that safe_mode is ON, but I'm not sure if that's what's causing the failure or something else.


Just a thought: did you pass the full path for $filename?

Also, pass in a return var to read:

system($sql, $ret);

if ($ret === 0) { echo 'sucess'; }

Sorry, you'll have to hunt down the other return codes that MySQl might send back.

If safe_mode is enabled, your command will be escaped with escapeshellcmd() but that's about it.

If you can FTP it but can't get a shell is there any chance you could convince an admin to run the script?

brian

--- End Message ---
--- Begin Message ---
tedd wrote:
At 4:46 PM +0100 9/11/07, Stut wrote:
tedd wrote:
I know that this is not a php question, but all of you are so smart I thought would ask anyway.

I need to upload a 5 Meg sql file to a client's database. However, his site's phpMyAdmin shows a maximum file size limit of 2 Meg.

Now, is this something that is controlled by his host, or is there a way for me to get around it without requiring his host to do something, or what? How can I do this?

Manually break the SQL file into several pieces. You may need to duplicate some statements at the top and tail of the main file in each part and also make sure that you duplicate any USE DATABASE statements to ensure you're on the right DB.

You'll also need to make sure you execute them on the server in order.

-Stut

-Stut:

This is a relational dB and the several times that I have attempted to load it in "in parts" has met with failure.

I was thinking that I could ftp the sql file to the clients server and then run a php script on his server, something like:

$sql = "mysql  -h$dbhost -u$dbuser -p$dbpass $dbname < $filename";
system($sql);

But, that didn't work -- however -- using mysqldump did download the file. So, I'm close.

Actually reading the php site:

http://php.net/system

With safe mode enabled, the command string is escaped with escapeshellcmd().

Then http://www.php.net/manual/en/function.escapeshellcmd.php:

Following characters are preceded by a backslash: #&;`|*?~<>^()[]{}$\, \x0A and \xFF.

So your < is being replaced with \< which is why it wouldn't work.

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
Chris wrote:
tedd wrote:

I was thinking that I could ftp the sql file to the clients server and then run a php script on his server, something like:

$sql = "mysql  -h$dbhost -u$dbuser -p$dbpass $dbname < $filename";
system($sql);

But, that didn't work -- however -- using mysqldump did download the file. So, I'm close.


Actually reading the php site:

http://php.net/system

With safe mode enabled, the command string is escaped with escapeshellcmd().

Then http://www.php.net/manual/en/function.escapeshellcmd.php:

Following characters are preceded by a backslash: #&;`|*?~<>^()[]{}$\, \x0A and \xFF.

So your < is being replaced with \< which is why it wouldn't work.


Right. You could try mysqlimport to get around using the < instead. Strip out all but the ddl statements (CREATE TABLE and friends) and place them into separate files for each table. That is, name each file for the table its data corresponds to. Upload the ddl stuff with phpMyAdmin, then import the data with mysqlimport through your script.

However, i think you might need FILE privilege.

Instead of putzing around with your existing dump file to copy everything out, you could import everything to a local database (if you don't have it already) and dump out each table to a separate file.

brian

--- End Message ---
--- Begin Message ---
brian wrote:
tedd wrote:

I was thinking that I could ftp the sql file to the clients server and then run a php script on his server, something like:

$sql = "mysql  -h$dbhost -u$dbuser -p$dbpass $dbname < $filename";
system($sql);

But, that didn't work -- however -- using mysqldump did download the file. So, I'm close.

I know that safe_mode is ON, but I'm not sure if that's what's causing the failure or something else.


Just a thought: did you pass the full path for $filename?

Also, pass in a return var to read:

system($sql, $ret);

if ($ret === 0) { echo 'sucess'; }

Sorry, you'll have to hunt down the other return codes that MySQl might send back.

If safe_mode is enabled, your command will be escaped with escapeshellcmd() but that's about it.

If you can FTP it but can't get a shell is there any chance you could convince an admin to run the script?


Also, to be on the safe side, you might want to include set_time_limit(0); in your script, also (if you can get system() to work, that is).

brian

--- End Message ---
--- Begin Message ---
Look up readfile();

Make sure you read the comments.

On 9/11/07, Angelo Zanetti <[EMAIL PROTECTED]> wrote:
>     Hi guys.
>
> I am linking to a file on a WAP site. the backend is written in PHP.
> However I need to link to a file but set the content type. I've done the
> following and am wondering if this is correct:
>
> <?
>
> // We'll be outputting a PDF
> header('Content-type: application/vnd.symbian.install');
>
> // It will be called downloaded.pdf
> header('Content-Disposition: attachment;
> filename="../File/norEnglish.sis"');
>
> ?>
>
>
> So basically I set the HREF to the file above (filename .php).
>
> Let me know if there is anything that im doing incorrectly.
>
> Thanks
>
> --
> ------------------------------------------------------------------------
> Angelo Zanetti
> Systems developer
> ------------------------------------------------------------------------
>
> *Telephone:* +27 (021) 552 9799
> *Mobile:*       +27 (0) 72 441 3355
> *Fax:*            +27 (0) 86 681 5885
> *
> Web:* http://www.zlogic.co.za
> *E-Mail:* [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
IRIran.net'Remove page referrer'  was my first question from PHP.net mailing 
lists, 
that's great :) , php have a good support ,
I think all php lovers gather here :) ,
I love this place ,
 Thanks to all

--- End Message ---
--- Begin Message --- i need to parse an html page for tabular data which i can then import into mysql so i thought converting the html to xml might be a feasible thing to do, however, other than using tidy from the command line i can't find a way to do this from php.

does anyone know of any class (or other) that would allow me to do this? or maybe i just need a different approach.
--- End Message ---

Reply via email to