[PHP] insert data to mysql
Hello, I am just wondering if someone can help me out with this. This is what I have so far, but it isnt working: MYSQL_CONNECT($hostname, $username, $password) or die("Unable to connect to database"); @mysql_select_db( "$dbName") or die( "Unable to select database"); $sql = "INSERT INTO $userstable (client, contact, email, address, city, state, zip, phone, fax, model, country, details, type) VALUES("$client", "$contact", "$email", "$address", "$city", "$state", "$zip", "$phone", "$fax", "$model", "$country", "$details", "$type")"; $result = MYSQL_QUERY($sql) or die ("Couldn't execute query"); MYSQL_CLOSE(); Im new (no kidding?), so i hope this is easy, also, is there a address anyone can point me to for a archive of this list? Thanks in advance, Shawn
[PHP] RE: insert data to mysql
> Concatenate your string. > > "...VALUES ('".$client."','".$contact."')" (etc.) > > Or just replace the double-quotes within the string with single quotes. > That should do it. I did that but it still doesnt work? Is there something else that I should be passing to the script to let it know to write to fields within the table? Shawn
Re: [PHP] insert data to mysql
define "not work" like is there an error? data not inserting? also, read and bookmark this tutorial, it'll help this and future endeavers : http://www.zend.com/zend/tut/using-strings.php The error is that the data isnt being written to the MySQL database. This is taking variables from a form, and emailing them to a recipient, also it is supposed to write the data to a database. The email works fine, but it just isnt writting to the database? Shawn "thanks for the link"
[PHP] insert into
Could someone tell me how to actually execute this script please? $hostname = ""; $username = ""; $password = ""; $dbName = ""; $userstable = "booking"; MYSQL_CONNECT($hostname, $username, $password) or die("Unable to connect to database"); @mysql_select_db( "$dbName") or die( "Unable to select database"); $mysql_query INSERT INTO $userstable (client, contact, email, address, city, state, zip, phone, fax, model, country, details, type) VALUES('$client', '$contact', '$email', '$address', '$city', '$state', '$zip', '$phone', '$fax', '$model', '$country', '$details', '$type'); MYSQL_CLOSE(); ?> Thanks, also if you know any tutorials for PHP and MySQL Shawn
RE: [PHP] PHP 4.0.5 is out
Is anyone else having problems with the Windows binary zip? I've downloaded it a couple times and it keeps saying that it's corrupt. Thanks! Shawn Sellars -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] wordwrap
Is there a tag in php that acts like "wordwrap=virtual" does in html? I have a script that is sending out variables in a email from a contact form, but for a comments section it will not wordwrap in the email. Thanks Shawn
[PHP] session_start ()
When using session_start () over alot of pages, do i need to reregister the origional session? example: page1:session_start(); session_register('data'); page2:session_start(); page3:session_start(); session_register('data'); new to sessions, (no really), so thanks for the help, ill be going through the manual while I wait :-) Shawn
[PHP] InterSystems Cache DB and PHP
Does anyone know if PHP can be used (other than with ODBC) with the Cache database from InterSystems? Thanks in Advance, Shawn Sellars
[PHP] Help w/ exec() on Win2k, IIS5.
Using IIS5 on W2K Server, I can't get get the exec() or other similar commands to work. This is what I'm doing - exec( "dir/a-d/b $dir_name", $arFiles ) The array doesn't contain anything! I've tried it with cmd.exe before the command, but it just seems to get stuck in a loop! Can anyone tell me how to successfully use this command? Or if not, any other ideas on how to get the file names inside a directory into an array? Thanks in Advance, Shawn Sellars
[PHP] URL vars in URL var?
I'm trying to pass a URL as a var in a URL: The url var should equal: http://www.someothersite.com/index.php?something=something&x=100&y=200 And I'm passing it to this URL: http://www.somesite.com/index.php?var=val So if I use: http://www.somesite.com/index.php?var=val&url=http://www.someothersite.com/i ndex.php?something=something&x=100&y=200 The problem is, if I echo $url; I get the following: http://www.someothersite.com/index.php?something=something So the vars after the & in the url var are being truncated, I'm assuming that they are treated as vars of the main URL. Any help appreciated, Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL vars in URL var?
Great thanks! Since I'm doing this from an anchor or in the browser location bar, I just replaced the & in the url var with %26. Works great! -Shawn "Adam Voigt" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... http://www.php.net/manual/en/function.urlencode.php Pass it through that function (or one of the others) on: http://www.php.net/manual/en/ref.url.php On Tue, 2002-12-03 at 12:01, Shawn McKenzie wrote: I'm trying to pass a URL as a var in a URL: The url var should equal: http://www.someothersite.com/index.php?something=something&x=100&y=200 And I'm passing it to this URL: http://www.somesite.com/index.php?var=val So if I use: http://www.somesite.com/index.php?var=val&url=http://www.someothersite.com/i ndex.php?something=something&x=100&y=200 The problem is, if I echo $url; I get the following: http://www.someothersite.com/index.php?something=something So the vars after the & in the url var are being truncated, I'm assuming that they are treated as vars of the main URL. Any help appreciated, Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Adam Voigt ([EMAIL PROTECTED]) The Cryptocomm Group My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Objects and Classes?
First, I'm more of a quick learning hack than a developer. I have some code with a few functions that I've written. I have moved a good part of this to a class and have updated the code to define an object based on this class and do its stuff. I feel that I understand objects/classes and how to code and use them, but what I'm having trouble with is the logic of building the class. Why did I build the class (just seemed like the thing to do)? Should the class be most of my app so that it can be accessed by others? This is more of a high-level app development question. Does anyone have good info or methodology on when to use a class and what components make sense to include in the class? How many classes? I could send my code to anyone who is a guru in this that could just give me some high-level advice. Thanks! Shawn (Just learning) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Objects and Classes?
Very cool! Thanks! "Christopher Raymond" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > Shawn: > > I beleive I can clarify the purpose of objects/classes for you and > enrich my clarification with a couple of examples. > > > THE DIFFERENCE BETWEEN "OBJECT" AND "CLASS": > > A class defines the structure of an object. A class is a "template" > for an object. An object is a container for data and for functions that > operate on that data. A class is a roadmap -- it defines the object's > structure. You can then create several objects using one class. These > several objects are separate from one another, but identical in > structure. Each can contain different data but use the same functions to > operate on that data. > > Functions contained within an object class are called methods. > Functionally, methods are exactly the same as functions except that they > are restricted to the scope of the object. Generally, a method is a > function that operates on the object's data. An object contains variable > data including variables, arrays and objects. These variables are called > the object's properties. > > > WHEN TO USE OBJECTS: > > Objects could be used when you have several similar pieces of data > especially when you wish to have that data manipulated by the same > functions but wish to maintain separation between these data objects. > > > EXAMPLE: > > Let's say, for example, that you wished to store information about a > number of different people within a single script execution. An > insurance site might wish to gather information about the primary > applicant, his wife and their three children all on the same page. > > You and I would agree that all people have similar properties; we all > have an age, a height, a weight - we might smoke etc. Therefore, a class > for people could be defined. > > class Human > { > var $age; > var $height_inches; > var $weight_pounds; > var $smoker; > > function HeightWeightRatio() > { > $ratio = $this->height_inches / $this->weight_pounds; > return $ratio; > } } > } } > > To create an instances of the class (an object) you would use > something like this: > > $father = new Human; > $mother = new Human; > > Once you have instantiated the class (previous lines) you could then > set the values of the object with code like: > > $father->age = 49; > $father->height = "5'11"; > $father->weight = 215; > $father->smoker = false; > > $father_ratio = $father->HeightWeightRatio(); > > $mother->age = 47; > $mother->height = "5'5"; > $mother->weight = 145; > $mother->smoker = true; > > $mother_ratio = $mother->HeightWeightRatio(); > > By now, I'm sure you get the picture. > > > THE MOST USEFUL EXAMPLE FOR ME THUS FAR: > > class HTMLTemplate > { > > var $template; > var $html; > var $parameters > = array(); > var $populated = false; > > function HTMLTemplate ( > $template) > { > > $this->template = $template; > $this->html = > implode ("", (file($this->template))); > > } > > function SetParameter ( > $variable, $value) > { > > $this->parameters[$variable] = $value; > > } > > > function PopulateValues () > { > > foreach ($this->parameters as > $key => $value) > { > > $template_name = ' >'; > $this->html = str_replace ($template_name, $value, $this->html); > } > > > $this->populated = true; > } > > function ReturnHTML () > { > if ( > $this->populated) > { > return $this->html; > } > else > { > > $this->PopulateValues(); > return $this->html; > } > } > } > > This class allows you to use an html template file which you can paste > dynamic values/content into. Here's an example of how to use it: > > > $title = "My Web Page"; > $content = "Hello, this is my web page."; > > $template = new HTMLTemplate("/mytemplate.html"); > $template->setParameter("PAGE-TITLE", $title); > $template->setParameter("CONTENT", $content); > > echo $template->ReturnHTML(); // Sends html to the browser > > // It is important to destroy an object once you are finished > // using it so that you can free up the memory space that it uses > > unset($template); // Destroys instance of object > > ?> > > HTML TEMPLATE FILE: > > My html template file might look like this: > > > > > > > > > > > > Christopher Raymond, > Oasis Networks <-- Web Development & Macintosh Systems Consulting -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Include?
It seems that if I create a php file in my dir at my hosting provider and do include('/etc/passwd'); then wow, I see the contents of etc/passwd! Is this expected behavior??? I am looking at creating a script that takes a var in the url and includes the requested file. The purpose would be for only URLs (myscript.php?page=http://mysite.com/dir/cool.html, or relative URLs (myscript.php?page=/dir/cool.html). Can I do this without allowing someone to include files by filesystem reference??? Thanks! Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Code contents of a function
I have a script with some functions and within the script I want to read the code from one of the functions into a string. Example: function myfunction() { echo "something"; echo "something else"; someotherfunction(); } I want to read: echo "something"; echo "something else"; someotherfunction(); into a string. Any ideas??? TIA -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code contents of a function
What??? I want to read the code from the function into a string! "Peter Houchin" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > so put it in a if or switch statement > > eg > > if ($var){ > myfunction(); > } > else { > sumotherfunction(); > } > > etc > > > > -Original Message- > > From: Shawn McKenzie [mailto:[EMAIL PROTECTED]] > > Sent: Friday, 3 January 2003 12:18 PM > > To: [EMAIL PROTECTED] > > Subject: [PHP] Code contents of a function > > > > > > I have a script with some functions and within the script I want > > to read the > > code from one of the functions into a string. > > > > Example: > > > > function myfunction() { > > echo "something"; > > echo "something else"; > > someotherfunction(); > > } > > > > I want to read: > > > > echo "something"; > > echo "something else"; > > someotherfunction(); > > > > into a string. > > > > Any ideas??? TIA > > -Shawn > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Parse source for braces
I need to parse some source code to find the contents of a specific function. The only way I can think of is to load the source file into a string find the function by name and parse the text in the string and find the end brace of the function, made difficult by the existence of all the other braces that may be there (if, while, switch, foreach, etc...). Anybody have some code to do this??? function someFunc() { if(something) { something... } while(something) { something... } } // So I need the code from the beginning of the function to here TIA -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Vars in URL
I want to pass vars to another site but I don't want to use a form. How can I pass these vars to another site without the vars being shown in the URL. I tried header("Location:"); TIA, Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Vars in URL
I am trying to do something simple to sell items with paypal. One of the options paypal has is a return url, so that after the buyer pays via the paypal website they are forwarded to the return url (my site) so they can access some info.. The problem is that the form on my site that collects info and posts to paypal has the hidden return url vars in it. So a simple view source in the browser reveals the return url. So what I did is made a form that submits to a php script on my site that then adds the appropriate paypal vars and submits to the paypal site. I used header(Location:"), but this shows the return url var in the url address bar. I want to pass vars to paypal without them being shown in the url address bar. TIA -Shawn "Chris Shiflett" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > --- Shawn McKenzie <[EMAIL PROTECTED]> wrote: > > I want to pass vars to another site but I don't want > > to use a form. How can I pass these vars to another > > site without the vars being shown in the URL. > > That question is far too vague in terms of who needs to be > passing data where. If you want to pass data to a Web > server, and you do not want to use URL variables, then your > only options are POST and cookies. > > If you are speaking about a user of your Web site who needs > to be sending data to a Web server, and you do not want > them to use URL variables or submit an HTML form, then > cookies are your only option. > > Perhaps you can elaborate on what you are trying to > accomplish? > > Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Vars in URL
O.K. I found this at php.net but it doesn't seem to bring up the paypal page. I guess I am trying to simulate a form POST using headers. Any ideas??? $paypal_vars is an array of the vars and values that paypal needs. foreach($paypal_vars as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } $req = substr($req, 1, strlen($req) - 1); $header .= "POST www.paypal.com HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= 'Content-Length: ' . strlen($req) . "\r\n\r\n"; $fp = fsockopen (/xclick/, 80, $errno, $errstr, 30); if(!$fp) { echo "$errstr ($errno)"; } else { fputs($fp, $header . $req); while(!feof($fp)) { $res = fgets ($fp, 1024); } fclose ($fp); } Thanks! Shawn "Chris Shiflett" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > --- Shawn McKenzie <[EMAIL PROTECTED]> wrote: > > I want to pass vars to another site but I don't want > > to use a form. How can I pass these vars to another > > site without the vars being shown in the URL. > > That question is far too vague in terms of who needs to be > passing data where. If you want to pass data to a Web > server, and you do not want to use URL variables, then your > only options are POST and cookies. > > If you are speaking about a user of your Web site who needs > to be sending data to a Web server, and you do not want > them to use URL variables or submit an HTML form, then > cookies are your only option. > > Perhaps you can elaborate on what you are trying to > accomplish? > > Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] emulate full post wth redirect
Wow, has it really been a year. No replies??? Any ideas??? Anyone??? Thanks! Shawn "Bobby Patel" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hello, I want to emulate a POST request to Paypal. Originally a POST request > is sent from the user (through a form) and the user is redirected to > paypal's site. Now, what I want to do is to emulate a POST request (so that > the surfer can't see some of the hidden fields of the form) and to deter > tampering. (If they could see all the fields, they could just create their > own form , and just change the amount). > > Possible solution: > fsockopen to emulate POST, but that doesn;t redirect the user, using header > will direct the user to the paypal site, but then I have to use a GET > request and then once again variables are visible and modifiable. > > > Desired solution: > a PHP script (toPaypal.php, say) that is called when a surfer wants to buy > something for a product for $5 , say. > The Product form will direct to the toPaypal.php script that creates a POST > request and sends the request and the surefer to Paypal. > > Any ideas? or did I just make this confusing? One solution I guess is to > just double check the total amount credited to the merchant account matches > the product. But then I ask this question out of curosity. > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] issues with ksort()
What else does ksort() do to the array??? Does it matter that my keys look like this: '[some-text]'??? This works great: foreach($myarray as $key => $val) { echo "$key = $val"; } This gives me a Warning: Invalid argument supplied for foreach(): $sortedarray = ksort($myarray); foreach($sortedarray as $key => $val) { echo "$key = $val"; } Any ideas??? TIA -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: issues with ksort()
Ah Thanks! -Shawn - Original Message - From: "Paul Chvostek" <[EMAIL PROTECTED]> To: "Shawn McKenzie" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Friday, February 07, 2003 11:18 AM Subject: Re: issues with ksort() On Fri, Feb 07, 2003 at 11:09:10AM -0600, Shawn McKenzie wrote: > > What else does ksort() do to the array??? Does it matter that my keys look > like this: '[some-text]'??? > > This works great: > > foreach($myarray as $key => $val) { > echo "$key = $val"; > } > > This gives me a Warning: Invalid argument supplied for foreach(): > > $sortedarray = ksort($myarray); > foreach($sortedarray as $key => $val) { > echo "$key = $val"; > } > > Any ideas??? Inserting a print_r into your test script tells you the problem, as does a closer look at http://www.php.net/ksort . You're assuming ksort()'s return value is the sorted array. It is not. Try something more along the lines of: $testarray=array( "[three]" => 3, "[two]" => 2, "[one]" => 1, ); ksort($testarray); print_r($testarray); -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Need help storing and displaying html/text!
I have a form and I want the user to be able to enter html in a text area. This will then be stored in an array in a config file. Example $htmlstuff[1] = '
[PHP] Re: Need help storing and displaying html/text!
Hmmm... I guess no one is doing this??? Seems fairly common. Thanks! Shawn "Shawn McKenzie" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I have a form and I want the user to be able to enter html in a text area. > This will then be stored in an array in a config file. Example > $htmlstuff[1] = '
[PHP] Anyone? more info...
Is more info needed, or was everyone just going post replies like: "see stripslashes() and htmlentities()" *** I have a form and I want the user to be able to enter html in a text area. This will then be stored in an array in a config file. Example $htmlstuff[1] = '
[PHP] Re: How can I install PHP 4.2.3 and Apache on WIN98 ?
Apache won't be a service on Win98. there should be a batch file to start it, or just start apache.exe from the command line with options. You'll need to do it every you reboot unless you put a batch file in Startup. Once Apache is running, just follow the install instructions for PHP, restart Apache, and it should work fine. FYI... Posting in this forum you're most likely to just get a link to the Apache documentation. HTH -Shawn "Rija" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I want to run php 4.2.3 on Windows 98 2nd edition using apache server, but > after installing apache on it, I've got the following message, No service > installed. > So how can I install it? Then, I also cannot install php. > > Any thought? > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Anyone? more info...
Thanks Phillip! "Philip Hallstrom" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > That is the right answer though... along with the various magic_quotes > flags in the configuration. > > You need to look at your existing settings and then create a simple test > where you type in something such as: x'x"x\x and then spit it out and save > it and generally see at what point slashes are being added. > > There's a couple of ways to do it... > > put slashes in automatically, strip them on display > don't do it automatically, add them before insertion to a database > > but which one is easiest for you depends on your sites configuration and > what code you've already written, etc... > > -philip > > > On Mon, 10 Feb 2003, Shawn McKenzie wrote: > > > Is more info needed, or was everyone just going post replies like: > > > > "see stripslashes() and htmlentities()" > > > > *** > > > > I have a form and I want the user to be able to enter html in a text area. > > This will then be stored in an array in a config file. Example > > $htmlstuff[1] = '
[PHP] Issue saving php that includes constant---
I collect some PHP code in an HTML form (textarea) I then save this in an array in a file using export_var(). If the code entered in the textarea is this: echo "To "._LOGIN." click the login link below"; And the constant _LOGIN happens to be defined in the current script that generates the form (maybe _LOGIN = "Login" ), then the result after my var_export() to the file is this: $var = 'To Login click the login link below";'; Any ideas on how to keep the text of the constant definition in the string instead of it being evaluated??? TIA, Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] var_export() strips slashes
Seems that var_export() strips slashes from my array keys even though the docs say that it returns valid PHP code. This is bad if I want to use $b below to define another array, gives a parse error on the single quote in the key. $a = array('it\'s here' => 'single, \' double "'); $b = var_export($a, TRUE); echo $b; Displays: array ( 'it's here' => 'single, \' double "', ) And: $c = eval($b); generates a parse error in the eval'ed code. Any help??? TIA, -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: var_export() strips slashes
Is this a real bug, or am I just doing something stupid? :-) Thanks! Shawn > Seems that var_export() strips slashes from my array keys even though the > docs say that it returns valid PHP code. This is bad if I want to use $b > below to define another array, gives a parse error on the single quote in > the key. > > $a = array('it\'s here' => 'single, \' double "'); > $b = var_export($a, TRUE); > echo $b; > > Displays: > array ( 'it's here' => 'single, \' double "', ) > > And: > $c = eval($b); > > generates a parse error in the eval'ed code. > > Any help??? > > TIA, > -Shawn > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Undefined offset notices
While debugging my code, that seems to work fine, I see hundreds of these notices, many different ones with different offset numbers same line number. (I know I can turn notices off) Notice: Undefined offset: 2 in D:\apps\www\test\themes\Family\includes\autotheme.inc.php on line 275 I would like to know what the notice pertains to (offset?) Here's the code: $commands is an associative array, $tmpparts and $tmpcmds are integer index arrays. $i = 0; // Line 270 while($i != count($tmpparts)) { $content = "?>".$tmpparts[$i]; eval($content); foreach($command as $name => $cmds) { if($tmpcmds[$i] == $name) { $docmd = $cmds; eval($docmd); } } $i++; } // Line 281 TIA, Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Derive bottom-most dir from string???
Is there an easy way to derive the bottom-most directory from a string containing a path? Example: $somepath = "html/testsite/templates/shopping"; Becomes: "shopping" TIA -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Derive bottom-most dir from string???
Sorry... Think I was over complicating it. Seems the last element of $somearray from $somearray = explode("/", $somepath); will work well. Thanks! Shawn "Shawn McKenzie" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Is there an easy way to derive the bottom-most directory from a string > containing a path? > > Example: $somepath = "html/testsite/templates/shopping"; > > Becomes: "shopping" > > TIA > -Shawn > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] rewrite rule help anyone?
Slightly off topic, but I have some PHP also ;-) I am trying to make search engine friendly URLs for a site, but want this to be fairly dynamic and work with any new script and vars. If anyone would be willing, I need help on a mod_rewrite rule or rules? I'm thinking it should be fairly simple, but I know nothing about reg expressions. Maybe not the greatest, but here's the code that generates the HTML with altered URLs. This works great, but then I need Apache to rewrite these. ---This: index.php?file=test&cmd=display&what=all ---Becomes: index-get-file-is-test+cmd-is-display+what-is-all.html --Here's the code: ob_start(); echo $htmlpage; $newdisplay = ob_get_contents(); ob_clean_flush(); echo rewrite($newdisplay); function rewrite($newdisplay) { $search = array( ".php?", ".php", "=", "&", "&"); $replace = array( "-get-", "", "-is-", "+", "+"); $hrefs = find_hrefs($newdisplay); $tmphrefs = str_replace($search, $replace, $hrefs); foreach($tmphrefs as $key => $array) { $newhrefs[$key] = $array.".html"; } $newdisplay = str_replace($hrefs, $newhrefs, $newdisplay); return $newdisplay; } //finds href=" in the string containing the html function find_hrefs($tmpcontent) { while($start = strpos($tmpcontent, 'href="', $end)) { $start = $start +6; $end = strpos($tmpcontent, '"', $start); $href[] = substr($tmpcontent, $start, $end - $start); } return $href; } TIA, Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: rewrite rule help anyone?
No takers??? Did I say, Please! Thanks! Shawn "Shawn McKenzie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Slightly off topic, but I have some PHP also ;-) > > I am trying to make search engine friendly URLs for a site, but want this to > be fairly dynamic and work with any new script and vars. > > If anyone would be willing, I need help on a mod_rewrite rule or rules? I'm > thinking it should be fairly simple, but I know nothing about reg > expressions. Maybe not the greatest, but here's the code that generates the > HTML with altered URLs. This works great, but then I need Apache to rewrite > these. > > ---This: > index.php?file=test&cmd=display&what=all > ---Becomes: > index-get-file-is-test+cmd-is-display+what-is-all.html > > --Here's the code: > > ob_start(); > echo $htmlpage; > $newdisplay = ob_get_contents(); > ob_clean_flush(); > echo rewrite($newdisplay); > > function rewrite($newdisplay) > { > $search = array( > ".php?", ".php", "=", "&", "&"); > > $replace = array( > "-get-", "", "-is-", "+", "+"); > > $hrefs = find_hrefs($newdisplay); > $tmphrefs = str_replace($search, $replace, $hrefs); > foreach($tmphrefs as $key => $array) { > $newhrefs[$key] = $array.".html"; > } > $newdisplay = str_replace($hrefs, $newhrefs, $newdisplay); > > return $newdisplay; > } > > //finds href=" in the string containing the html > function find_hrefs($tmpcontent) > { > while($start = strpos($tmpcontent, 'href="', $end)) { > $start = $start +6; > $end = strpos($tmpcontent, '"', $start); > $href[] = substr($tmpcontent, $start, $end - $start); > } > return $href; > } > > TIA, > Shawn > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MIME help needed please...
I got this from the user contributed notes in the php.net manual. It seems to work fine most of the time, but Eudora and Pegasus users either get mangled attachments or no attachments. Can anyone see a problem (most files are zip, but sometimes tar.gz or sit) I tried using Content-Type: application/zip with the same results. I'm thinking it is some issue with the headers, content-types, boundaries or something. Or maybe Pegasus/Eudora don't understand MIME or base64 (doubtful)??? Help appreciated. Thanks! function send_mail($from_name, $from_email, $to_name, $to_email, $subject, $text, $path, $filename) { // encode file attachments foreach($filename as $key => $file) { $fp = fopen($path[$key].$file, "r"); $content = fread($fp, filesize($path[$key].$file)); $attachment[$key] = chunk_split(base64_encode($content)); } // headers need to be in the correct order... $headers = "From: $from_name<$from_email>\n"; $headers .= "Reply-To: <$from_email>\n"; $headers .= "MIME-Version: 1.0\n"; // the following must be one line (post width too small) $headers .= "Content-Type: multipart/related; type=\"multipart/alternative\"; boundary=\"=MIME_BOUNDRY_main_message\"\n"; $headers .= "X-Sender: $from_name<$from_email>\n"; $headers .= "X-Mailer: PHP4\n"; //mailer $headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal $headers .= "Return-Path: <$from_email>\n"; $headers .= "This is a multi-part message in MIME format.\n"; $headers .= "--=MIME_BOUNDRY_main_message \n"; $headers .= "Content-Type: multipart/alternative; boundary=\"=MIME_BOUNDRY_message_parts\"\n"; // plaintext section begins $message = "--=MIME_BOUNDRY_message_parts\n"; $message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n"; $message .= "Content-Transfer-Encoding: quoted-printable\n"; $message .= "\n"; // your text goes here $message .= "$text\n"; $message .= "\n"; // this ends the message part $message .= "--=MIME_BOUNDRY_message_parts--\n"; $message .= "\n"; // now we add attachments (images, etc) foreach($filename as $key => $file) { $message .= "--=MIME_BOUNDRY_main_message\n"; $message .= "Content-Type: application/octet-stream; name=\"$file\"\n"; $message .= "Content-disposition: attachment\n"; $message .= "Content-Transfer-Encoding: base64\n"; $message .= "\n"; $message .= "$attachment[$key]\n"; $message .= "\n"; } // message ends $message .= "--=MIME_BOUNDRY_main_message--\n"; // send the message $stat = mail("$to_name<$to_email>", $subject, $message, $headers); return $stat; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP_SELF syntax
Works great for me. The error may be from a previous line. What is the error? -Shawn "Peter Gumbrell" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Could someone tell me why this code prompts a parse error. I have tried it > several different way. The statement is called from within a function: > > print " action=\"$_SERVER['PHP_SELF']\">\n"; > > Many thanks > > Peter > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] regex question?
I'm using the following to try and replace urls in my html output: $newhrefs = preg_replace("/script.php\?(.*)=(.*)&(.*)=(.*)&(.*)=(.*)/", "script-$1-$2-$3-$4-$5-$6.html", $hrefs); This works fine as long as there are exactly 3 var=val pairs... not 1 or 2 or 4 or more... How can I write my expression to match 1 or more pairs??? For example: script.php?var=val script.php?var=val&var2=val2 script.php?var=val&var2=val2&var3=val3 etc...etc...etc... TIA, Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: regex question?
Anyone? please? Thanks! Shawn "Shawn McKenzie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm using the following to try and replace urls in my html output: > > $newhrefs = preg_replace("/script.php\?(.*)=(.*)&(.*)=(.*)&(.*)=(.*)/", > "script-$1-$2-$3-$4-$5-$6.html", $hrefs); > > This works fine as long as there are exactly 3 var=val pairs... not 1 or 2 > or 4 or more... > > How can I write my expression to match 1 or more pairs??? For example: > > script.php?var=val > script.php?var=val&var2=val2 > script.php?var=val&var2=val2&var3=val3 > etc...etc...etc... > > TIA, > Shawn > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] derive function that called a function?
Is there any way to determine what function (if any) called a particular function??? Example: function myFuncA() { myFuncB(); } function myFuncB() { some stufff; } In myFuncB() can I find out that I was called by myFuncA()??? FYI... I am trying to write some code that integrates with other peoples' code and don't want to modify their functions (e.g. what args they call my function with). But in certain cases I need to take certain actions if my function was called by a particular function. TIA Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: MIME help needed please...
Is this a stupid question, or does no one know what is wrong??? Thanks! Shawn "Shawn McKenzie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I got this from the user contributed notes in the php.net manual. It seems > to work fine most of the time, but Eudora and Pegasus users either get > mangled attachments or no attachments. > > Can anyone see a problem (most files are zip, but sometimes tar.gz or sit) I > tried using Content-Type: application/zip with the same results. I'm > thinking it is some issue with the headers, content-types, boundaries or > something. Or maybe Pegasus/Eudora don't understand MIME or base64 > (doubtful)??? > > Help appreciated. Thanks! > > function send_mail($from_name, $from_email, $to_name, $to_email, $subject, > $text, $path, $filename) > { > // encode file attachments > foreach($filename as $key => $file) { >$fp = fopen($path[$key].$file, "r"); >$content = fread($fp, filesize($path[$key].$file)); >$attachment[$key] = chunk_split(base64_encode($content)); > } > // headers need to be in the correct order... > $headers = "From: $from_name<$from_email>\n"; > $headers .= "Reply-To: <$from_email>\n"; > $headers .= "MIME-Version: 1.0\n"; > > // the following must be one line (post width too small) > $headers .= "Content-Type: multipart/related; > type=\"multipart/alternative\"; > boundary=\"=MIME_BOUNDRY_main_message\"\n"; > $headers .= "X-Sender: $from_name<$from_email>\n"; > $headers .= "X-Mailer: PHP4\n"; //mailer > $headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal > $headers .= "Return-Path: <$from_email>\n"; > $headers .= "This is a multi-part message in MIME format.\n"; > $headers .= "--=MIME_BOUNDRY_main_message \n"; > $headers .= "Content-Type: multipart/alternative; > boundary=\"=MIME_BOUNDRY_message_parts\"\n"; > > // plaintext section begins > $message = "--=MIME_BOUNDRY_message_parts\n"; > $message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n"; > $message .= "Content-Transfer-Encoding: quoted-printable\n"; > $message .= "\n"; > > // your text goes here > $message .= "$text\n"; > $message .= "\n"; > > // this ends the message part > $message .= "--=MIME_BOUNDRY_message_parts--\n"; > $message .= "\n"; > > // now we add attachments (images, etc) > foreach($filename as $key => $file) { >$message .= "--=MIME_BOUNDRY_main_message\n"; >$message .= "Content-Type: application/octet-stream; > name=\"$file\"\n"; >$message .= "Content-disposition: attachment\n"; >$message .= "Content-Transfer-Encoding: base64\n"; >$message .= "\n"; >$message .= "$attachment[$key]\n"; >$message .= "\n"; > } > // message ends > $message .= "--=MIME_BOUNDRY_main_message--\n"; > > // send the message > $stat = mail("$to_name<$to_email>", $subject, $message, $headers); > return $stat; > } > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Easier queries?
Here's what I'm thinking, just looking to see if anyone has done this or similar. - I have a MySQL DB and I create an ODBC datasource for it on my windows box - I then open MS Access and link the tables from my datasource - Access provides a graphical relationship builder, so I build relations in this - Access also provides a graphical query builder that uses the stored relationships - So I build a query, view the SQL and use the SQL code in some mysql_ PHP functions - Maybe next I instead save the queries in a query table so I can get them via simple name, like 'All_Customers' Sort of analogous to MS SQL Views? Sound good, or is there a better way? TIA -Shawn P.S. I've also seen mention of some graphical query builders. Can anyone recommend a good FREE one? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Eval var from query
How can I evaluate a var that is from a text field of a database? Example: MySQL field `name` = hi my name is $name In my script I have: $name = "Shawn"; After fetching a query result as an associative array I have the contents of the `name` field in $data If I echo $data I get: hi my name is $name I would like to get: hi my name is Shawn TIA, Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Eval var from query
eval($data) returns Parse error: parse error, unexpected T_STRING in C:\apps\apache2\htdocs\test\query.php(23) : eval()'d code on line 1 Thanks! Shawn "Shawn McKenzie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > How can I evaluate a var that is from a text field of a database? Example: > > MySQL field `name` = hi my name is $name > > In my script I have: > > $name = "Shawn"; > > After fetching a query result as an associative array I have the contents of > the `name` field in $data > > If I echo $data I get: hi my name is $name > > I would like to get: hi my name is Shawn > > TIA, > Shawn > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Eval var from query
Thanks Kevin! That works great. It outputs: hi my name is Shawn Now if I want to assign $data to another var, let's say $newdata and have it eval the $name var inside of that. How would that work? Meaning I want to $newdata = hi my name is Shawn Thanks! Shawn "Kevin Stone" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > The string you send to eval() must be valid PHP code. So try this.. > > eval( 'echo "'.$data.'";'); > > - Kevin > > > - Original Message - > From: "Shawn McKenzie" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Monday, July 14, 2003 1:15 PM > Subject: [PHP] Re: Eval var from query > > > > eval($data) > > > > returns Parse error: parse error, unexpected T_STRING in > > C:\apps\apache2\htdocs\test\query.php(23) : eval()'d code on line 1 > > > > Thanks! > > Shawn > > > > "Shawn McKenzie" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > How can I evaluate a var that is from a text field of a database? > > Example: > > > > > > MySQL field `name` = hi my name is $name > > > > > > In my script I have: > > > > > > $name = "Shawn"; > > > > > > After fetching a query result as an associative array I have the > contents > > of > > > the `name` field in $data > > > > > > If I echo $data I get: hi my name is $name > > > > > > I would like to get: hi my name is Shawn > > > > > > TIA, > > > Shawn > > > > > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Eval var from query
Got it! eval( '$newdata = "'.$data.'";'); Thanks! Shawn "Shawn McKenzie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Thanks Kevin! That works great. It outputs: hi my name is Shawn > > Now if I want to assign $data to another var, let's say $newdata and have it > eval the $name var inside of that. How would that work? > > Meaning I want to $newdata = hi my name is Shawn > > Thanks! > Shawn > > "Kevin Stone" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > The string you send to eval() must be valid PHP code. So try this.. > > > > eval( 'echo "'.$data.'";'); > > > > - Kevin > > > > > > - Original Message - > > From: "Shawn McKenzie" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Monday, July 14, 2003 1:15 PM > > Subject: [PHP] Re: Eval var from query > > > > > > > eval($data) > > > > > > returns Parse error: parse error, unexpected T_STRING in > > > C:\apps\apache2\htdocs\test\query.php(23) : eval()'d code on line 1 > > > > > > Thanks! > > > Shawn > > > > > > "Shawn McKenzie" <[EMAIL PROTECTED]> wrote in message > > > news:[EMAIL PROTECTED] > > > > How can I evaluate a var that is from a text field of a database? > > > Example: > > > > > > > > MySQL field `name` = hi my name is $name > > > > > > > > In my script I have: > > > > > > > > $name = "Shawn"; > > > > > > > > After fetching a query result as an associative array I have the > > contents > > > of > > > > the `name` field in $data > > > > > > > > If I echo $data I get: hi my name is $name > > > > > > > > I would like to get: hi my name is Shawn > > > > > > > > TIA, > > > > Shawn > > > > > > > > > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] filemtime() on Windows
I am trying to get the last modified time of an HTML file on my windows machine. The file is in a sub dir of my script dir and I can use the same path for file_get_contents() and fopen() and the path works great. $filetime = date("mdyhis", filemtime("subdir/file.html")); Always returns: 12316906 (December 31, 1969) Any ideas? TIA -Shawn Windows XP PHP 4.3.1 Apache 2.0.45 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: filemtime() on Windows
Nevermind. I had a typo in the path. Sorry... -Shawn "Shawn McKenzie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I am trying to get the last modified time of an HTML file on my windows > machine. The file is in a sub dir of my script dir and I can use the same > path for file_get_contents() and fopen() and the path works great. > > $filetime = date("mdyhis", filemtime("subdir/file.html")); > > Always returns: 12316906 (December 31, 1969) > > Any ideas? TIA > -Shawn > > Windows XP > PHP 4.3.1 > Apache 2.0.45 > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] replacing & but not special chars
I have some URLs in hrefs that have an &. This does not validate HTM4.01 transitional, so I want to replace them with & So I buffer the output and do a replace, but suppose there is already an & then I get & or if I have anything else like " then I get " Any ideas on how to do this the right way??? Thanks! Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Allowed mem size exhausted
I have the following code that generates the following error. I am using this code to prepare a zip or tar.gz file as an email attachment. Can someone suggest a better / more efficient way to do this and maybe avoid the error??? I believe that the file that generated this error was about 1.8MB. 6 $fp = fopen($path.$filename, "r"); 7 $content = fread($fp, filesize($path.$filename)); 8 $attachment = base64_encode($content); 9 $attachment = chunk_split($attachment); Fatal error: Allowed memory size of 8388608 bytes exhausted at (null):0 (tried to allocate 2228273 bytes) in /home/user/public_html/dir/subdir/include/functions.php on line 9 Many thanks! Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: global scope issue
OK, so what's the use of having the autoglobal $GLOBALS??? This is contrary to the docs. -Shawn "Ivo Fokkema" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "Shawn McKenzie" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > I'm having problems using global vars. I have read the docs and all of > the > > notes but it's not helping. Simplified example: > > > > /dir1/script2.php > > > $test = array ( 'a' => '1', 'b' => '2'); > > ?> > > > > /dir1/script1.php > > > include("/dir1/script2.php"); > > print_r($test); //works great > > print_r($GLOBALS['test']); //does not work > > ?> > > > > This is a local include so the vars should be in the global scope right? > > Any help please? > As far as I know, no defined variable is global by default. If you would > really need this variable to be global, you'll need to do a > > global $test; > > to make $test global. > > HTH, > > Ivo > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Best PHP CMS
I prefer and use PostNuke. Great community, stable platform, many modules/themes, sensible API for development and AutoTheme HTML theme system for templating, with another system on the way. HTH -Shawn "Anthony" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm just looking for some opinions. I've been going though sourceforge > looking at different CMS systems. There are a lot of really good CMS > projects out there. I'm looking for some opinions on the best ones out > there. I'm obviously looking at something PHP based and using mySQL > backend. Some of the features that I'd like are an easy template > implementation, blog features, media gallery and something that's easy to > build custom modules to add features. So far I'm looking at about 6 CMS > systems, I like certain things in each of them. so what's your opinion. > > - Anthony > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Using Constants
I'm considering using constants for some predefined paths in my script, like HTML_DIR, INC_DIR. These values won't change and they will be global to all functions. Are there any drawbacks to using constants over reg vars for this sort of thing??? TIA, Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: global scope issue
Sorry... nevermind. I was developing as part of a team and it seems that my script is included in a function written by someone else. So my vars from my included files are local to the other function and not global. Thanks! Shawn "Shawn McKenzie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > does it matter if a global command has bee issued before with vars other > than the $test var? i.e before the include if there is a global $somevar; > > -Shawn > > "Curt Zirzow" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > * Thus wrote Ford, Mike [LSS] ([EMAIL PROTECTED]): > > > > -Original Message- > > > > From: Ivo Fokkema [mailto:[EMAIL PROTECTED] > > > > Sent: 13 August 2003 15:45 > > > > > > > > "Shawn McKenzie" <[EMAIL PROTECTED]> wrote in message > > > > news:[EMAIL PROTECTED] > > > > > > > > As far as I know, no defined variable is global by default. > > > > If you would > > > > really need this variable to be global, you'll need to do a > > > > > > > > global $test; > > > > > > > > to make $test global. > > > > > > Absolute rubbish!! ALL variables used in the global scope are > automatically > > > global and available in the superglobal array $GLOBALS. You're > confusing > > > this with the issue that global variables are not automatically > accessible > > > within functions but must be "imported" with the global statement. (And > a > > > global statement in the gloabl scope has absolutely no effect > whatsoever.) > > > > I also believe php gives a warning/error about globaling a global > > var in global scope. > > > > Curt > > -- > > "I used to think I was indecisive, but now I'm not so sure." > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] where did my errors go?
error_reporting and/or display_errors in php.ini? "David T-G" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] global scope issue
I'm having problems using global vars. I have read the docs and all of the notes but it's not helping. Simplified example: /dir1/script2.php '1', 'b' => '2'); ?> /dir1/script1.php This is a local include so the vars should be in the global scope right? Any help please? TIA -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: global scope issue
does it matter if a global command has bee issued before with vars other than the $test var? i.e before the include if there is a global $somevar; -Shawn "Curt Zirzow" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > * Thus wrote Ford, Mike [LSS] ([EMAIL PROTECTED]): > > > -Original Message- > > > From: Ivo Fokkema [mailto:[EMAIL PROTECTED] > > > Sent: 13 August 2003 15:45 > > > > > > "Shawn McKenzie" <[EMAIL PROTECTED]> wrote in message > > > news:[EMAIL PROTECTED] > > > > > > As far as I know, no defined variable is global by default. > > > If you would > > > really need this variable to be global, you'll need to do a > > > > > > global $test; > > > > > > to make $test global. > > > > Absolute rubbish!! ALL variables used in the global scope are automatically > > global and available in the superglobal array $GLOBALS. You're confusing > > this with the issue that global variables are not automatically accessible > > within functions but must be "imported" with the global statement. (And a > > global statement in the gloabl scope has absolutely no effect whatsoever.) > > I also believe php gives a warning/error about globaling a global > var in global scope. > > Curt > -- > "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Allowed mem size exhausted
Thanks! Would anyone care to expand on the "tools" or the methods for preparing on disk??? Thanks again! -Shawn "Curt Zirzow" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > * Thus wrote David Nicholson ([EMAIL PROTECTED]): > > Hello, > > > > This is a reply to an e-mail that you wrote on Tue, 5 Aug 2003 at > > 17:57, lines prefixed by '>' were originally written by you. > > > I would prepare the file on disk instead of memory. If you do > > > increase the memory to handle bigger files, what happens when you > > > get 10 requests at the same time? about 80MB of memory used. > > > > Correct me if I am wrong but would it not be better to use the > > functions he is currently using (which prepare the data in volitile > > memory) for as long as they allow for this. The OS should then > > realise when it does not have enough physical RAM for each of the > > requests and handle swapping onto disk itself as and when it is > > needed. This would mean you haven't got the overheads of writing > > lots of data to disk, just to delete it again when you do only have > > one request at a time and have plenty of RAM spare to take care of > > the operation. > > Better all depends on the situation. > > Now if one script forces your whole system to start using swap, I > think there is something wrong. The system should never swap unless > under heavy load. And even then, things should be changed so that > the system does not swap EVER. > > Having one script be inefficient is better than having the whole > system brought down to its knees (and perhaps die due to lack of > swap.) > > if only one person will be accessing the script at one time there > isn't any issues, but I would always be weary of loading 8MB of > data into one script, excpecially when there are tools readily > available. > > Curt > -- > "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Looking for library of functions
Can anyone please point me to a set of good functions to search and manipulate HTML? Mainly I'm looking to buffer HTML that is output by another script and fix some issues with it. Such as missing " around property values and many other things. Function examples: Find tags in HTML, replace tags, modify tags, find properties in tags, return entire HTML elements such as tables even if there are nested tables; meaning if I have: It should be able to return the entire table containing the other table. Sorry if I'm not explaining this well. Thanks! Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Determine memory used from script
Is there a way to determine the amount of memory that a script is consuming at a certain point? Maybe a function that would return this? The reason is, I get this: Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 46080 bytes) in /home/httpd/vhosts/aaa/httpdocs/bbb/ccc/script.php on line 20 I know why I get the error but would like to know when and why my script is consuming so much. Thanks! Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: New word proposition (was: Re: [PHP] HTML and PHP)
HAH! I love it! -Shawn "Evan Nemerson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Clode? I like it. Really, who wants to say "closing php tag", "terminating php > tag", or whatever you say. Why not start calling it a clode? What does > everyone else think? > > The only issue is if a "closing php tag" (or should it be a more general > "closing tag", with php being able to serve as a modifier when required, ie > "php clode") is a clode, would an "opening [php] tag" be an ode? > > Comments? > > > > > On Wednesday 04 June 2003 12:47 pm, Christian Ista wrote: > > Hello, > > > > Look the code below. Is it an obligation to multiply the number of > ?>. There is no other way ? not possible to use only an open php tag > > () ? > > > > Christian, > > > > > > >switch($constant_lastupdate[$i][3]){ > >case '1' :?> > > > border="0"> > > > break; > >case '2' :?> > > > border="0"> > break; > >case '3' :?> > > > border="0"> > > > break; > >} > > ?> > > -- > "Two hands working can do more than a thousand clasped in prayer." > > -Unknown > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ob_get_contents returns FALSE?
I can't get ob_get_contents() to return false, or I don't know how to test for it. Help appreciated. The following never echos STARTING!!! ob_end_flush(); if(ob_get_contents() === FALSE) { echo "STARTING!!!"; ob_start(); } also tried: if(ob_get_contents() == FALSE) and: if(!ob_get_contents()) and: if(ob_get_contents() == "") But I do get the following notice at the ob_end_flush(); line which tells me that output buffering is not on: Notice: ob_end_flush() [ref.outcontrol]: failed to delete buffer default output handler. Thanks! Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: ob_get_contents returns FALSE?
Any advice? Thanks! Shawn "Shawn McKenzie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I can't get ob_get_contents() to return false, or I don't know how to test > for it. Help appreciated. The following never echos STARTING!!! > > ob_end_flush(); > if(ob_get_contents() === FALSE) { > echo "STARTING!!!"; > ob_start(); > } > > also tried: if(ob_get_contents() == FALSE) > and: if(!ob_get_contents()) > and: if(ob_get_contents() == "") > > But I do get the following notice at the ob_end_flush(); line which tells me > that output buffering is not on: > > Notice: ob_end_flush() [ref.outcontrol]: failed to delete buffer default > output handler. > > Thanks! > Shawn > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How to determine if output buffering is on?
O.K. so how can I determine if output buffering has been started??? Thanks! Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ftp_ssl_connect() Problem
I too am having problems getting ftp_ssl_connect() enabled, any help is very appreciated. What I am using is as follows, please let me know what it is I am missing.. PHP 4.3.0 installed as a Static Module with Apache 1.3.24 This is a re-configuration of an existing installation of PHP 4.3.0 I have never had problems reconfiguring PHP as I needed the other options I use. My configure command was ./configure \ --enable-sockets \ --enable-ftp \ --with-mysql=/usr/local/mysql \ --with-apache=../apache_1.3.24 \ --with-png-dir=/root/backup/image/libpng-1.2.5 \ --with-jpeg-dir=/root/backup/image/jpeg-6b \ --with-gd=/usr/local/gd \ --with-zlib-dir=/usr/local \ --with-openssl=/usr/local/ssl My infophp() says.. OpenSSL support enabled OpenSSL Version OpenSSL 0.9.6b [engine] 9 Jul 2001 However the general info says : Build Date Feb 25 2003 11:00:45 (this was about the last time I made a successful change, obviously not today) Configure Command './configure' '--with-mysql=/usr/local/mysql' '--with-apache=../apache_1.3.24' '--with-png-dir=/root/backup/image/libpng-1.2.5' '--with-jpeg-dir=/root/backup/image/jpeg-6b' '--with-gd=/usr/local/gd' '--with-zlib-dir=/usr/local' '--enable-sockets' '--enable-ftp' (this command reflects my last successful change and lacks the '--with-openssl=/usr/local/ssl' I would have expected) Thanks for any help that can be provided. >From my understanding PHP 4.3.0 and OpenSSL 0.9.6 should work. Thanks again. -Shawn Shawn McKnight Circumerro Inc. 307-733-8319 x222 [EMAIL PROTECTED] "We are the music makers, we are the dreamers of the dream." - Willy Wonka -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: ANY POSTNUKER? Security problem!
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 It is also a simple drop-down box setting in the admin / settings. - -Shawn "Nabil" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > i have problem with session in postnuke. > > the problem is that while i m logged in as a user, if i closed the > browser, then i logged into it again , i still logged in, and that > make a security hale, as any one can use my account on my pc... > (ofcourse i don't want to log out) > > Any solution to make my login depending on a PHP session? so if the > user closed the browser , then back in , he has to put his usernme > and password. > > Best Rergards > -BEGIN PGP SIGNATURE- Version: PGP 8.0.2 iQA/AwUBPtTxkbiya2JGK6NREQKzyQCeOoxmfH6pNJrnhLt2dNg4lxXfLlEAoJJd VVx84SqQI119yQDinvkgD0V7 =ildx -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to determine if output buffering is on?
Thanks Leif. I hoping to get something for vers of PHP < 4.2. From my earlier post: The following never echos STARTING!!! ob_end_flush(); if(ob_get_contents() == FALSE) { echo "STARTING!!!"; ob_start(); } also tried: if(ob_get_contents() === FALSE) and: if(!ob_get_contents()) and: if(ob_get_contents() == "") But I do get the following notice at the ob_end_flush(); line which tells me that output buffering is not on: Notice: ob_end_flush() [ref.outcontrol]: failed to delete buffer default output handler. Thanks! Shawn "Leif K-Brooks" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Yay, a hack! The correct answer is ob_get_level(). > > Jim Lucas wrote: > > >output some html and then try and do an header() redirect. > > > >if it works, then some sort of buffering is turned on. > > > >if it fails and tells you that output has already been sent to the browser, > >then it isn't turned on. > > > >Jim Lucas > >- Original Message - > >From: "Shawn McKenzie" <[EMAIL PROTECTED]> > >To: <[EMAIL PROTECTED]> > >Sent: Saturday, June 07, 2003 7:39 AM > >Subject: [PHP] How to determine if output buffering is on? > > > > > > > > > >>O.K. so how can I determine if output buffering has been started??? > >> > >>Thanks! > >>Shawn > >> > >> > >> > >>-- > >>PHP General Mailing List (http://www.php.net/) > >>To unsubscribe, visit: http://www.php.net/unsub.php > >> > >> > >> > >> > > > > > > > > > > -- > The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to use objects, variables in an eval() func ?
Maybe: global $yourobject; -Shawn "Lpa" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi, I have an eval which evaluate a block of code before echo the result on the screen.. Here is the func : function t_eval($texte) { ob_start(); eval("?>".$texte); $retval = ob_get_contents(); ob_end_clean(); return $retval; } But I use some objects for databases, ... and when i trying to execute this code i have this text. Fatal error: Call to a member function on a non-object in k:\program files\easyphp\www\dhea\include\php\functions_conversion.inc.php(23) : eval()'d code on line 9 What to do ? Thanx Laurent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: shorthand "if" notation
Ternary operator. Look in the comparison operators section: http://us2.php.net/manual/en/language.operators.comparison.php -Shawn "Adrian Greeman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > I am confused by the shorthand "if" notation. > For example I just saw this PHP snippet on another forum > > $bkgndClass = $bkgndClass == "darkBkgnd" ? "liteBkgnd" : > "darkBkgnd"; > } > ?> > > I think it is an if but cannot find it in the manual. How > is that written in the more normal notation - if(){} etc?? > > [And please excuse a slightly off-thread but related extension to > the question but I have seen similar in Javascript - namely --- > var evt = (evt ? evt : ((window.event) ? window.event : null); > is this the same notation or something else?] > > RegardsAdrian Greeman > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Eval or $$ are they the same or is $$ safer
Can you expand on this? I haven't found a ref to the $$ except for variable variables. $$ What does it do? How is it used? Thanks! Shawn "Leif K-Brooks" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Use $$ unless you need to use eval. Easier to read, faster to process. > Also safer if you don't validate form data. > > Jason Lehman wrote: > > >Is $$ the same as eval or is it different and my main question is, is it > >safer to use to for processing form data? > > > > > > > > > > > > -- > The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] failed to delete buffer default output handler
echo ob_get_level(); returns 1 but the next line: ob_end_clean(); returns Notice: ob_end_clean() [ref.outcontrol]: failed to delete buffer default output handler. Any ideas? Thanks! Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help with output from system() or backticks
Have you tried it like this? $output = `$executable $param`; $output = explode("\n",$output); print_r($output); It works for me! I get the same weird response as you when I try to create the array directly off of the system call. Good Luck, Shawn Sellars -Original Message- Essentially: $output = array (system("$executable $param")); print_r($output); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Extract HTML tags
I've loaded an html file into a string. What I'd like to do is create two new strings: first new string with the original string but remove all content from the beginning of the file up to and including , and then remove from the end of file up to and including second new string only containing content after up to and including Any ideas on simple ways to do this? TIA -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Odd request
Probably a question for the php dev team, but here it goes. I want to display an external page in an iframe and have the iframe auto sized to fit the content without having scroll bars. I've tried javascript to no avail. So here's my idea: 1. Instead of iframe: $string = file_get_contents("http://somwhere.com";); to load page into string and then echo $string; use javascript to detect onclick, get href of anchor, load page into string and echo again. Works O.K. unless there are relative paths in document. 2. What I want to do: $string = file_get_contents("http://somwhere.com";); and determine the height that this page ($string) would render in a browser. Render iframe at determined height with src = "http://somwhere.com";. Any way in php to determine at what height html content will render??? If not, should there be? TIA -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to navigate backwards in PHP ???
$HTTP_SERVER_VARS["HTTP_REFERER"]; - or - PHP 4.1.0 and later $_SERVER["HTTP_REFERER"]; Not as reliable as passing it yourself though. HTH -Shawn "-<>-" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > This is really puzzling me ... I've tried finding the answer in the manual > ... but sofar without luck... > > What I need to is simply to be able to make a go-back link that points to > the URL that contains the page that had the link that send the user to the > current page ... (did that make sense?) > > Or to put it another way: I need to be able to have a link on page A, > point to page B, and then have page B know the exact URL of page A > (including all variables that's needed to build page A). > > The thing is that simply using > doesn't work because the internal links adds the hash-mark (#) after the > URL, and then the browser needs to go one more step backwards for each > time the user clicks on an internal link ... > > I could easily write a JS function to handle all of this, but my goal is > to not use any JS at all, and really, this is something that ought to be > easily doable in PHP ... only I can't figure out how ... does it have > something like Document Referrer ??? which could contain the URL of the > sender, which I'd then be able to plump into a variable, which could then > be used when generating the links to go back to the sender page... > > TIA > > Rene > -- > Rene Brehmer > System developer in the making... > > This message was written on 100% recycled spam. > > My website: http://www.geocities.com/cerberus_hotdog > Babes and computer & internet references... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: $html_code .= include ("filetoinclude.txt");
function file_get_contents($filename) { $fp = @fopen($filename, "r"); if (!($fp)) { return 0; } while (!feof($fp)) { $temp .= fread($fp, 4096); } return $temp; } and then: $html_code = file_get_contents(filetoinclude.txt); HTH -Shawn "Research And Development" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Should this work? > > $html_code .= include ("filetoinclude.txt"); > > I am populating a variable with html to be printred later as usual: > $html_code .= "html". > > But I have some static html files that I want included in the html that > I am storing in the variable. The HTML is in text files. The above code > obviously does not work. I want to know if there is another way. > > Thanks. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] newline in string
I have loaded an html file into a string. How can I search the string for newlines/linefeeds? I know they are there, because if I echo the string and view source in the browser, some tags are on new lines. Example: TIA -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newline in string
Thanks everyone. I'' be breaking the string after the newline so that I can convert the html to php echos and write them to a file. -Shawn "John W. Holmes" <[EMAIL PROTECTED]> wrote in message 000d01c272c1$54d0$7c02a8c0@coconut">news:000d01c272c1$54d0$7c02a8c0@coconut... > > I have loaded an html file into a string. How can I search the string > for > > newlines/linefeeds? I know they are there, because if I echo the > string > > and > > view source in the browser, some tags are on new lines. > > > > Example: > > > > > > > > > > And do what when you find them? If you just want to know if there are > newlines in the file, then use strstr(). If you want to remove or > replace them, then use str_replace(). If you want to add in a where > some newlines are, then use nl2br(). > > ---John Holmes... > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replace illegal filename chars???
Doesn't work. It returned the same as what I put in: What's Up Doc? -Shawn "Maxim Maletsky" <[EMAIL PROTECTED]> wrote in message news:20021024122630.4E99.MAXIM@;php.net... > > Use a regular expression like: > > $str = ereg_replce("/[^[:alnum:]]/i", '', $str); > > > -- > Maxim Maletsky > [EMAIL PROTECTED] > > > www.PHPBeginner.com // PHP for Beginners > www.maxim.cx // my Home > > // my Wish List: ( Get me something! ) > http://www.amazon.com/exec/obidos/registry/2IXE7SMI5EDI3 > > > > Marek Kilimajer <[EMAIL PROTECTED]> wrote... : > > > I use strtr() for this > > > > Shawn McKenzie wrote: > > > > >Anyone have a good way to remove from a string all characters and spaces > > >that are illegal in a filename??? > > > > > >$string = "What's up Doc?"; > > > > > >I need: > > > > > >$filename = "whatsupdoc"; > > > > > >TIA > > >-Shawn > > > > > > > > > > > > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replace illegal filename chars???
Thanks, the ereg_replace example didn't work for me (even after fixing the typo). A-Za-z0-9 is fine for my needs, replacing them with "". What is your preg_replace allowing? Thanks! Shawn "Peter Mr. Eps Thoenen" <[EMAIL PROTECTED]> wrote in message news:A733FF9B1FB0F441B3A6209FF71030E50169B287@;bondsteel2.areur.army.mil... > close but preg_replace("/[^[:print:]]/",'',$str); is what you want. > > The below would work but typo'ed ... ereg_replce should be ereg_replace > > Also..that is just A-Za-z0-9 ... many OS's allow punctation also...[:print:] > will cover this. > > Now only if php supported [:control:] and [:graph:] :) > > -Peter > > > -Original Message- > > From: Shawn McKenzie [mailto:nospam@;mckenzies.net] > > Sent: Friday, October 25, 2002 04:48 > > To: [EMAIL PROTECTED] > > Subject: Re: [PHP] Replace illegal filename chars??? > > > > > > Doesn't work. It returned the same as what I put in: What's Up Doc? > > > > -Shawn > > > > "Maxim Maletsky" <[EMAIL PROTECTED]> wrote in message > > news:20021024122630.4E99.MAXIM@;php.net... > > > > > > Use a regular expression like: > > > > > > $str = ereg_replce("/[^[:alnum:]]/i", '', $str); > > > > > > > > > -- > > > Maxim Maletsky > > > [EMAIL PROTECTED] > > > > > > > > > www.PHPBeginner.com // PHP for Beginners > > > www.maxim.cx // my Home > > > > > > // my Wish List: ( Get me something! ) > > > http://www.amazon.com/exec/obidos/registry/2IXE7SMI5EDI3 > > > > > > > > > > > > Marek Kilimajer <[EMAIL PROTECTED]> wrote... : > > > > > > > I use strtr() for this > > > > > > > > Shawn McKenzie wrote: > > > > > > > > >Anyone have a good way to remove from a string all characters and > > spaces > > > > >that are illegal in a filename??? > > > > > > > > > >$string = "What's up Doc?"; > > > > > > > > > >I need: > > > > > > > > > >$filename = "whatsupdoc"; > > > > > > > > > >TIA > > > > >-Shawn > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > PHP General Mailing List (http://www.php.net/) > > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ereg_replace???
I need to replace all NON alpha-numeric characters in a string. Example: input: "-What's Up Doc?" output: "WhatsUpDoc" I received this in a previous post, but it doesn't work: $str = ereg_replace("/[^[:alnum:]]/i", '', $str); Thanks! Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Free compiler for Win
There is a GNU gcc compiler for windows. -Shawn "Marcello Lupo" <[EMAIL PROTECTED]> wrote in message news:0210281543120J.00435@;hunters... > Hi to all, > anyone know a good free complier for win 2000/NT to compile PHP and so on? > thanks, > Bye > MArselo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg_replace???
Thanks! Why does preg_replace("^\W^","",$str); not remove undescores _ ? Are they alpha-numeric? I had to do this preg_replace("^\W|_^","",$str); TIA, Shawn "John W. Holmes" <[EMAIL PROTECTED]> wrote in message news:000201c27eab$f4ea0500$7c02a8c0@;coconut... > > I need to replace all NON alpha-numeric characters in a string. > > > > Example: > >input: "-What's Up Doc?" > >output: "WhatsUpDoc" > > > > I received this in a previous post, but it doesn't work: > >$str = ereg_replace("/[^[:alnum:]]/i", '', $str); > > Use preg_replace() with that string, not ereg_replace(). > > ---John Holmes... > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] preg_replace (underscore)
Why does preg_replace("^\W^","",$str); not remove undescores _ ? Are they alpha-numeric? I had to do this preg_replace("^\W|_^","",$str); TIA, Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fw: [PHP] preg_replace (underscore)
Thanks, but I'm trying to replace ALL non alpha-numeric characters, which I'm doing with the preg_replace, however it leaves the _. Seems silly to use preg_replace and then use str_replace. Thanks! Shawn "John Meyer" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > i've just used str_replace for underscores and it's worked > wonderfully. > > -Original Message- > From: Shawn McKenzie [mailto:nospam@;mckenzies.net] > Sent: Monday, October 28, 2002 4:46 PM > To: [EMAIL PROTECTED] > Subject: [PHP] preg_replace (underscore) > > > Why does preg_replace("^\W^","",$str); not remove undescores _ ? Are > they alpha-numeric? > > I had to do this preg_replace("^\W|_^","",$str); > > TIA, > Shawn > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP code in form field - var_export() (slashes)?
O.K. I am collecting PHP code in a textarea and then using var_export() to a file for later use. In the file, the PHP is in single-quotes. I am having issues trying to make sure that things are escaped correctly. If PHP code is submitted with no single-quotes and no escaping, then all is well. If magic_quotes_gpc = 1 then i just use stripslashes(). If PHP code is submitted and the code has slashes in it already ( example: echo "http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP code in form field - var_export() (slashes)?
I'm storing some multi-dimensional associative arrays in the file and then when I need the values somewhere I just include the file and voila my arrays are defined. Seemed better than looping through arrays writing to a file and then using the same loop structure to read lines from the file and assign back to the same array that I had it in in the first place. Thanks! -Shawn "Jason Wong" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Wednesday 24 September 2003 12:00, Shawn McKenzie wrote: > > > O.K. I am collecting PHP code in a textarea and then using var_export() to > > a file for later use. In the file, the PHP is in single-quotes. > > I'm curious, why are you using var_export() if it's causing so many problems? > Acutally why are you using var_export() at all, am I missing something? > > Couldn't you just write the string containing the contents of the textarea > straight out to a file? > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.biz > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > -- > Search the list archives before you post > http://marc.theaimsgroup.com/?l=php-general > -- > /* > The only function of economic forecasting is to make astrology look > respectable. > -- John Kenneth Galbraith > */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help! the Error_Reporting doesn't work
What do you mean "it doesn't work"? It doesn't display errors? How do you know that you have errors? Are you running your own script or someone else's? -Shawn "Luckyeagle" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I have set the PHP.INI as follow: > > error_reporting = E_ALL & ~E_NOTICE > display_errors = On > display_startup_errors = Off > log_errors = On > log_errors_max_len = 1024 > ignore_repeated_errors = Off > ignore_repeated_source = Off > report_memleaks = On > track_errors = Off > > But it doesn't work > How can i solve it? > > Thanks a lot -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] magic_quotes_gpc and \
O.K. I'll try again from a different angle. magic_quotes_gpc = on. If I have a form that POSTS a textarea that contains PHP code. Say some code that contains legitimate escapes \ like: echo "http://somewhere.com\";>Click"; When the data is posted and received in the destination script, additional escapes \ are added. So how do I get to the original code above? strip_slashes will strip all slashes, even the original ones that are supposed to be there. Thanks! -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] displaying var in textarea
I have a var: $test = 'echo \'test\';'; If I display this in a textearea like so: echo "\n" .$test ."\n"; In the browser and in the HTML source I see (no slashes): echo 'test'; Even if I do an htmlentities($test); I see no slashes and the single-quotes are not shown in the HTML source as " Is this just a behavior of the textarea??? Thanks! -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Echo $PHP_SELF not working
Unless you do an extract($_POST); in a main include somewhere before your form. For $PHP_SELF just do $PHP_SELF = $_SERVER['PHP_SELF']; or to get all of the $_SERVER vars, do extract($_SERVER); -Shawn "Jeff McKeon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] So you're saying I had register_globals set to ON on my dev server!? CRAP!!! I thought I was working with it off! Now I have to redevelop it all and change all my $variables from forms to $_POST['variable']? Even when they post to the same page with "action=''"?? Jeff > -Original Message- > From: Paul van Schayck [mailto:[EMAIL PROTECTED] > Sent: Friday, October 10, 2003 8:24 AM > To: [EMAIL PROTECTED] > Subject: [PHP] Re: Echo $PHP_SELF not working > > > Hello, > Here we go again ;) > > [EMAIL PROTECTED] (Jeff McKeon) wrote > > I've just published a new website and something is wrong. > I suspect > > the PHP.ini on the server but I can't seem to find anything. > > register_globals is on off. Which is a good idea, keep it there! > > > > On the dev server "ECHO $PHP_SELF" seems to work but not on the > > production one. Any ideas what I've missed? > http://nl2.php.net/manual/en/reserved.variables.php#reserved.variables.s erv er echo $_SERVER['PHP_SELF']; Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: $PHP_SELF and include all variables?
$_SERVER['GET'] will give an array of all get vars in the URL. Or maybe: $_SERVER['QUERY_STRING'] Which gives the entire get query string in the URL. -Shawn "Tristan Pretty" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm using $PHP_SELF, but need to automatically record what variables are > in the URL at that time... > is that possible? > > I've searched PHP.net, but cannot find this specific function... > > Cheers, > Tris... > > * > The information contained in this e-mail message is intended only for > the personal and confidential use of the recipient(s) named above. > If the reader of this message is not the intended recipient or an agent > responsible for delivering it to the intended recipient, you are hereby > notified that you have received this document in error and that any > review, dissemination, distribution, or copying of this message is > strictly prohibited. If you have received this communication in error, > please notify us immediately by e-mail, and delete the original message. > *** > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Code optimization: single vs. double quotes?
I came across this post and was hoping to get a gurus opinion on the validity. TIA -Shawn I remember reading somewhere re: PHP coding that it is a better coding practice to use single quotes as much as possible vs. using double quotes in scripts. When using double quotes, you are forcing PHP to look for variables within them, even though there may not be any, thus slowing execution time... For example it is better to code: Code: echo ' '; vs. Code: echo " "; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Code optimization: single vs. double quotes?
Thanks guys! I want to hear all opinions, but hopefully a PHP dev will give us the straight poop. -Shawn "Shawn McKenzie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I came across this post and was hoping to get a gurus opinion on the > validity. TIA > > -Shawn > > I remember reading somewhere re: PHP coding that it is a better coding > practice to use single quotes as much as possible vs. using double quotes in > scripts. When using double quotes, you are forcing PHP to look for variables > within them, even though there may not be any, thus slowing execution > time... > > For example it is better to code: > Code: > echo ' '; > > vs. > Code: > echo " "; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] copying a directory
I need to copy a directory from one location to the other. I didn't find a function for this. Is copy() supposed to work on directories as well as files, or is there another? TIA -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] copying a directory
Thanks, but I was looking for a multi-platform way via a function. I just bit the bullet and looped thru with readdir() and copied the files. -Shawn "Burhan Khalid" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Shawn McKenzie wrote: > > > I need to copy a directory from one location to the other. I didn't find a > > function for this. Is copy() supposed to work on directories as well as > > files, or is there another? > > Unix : > > cp -r /old/dir /new/dir > > Windows : > > xcopy /E c:\old\dir c:\new\dir > > Use those with : > > http://www.php.net/manual/en/function.exec.php > > > > -- > Burhan Khalid > phplist[at]meidomus[dot]com > http://www.meidomus.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] HTTP1.1 problems maybe?
I have a script that I have written for the PHP-Nuke CMS that controls the theme. The site loads fine in any browser without my script. But with my script, the site will load fine in Mozilla 1.4 and in Lynx, but I get a blank page (no error) in IE6. If I go to IE settings and disable use HTTP 1.1, then all loads well in IE. Any ideas on things to look at or a method to troubleshoot??? Thanks! -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTTP1.1 problems maybe?
Yes, thanks Chris. Could it be gzip problems? I captured with HTTP Interceptor and here are the server response headers prior to the actual HTML: With NO HTTP 1.1 [From Req: GET http://mckenzies.net/nuke69/ HTTP/1.0] HTTP/1.1 200 OK Date: Wed, 12 Nov 2003 22:32:00 GMT Server: Apache/1.3.28 (Unix) PHP/4.3.3 X-Powered-By: PHP/4.3.3 Connection: close Content-Type: text/html actual html from page With HTTP 1.1 [From Req: GET http://mckenzies.net/nuke69/ HTTP/1.1] HTTP/1.1 200 OK Date: Wed, 12 Nov 2003 22:21:40 GMT Server: Apache/1.3.28 (Unix) PHP/4.3.3 X-Powered-By: PHP/4.3.3 Content-Encoding: gzip Vary: Accept-Encoding Connection: close Transfer-Encoding: chunked Content-Type: text/html 7d3 actual html from page Thanks! -Shawn "Chris Shiflett" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > --- Shawn McKenzie <[EMAIL PROTECTED]> wrote: > > I get a blank page (no error) in IE6. If I go to IE settings and > > disable use HTTP 1.1, then all loads well in IE. > > > > Any ideas on things to look at or a method to troubleshoot??? > > Can you capture the HTTP transaction with IE and with another browser for > comparison? Ethereal is a good tool for obtaining this data if you don't > already have a favorite method. > > Chris > > = > My Blog > http://shiflett.org/ > HTTP Developer's Handbook > http://httphandbook.org/ > RAMP Training Courses > http://www.nyphp.org/ramp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTTP1.1 problems maybe?
Sorry, here is zip with data from mozilla also. mozilla works with HTTP 1.1 enabled in preferences. -Shawn "Shawn McKenzie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I've never sent attachment to this group, hope it is ok. > > Any help is much appreciated as I am not well versed in HTTP and diffs > between 1.0 and 1.1. > > Thanks! > Shawn > > "Chris Shiflett" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > --- Shawn McKenzie <[EMAIL PROTECTED]> wrote: > > > Yes, thanks Chris. Could it be gzip problems? > > > > That's a possibility, but I've never heard reports of IE having trouble > > with gzip. > > > > > I captured with HTTP Interceptor and here are the server response > > > headers prior to the actual HTML: > > > > > > With NO HTTP 1.1 > > > [From Req: GET http://mckenzies.net/nuke69/ HTTP/1.0] > > > > Can you provide the full request also? That might reveal something > > important. > > > > > HTTP/1.1 200 OK > > > Date: Wed, 12 Nov 2003 22:32:00 GMT > > > Server: Apache/1.3.28 (Unix) PHP/4.3.3 > > > X-Powered-By: PHP/4.3.3 > > > Connection: close > > > Content-Type: text/html > > > > > > actual html from page > > > > There's no Content-Length header? That's very odd. I would think this > > would be the one that doesn't work. :-) > > > > > With HTTP 1.1 > > > [From Req: GET http://mckenzies.net/nuke69/ HTTP/1.1] > > > HTTP/1.1 200 OK > > > Date: Wed, 12 Nov 2003 22:21:40 GMT > > > Server: Apache/1.3.28 (Unix) PHP/4.3.3 > > > X-Powered-By: PHP/4.3.3 > > > Content-Encoding: gzip > > > Vary: Accept-Encoding > > > Connection: close > > > Transfer-Encoding: chunked > > > Content-Type: text/html > > > > > > 7d3 > > > > > > actual html from page > > > > Well, there are a finite number of differences in the responses. Chunked > > transfer encoding is a very big difference, but again, I've never heard of > > IE having trouble with that either. > > > > At any rate, one method of debugging would be to use the header() function > > to specify your own headers, incrmentally trying to make your response > > appear identical regardless of which version of HTTP is being used. > > > > Although it's not in the examples you provide, it would also be worth > > noting whether IE sends the Host header when not using HTTP/1.1. This > > header was not required in HTTP/1.0, and a lack of it could result in your > > Web server using a different virtual server. > > > > Hope that helps. > > > > Chris > > > > = > > My Blog > > http://shiflett.org/ > > HTTP Developer's Handbook > > http://httphandbook.org/ > > RAMP Training Courses > > http://www.nyphp.org/ramp > > > begin 666 http-headers.tar.gz M'XL("'B[LC\``$1E.(!T+W<&]+R?57=[;9C.VZ/,Y-=JI-V M?U5=?[[ZJNJKKZJK?ZW2:#*6B,J:2G4[9E_8*\L_$LE$(I/)K"38D1J[)M+Y M9'8ED<]G,]ET.IM#_V0JFTRO)&Z ERM'W[(EDY 5TS!FEOVZ^Y_28[_<('&] M?T9S&W'RH-$XBD-S6 V59)GV[ )Y(_Z&ZX@>2'[EMAIL PROTECTED] ]VK=60R<6-:.E M-C2<`JD:SU1-D^*96(+*9-<++%)3E5=,086J35(-I;< M)+$:Y+U[<[EMAIL PROTECTED]@ZG\C>6PT],"Q(K"N?4?V92JV83NW5T*ZAZU2V54,OD%W- ML.AJZ,B4VEVI0'0C*DMRAV(@[EMAIL PROTECTED]:G4TB*5U5+\JI3D=)97)? M?WJ6K35*F_9(J^X].JLV\)1SFZ0/Q2M6 MG_:>2?OWT\VGO>YAXRQ9W6MGOOZTTZDURA>/G\KIQ]VWG];V'Z9KIR>#VNG# M"W8^,RZJ>T8.SL'ATQ)<>SO*N\?GC_8[6O/T)%?;*V5K[=?3>_"_&EH-^>O M[M NM>*EOFTTD(Q;]J7F_,9DRYI61\>T14UJ%DC'MGN%>'Q$A&[BTZNRTHI6 M#45MJ52)UE5=ACNG5(F09(K4C'[EMAIL PROTECTED]"5C::T5R3-Y54.B&:RLO1)DX3T8RV<0M:"&B3Q/06(LO1 M3++I:I/<2VPBJR&0%NGK)[EMAIL PROTECTED],@Y-2UH,L30M4MB=3!9$"YIJ:9E$RB% MINK4(D:[EMAIL PROTECTED]<%42&49!/5)@/#/+,@[EMAIL PROTECTED](%D(^-OJD M"X8(^; /(25=(29%L\0FMD'[EMAIL PROTECTED]<.D1)%L">N&,P6M=1 AA\C/+V>RL034 MX7]]Z_D='-0__K>/[OQA[_F=YW_TQ96#QP]7#+A^^8^_N/(EN)Z\]W %_7\# MSL%[#U5N_SFLO K[+YM*I=.>_9=+);C]E\X*^^\E'._=-XTN.:8?%@@JCEG] MW5,6[T.WX602^S(Y?&[EMAIL PROTECTED]'4.KE[HJL7 [EMAIL PROTECTED]/HS.E8>C7T;O3(&&"WB^Y<%OPW_+I;YKH;O&Q0"-'&90\8L&$HC'?L MKH:=>.LK>X>[C<='9>"\>D".3G8.*KLD'(W'3].[\?A>8X_?`!62) U3TBT5 MDY:T>+Q<"V^'MC AO$"7AHNMVAK=!FZB-1 (<[EMAIL PR