Re: [PHP] require_once adds a "1"
The '1' is received simply because your requirement clause echoed the result to the page. include, require and include_once all return boolean results of 1 or 0 which indicates a successful loading of said include. If you want to suppress the output of an include use ob_ methods which prevent output the stdout. Simply putting 'include_once("anyfile.php")' will output whatever processes occur within that include. Putting the echo statement will additionally output the status of the include operation. Regards, Jim londontown.com Ernest E Vogelsinger wrote: At 17:28 07.03.2003, Gary spoke out and said: [snip] Hi I've included the following in a php document: echo @ require_once("anyfile.php") and it works exactly as I expect except at the end of the included document theres a single "1" displayed. I've noticed also that if I include a document in the included document the end result will be the document I want exactly as I want it with the addition of two ones "11"s can anyone tell me how to get rid of the ones? (if I run anyfile.php by itself there are no "1"s) [snip] This happens if the included file returns some value, in your case it seems to return "true". Remove the return statement (you may simply "return;" if necessary) and the 1 will be history.
[Fwd: Re: [PHP] error while reading google-search-results]
Welcome to a mine field of problems :-) 1. The url you have entered is invalid. Thats a good first check to make usually. Try /search?q=test to get that bit sorted. 2. Google prevents known useragents from accessing it's content as it believes you are acting as a spider or a search engine stealing thier content. To counter this you need to use a new url capturing method and specifically set the name of the useragent. Use 'MSIE'. You can use curl, lwp etc to do this kind of thing. Curl is excellent, fast, highly configurable and execellent with secure connections. 3. I suggest you don't do this - they prevent it for a reason. Jim Jens Lehmann wrote: For reading in and displaying a file $uri I use this short script: $uri = 'http://www.google.de?q=test'; echo implode('',file($uri)); ?> Of course this works well for almost every website, but I have problems reading in the results of google (for instance the URI above). The error message I get is: [07-Mar-2003 16:14:13] PHP Warning: file("http://www.google.de?q=test";) - Success in /var/www/test/getfile.php on line 20 [07-Mar-2003 16:14:13] PHP Warning: Bad arguments to implode() in /var/www/test/getfile.php on line 20 Does anyone know why this happens? I use PHP 4.23 and Apache 1.3.26 on Debian GNU/Linux 3.0. Jens -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[Fwd: Re: [PHP] Checking for Null Variables]
quick way: if (!$field["name"]){ } else {} elegant ways (there will be many): if (empty($field["name"])){ // null or 0 } else {} if (is_null($field["name"])){ // null } else {} is_scalar() // string is_integer() // integer is_float() // float etc etc etc Christopher J. Crane wrote: How do I check if a variable is blank or not. I am returning data from a MySQL database and if a field is empty I would like to do something different. I tried if($field["Name"] == "") { do this } else { do this } It does not work right. Actually, at one point, it was working in the exact opposite manner. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] dynamic/multidimensional arrays in classes
$this->$arr[] should be $this->arr[] You are using a variable defined within the class - since it is a class variable you can reference it as you would anything else within the class, using '$this->' Patrick Teague wrote: I'm having problems figuring this out. This first way gives me a 'Fatal Error: Cannot use [] for reading in class.php on line xx' class myClass { var $arr = array(); function add_something( $value ) { $this->$arr[] = $value; // this is the line causing the error } } I've also tried using count() to find out how many items are in $arr, but it keeps saying that $r == 0... i.e. function add_something( $value ) { $r = count($arr); /* if( is_null( $r ) { $r = 0; } */ //print( $r ); $this->$arr[$r] = $value; } I've tried this both with & without the commented section & still $r = 0 even if you use '$class->add_something("my value");' 50 times. I'm guessing once this problem is solved it will work for multidimensional arrays as well? Patrick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] timestamp to english
In mysql use DATE_FORMAT(FROM_UNIXTIME(time),"%H ... etc") In PHP use echo date("", time()); Read the manuals at mysql.com and php.net. jim Lord Loh. wrote: How do I convert the unix time stamp (the one I get by the time()) to a readable English language time I am getting data from mySQL by the "now()" function Please Help Thank You. Lord Loh. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] imagejpeg and downloading images
READ the manual. The snippet is correct but if you want to take advantage of the saving features of this function follow the function information at the top of the page. Jumping straight to the user snippets is a mistake as they are user contributed and may not document the whole function. int imagejpeg ( resource image [, string filename [, int quality]]) imagejpeg($im,'myfile.jpg',80); Doug Coning wrote: Hi All, I'm using the following code to try to download images automatically from a directory: header('Content-Type: image/jpeg'); $im = imagecreatefromjpeg("001_SM77GR.jpg"); imagejpeg($im,'',85); imagedestroy($im); I copied this code from PHP.net. However, when I run the above code, it doesn't download the image, it just shows the image in the browser. I'm using IE 6 for my browser. How I get PHP to download this image? Thanks! Doug Coning -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mail() function
RTFM! mail($email_address,$subject,$message,$header); You can use @mail to supress any errors produced. Example: @mail("[EMAIL PROTECTED]","This is a Test","My Message","From: James <[EMAIL PROTECTED]>"); Look at: http://uk.php.net/manual/en/ref.mail.php - James www.LondonTown.com -Original Message- From: Phil Schwarzmann [mailto:[EMAIL PROTECTED]] Sent: 29 May 2002 15:58 To: [EMAIL PROTECTED] Subject: [PHP] mail() function I want to write a simple script that sends an e-mail message using PHP. I'm assuming that my web-host has the mail function hooked up to the e-mail server (should I be assuming this or should I assume that it's NOT hooked up?). What is the syntax for this command? something like this... ? (assuming that the variables contain the proper data) mail($contactemail, $subject, $message, $headers); THANKS!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mail() function
knowledge -Original Message- From: Ed Gorski [mailto:[EMAIL PROTECTED]] Sent: 29 May 2002 16:26 To: r; [EMAIL PROTECTED] Subject: Re: [PHP] mail() function lol.what does that return? At 09:08 PM 5/29/2002 -0700, r wrote: >That may and may not work, I would suggest you add the RTFM() function, then >it WILL work. >Cheers, >-Ryan >- Original Message - >From: "Phil Schwarzmann" <[EMAIL PROTECTED]> >To: <[EMAIL PROTECTED]> >Sent: Wednesday, May 29, 2002 7:57 AM >Subject: [PHP] mail() function > > > > I want to write a simple script that sends an e-mail message using PHP. > > > > I'm assuming that my web-host has the mail function hooked up to the > > e-mail server (should I be assuming this or should I assume that it's > > NOT hooked up?). > > > > What is the syntax for this command? > > > > something like this... ? (assuming that the variables contain the > > proper data) > > > > mail($contactemail, $subject, $message, $headers); > > > > THANKS!! > > > > >-- >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
RE: [PHP] Global variables
Look at the auto-prepend or auto-append feature. -Original Message- From: serge gedeon [mailto:[EMAIL PROTECTED]] Sent: 29 May 2002 14:35 To: [EMAIL PROTECTED] Subject: [PHP] Global variables Dear sir, I would like to know if I could create using PHP, global variables that I could use in diferrent files. I don't want to use http_get_vars or post or cookies is there an other way? Thank you. Serge GEDEON _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp. -- 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] How can I remove the last character from a one line file?
Function StripLastChar( $file ){ $fp = fopen("$file","r"); if ($fp){ $contents = fread($fp,10); fclose($fp); } $contents = eregi_replace("o$","",$contents); return $contents; } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: 30 May 2002 11:05 To: [EMAIL PROTECTED] Subject: RE: [PHP] How can I remove the last character from a one line file? Hi all, The problem is nearly solved. I need my if statement to read the last character from the file & if it ends with an o, then remove the one character. My current if statement allows the action to take place if there is an o anywhere in the file. Can somebody help me with this. My current if statement looks like this: if (eregi (".*\b",$port)){ $port=substr($port,0,(strlen($port)-1)); } Thanks alot Dave -Original Message- From: Rea, David Sent: 28 May 2002 15:46 To: 'Ed Gorski' Subject: RE: [PHP] How can I remove the last character from a one line file? That worked a dream, Thanks Ed! Dave -Original Message- From: Ed Gorski [mailto:[EMAIL PROTECTED]] Sent: 28 May 2002 14:41 To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [PHP] How can I remove the last character from a one line file? Try: $string="Jacko"; $string=substr($string,0,(strlen($string)-1)); echo $string; ed At 09:35 AM 5/28/2002 -0400, [EMAIL PROTECTED] wrote: >Hi all, > > How can I remove the last character from a one line file? > i.e. I need to change Jacko to Jack > > >I would really appreciate a response on this! > >Thank you! >Dave > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php Edmund Gorski Programmer / Analyst WWW Coordinator Dept. @ District Office 727-341-3181 -- 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] user auth.. with mysql and cookies.. help
It's basically saying that you are outputing stuff to the browser before you are setting the cookies which is a no go. All header requests (header() & setcookie()) must be run before any text is outputted. Thus, the most common error is that after or before your php tags is empty space, which to PHP is considered outputted text and you wont be able to set any headers. Other than that you might be setting cookies after you have echo'd templates or some such. - James -- W: www.londontown.com @: [EMAIL PROTECTED] -- -Original Message- From: Anton Heryanto [mailto:[EMAIL PROTECTED]] Sent: 30 May 2002 11:44 To: [EMAIL PROTECTED] Subject: [PHP] user auth.. with mysql and cookies.. help sorry, bother all of you with my same question i was learn to make user auth with mysql and using cookies, i have trouble with this error message; Warning: Cannot add header information - headers already sent by (output started at ../functions.inc:54) in ../functions.inc on line 49 Warning: Cannot add header information - headers already sent by (output started at ../functions.inc:54) in ../functions.inc on line 50 Warning: Cannot add header information - headers already sent by (output started at ../functions.inc:54) in ../functions.inc on line 51 Warning: Cannot add header information - headers already sent by (output started at ../functions.inc:54) in ../login.php on line 12 in this case i use 4 file .. 1)index.html -- sending data (methode post to login.php); 2)login.php 3)function.inc -- all the function i use 4)common.inc -- global variable; 2...login.php. http://$http_host/$docroot/report.php";); exit(); } else{ header("Location:http://$http_host/$docroot/error1.htm";); exit(); } 3.function.inc %s\n",$message); } function authenticateUser($user, $password) { global $host, $httphost, $user_db, $password_db, $db, $docroot; if (! ($link = mysql_pconnect($host, $user_db, $password_db))) { DisplayErrMsg(sprintf("internal Error %d: %s \n", mysql_errno(), mysql_error() )); DisplayErrMsg(sprintf("internal Error %s %s %s %d: %s \n", $host, $user, $password, mysql_errno(), mysql_error() )); return 0; } if (! ($result = mysql_db_query("$db","select * from user_login where userid = '$user'"))) { DisplayErrMsg(sprintf("internal Error %d: %s \n", mysql_errno(), mysql_error() )); return 0 ; } if (($row = mysql_fetch_array($result)) && ($password==$row["password"] && $password != "")) return 1; else return 0; } function deleteCookies() { for ($i=0; $i<$total_items; $i++) { setcookie("items_tray[$i]",""); setcookie("quantity[$i]",""); } setcookie("items_tray",""); setcookie("total_items",""); setcookie("quantity",""); } ?> and 4. common.inc ~ could you tell me what and where is the mistake ... thank for all of you all kindness regards anton --Linux is Power--- -- 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] Design Problem
Does it matter? The search engine doesnt know your producing dynamic content, its just requesting a page to scan, regardless of the way your producing it. - James -- W: www.londontown.com @: [EMAIL PROTECTED] -- -Original Message- From: Dani [mailto:[EMAIL PROTECTED]] Sent: 30 May 2002 14:40 To: [EMAIL PROTECTED] Subject: [PHP] Design Problem Importance: High Hi everyone, I'm new to this... What is the best way to make Search Engine Crawler still index us although we are using a script (PHP) to detect the IP of the crawler to provide the keywords for a certain crawler? Any advise is welcome.. Dani -- 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] Design Problem
I do it a different way - using IP's can be a bit of a bummer since they might change but often as not the hostnames dont. I detect spiders using the HTTP_USER_AGENT which identifies them either as say "kitty once hourly", "GoogleBot" or "Lycos" or some such - most of the decent spiders use the user_agent var to identify themselves and you can display alternate info dependent on which spider it is. For the majority of the content stuff we do we steer clear of using long and difficult query strings since some (not all) search engines dont like them - We use the Apache Directive ( or .htaccess ) to run our stuff through what looks like a directory but is in fact just a script. - James -- W: www.londontown.com @: [EMAIL PROTECTED] -- -Original Message- From: Dani [mailto:[EMAIL PROTECTED]] Sent: 30 May 2002 15:18 To: James Holden Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Design Problem Importance: High Thanks very much for the advice! Was that actually the way to do it? If it is,where can I get list of the IPs, please... thanks again... Dani James Holden wrote: > Does it matter? > > The search engine doesnt know your producing dynamic content, its just > requesting a page to scan, regardless of the way your producing it. > > - James > -- > W: www.londontown.com > @: [EMAIL PROTECTED] > -- > > -Original Message- > From: Dani [mailto:[EMAIL PROTECTED]] > Sent: 30 May 2002 14:40 > To: [EMAIL PROTECTED] > Subject: [PHP] Design Problem > Importance: High > > Hi everyone, > > I'm new to this... > What is the best way to make Search Engine Crawler still index us > although we are using a script (PHP) to detect the IP of the crawler to > provide the keywords for a certain crawler? > > Any advise is welcome.. > Dani > > -- > 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Design Problem
I dont deliver alternate content, I track when they visit which is a different thing all together. - James -- W: www.londontown.com @: [EMAIL PROTECTED] -- -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED]] Sent: 30 May 2002 13:05 To: [EMAIL PROTECTED] Subject: Re: [PHP] Design Problem On Thursday 30 May 2002 19:42, James Holden wrote: > I do it a different way - using IP's can be a bit of a bummer since they > might change but often as not the hostnames dont. > > I detect spiders using the HTTP_USER_AGENT which identifies them either as > say "kitty once hourly", "GoogleBot" or "Lycos" or some such - most of the > decent spiders use the user_agent var to identify themselves and you can > display alternate info dependent on which spider it is. Do note that some (most?) crawlers don't take kindly to this practice of delivering content based on the HTTP_USER_AGENT. If you're found out you'll most likely be removed from the search engine in question. -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* On the whole, I'd rather be in Philadelphia. -- W.C. Fields' epitaph */ -- 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] MORE Design Problem
http://www.phpbuilder.com/columns/tim2526.php3 - James -- W: www.londontown.com @: [EMAIL PROTECTED] -- -Original Message- From: Dani [mailto:[EMAIL PROTECTED]] Sent: 30 May 2002 16:12 To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [PHP] MORE Design Problem Importance: High Thank you...everyone! I really appriciated it. Where can I learn about all of this? Is there a tutorial website about this? thanks again. Dani [EMAIL PROTECTED] wrote: > > James Holden wrote: > > > >> Does it matter? > >> > >> The search engine doesnt know your producing dynamic content, its just > >> requesting a page to scan, regardless of the way your producing it. > > search engine spiders will usually disregard the search string of a URL, > i.e. everything after and including the "?" character. > to overcome this, you should use url rewrite mechanisms which can turn > > http://www.example.com/page.php?key1=val1&key2=val2 > > to > > http://www.example.com/page/val1/val2 > > hth, > Jakob. > > -- > 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] nested if parse error
I think coding without the use of brackets and line seperation will drive you mad! A working copy of your code: This in my humble op is so much neater and you can debug this in a second. if (1){ if (1) { echo "Hello"; } } else { } - James -- W: www.londontown.com @: [EMAIL PROTECTED] -- -Original Message- From: Miroslav Figlar [mailto:[EMAIL PROTECTED]] Sent: 30 May 2002 13:05 To: [EMAIL PROTECTED] Subject: [PHP] nested if parse error could somebody explain me please what is wrong with this piece of code? it gives me parse error on line 4 this works fine (no parse error): thank you miro -- 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: PHP can not connect to mysql
@mysql_connect("localhost:/tmp/mysql","user","pass"); - James -- W: www.londontown.com @: [EMAIL PROTECTED] -- -Original Message- From: andy [mailto:[EMAIL PROTECTED]] Sent: 31 May 2002 15:19 To: Michael Davey; [EMAIL PROTECTED] Subject: [PHP] Re: PHP can not connect to mysql That is the wron socket. I found out that my mysql version is running on socket /tmp/mysql.sock while the old one is running on /var/lib/mysql/mysql.sock. How can I tell php to connect with the other socket? Thanx, Andy - Original Message - From: "Michael Davey" <[EMAIL PROTECTED]> Newsgroups: php.general To: <[EMAIL PROTECTED]> Sent: Friday, May 31, 2002 4:05 PM Subject: Re: PHP can not connect to mysql > Check permissions on '/var/lib/mysql/mysql.sock' I seem to remember having > this problem in the past... > > Mikey > > "Andy" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > Hi there, > > > > I am runningn suse72 and there was a mysql installation with the rpm > > installed. so I did try to get rid of all the stuff I found from the old > > mysql installation (with yast) and compiled mysql from source. Server is > > running now. Unfotuantelly php is still trying to connect to the old > > version. phpinfo tells me the old mysql version number. > > > > This is what I am gettinng from php: > > > > Warning: Can't connect to local MySQL server through socket > > '/var/lib/mysql/mysql.sock' (2) in > > > > Server is definatelly running. Not the old one though! I killed the old > > process which was anyhow running. > > > > Can anybody help on that? > > > > Thank you very much in advance, > > > > Andy > > > > > > -- 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