[PHP] File reading code2
Hi, Can someone make me an example of simple reading a *.txt file on a hard drive and displaying that file with a echo command or some loop or anything path to file: (C:\Program Files\XAMPP\xampp\htdocs\test_folder\test1.txt) btw the script is in this folder to. Full code please. Thanks in advance! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] File reading code2
This just dumps the content to the browsers. You could use file() instead if you want to loop thru every line. $file = "test1.txt"; if(file_exists($file)) { if(is_readable($file)) { if($file_content = get_file_contents($file)) { echo ""; echo $file_content; echo ""; } echo "Something went wrong"; } else echo "Cannot read the file '$file', check permissions"; } else echo "The file '$file' does not exist in this directory"; You should learn how to read the manual, because in the end we will not do this kind of things if it already is in the manual. http://th.php.net/manual/en/function.file-get-contents.php http://th.php.net/file Best regards, Peter Lauri www.dwsasia.com - company web site www.lauri.se - personal web site www.carbonfree.org.uk - become Carbon Free -Original Message- From: Delta Storm [mailto:[EMAIL PROTECTED] Sent: Saturday, January 06, 2007 10:39 AM To: php-general@lists.php.net Subject: [PHP] File reading code2 Hi, Can someone make me an example of simple reading a *.txt file on a hard drive and displaying that file with a echo command or some loop or anything path to file: (C:\Program Files\XAMPP\xampp\htdocs\test_folder\test1.txt) btw the script is in this folder to. Full code please. Thanks in advance! -- 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] newbie question regarding URL parameters
On Sat, 2007-01-06 at 13:31 +1100, Ryan Fielding wrote: > Robert Cummings wrote: > > On Fri, 2007-01-05 at 20:57 -0500, Jim the Standing Bear wrote: > > > >> Hello, > >> > >> I have a newbie question regarding URL parameters. The PHP script I > >> wrote need to read parameters passed in from a URL, so as an example > >> > >> http://my.domain/myscript.php?name=me&age=27 > >> > >> and my script would use $name to get the value for name and $age to > >> get the value for age. > >> > >> Everything was working fine until the sysadmin did a upgrade of the > >> PHP server, and $name and $age both give me nothing. > >> > >> I am just wondering if the latest version of PHP has changed the way > >> > > ^ > > > > Ummm, pull your head out of the sand (or whatever other dark recess you > > have it stuck in). Register globals ini setting was defaulted to "off" > > about 3 or more years ago :/ > > > > Cheers, > > Rob. > > > Mate is this kind of behaviour really neccesary? I'm leaning towards yes. > Some people don't know everything that you do I don't know everything either, but register globals has been covered here in depth for the entire length of time since the default value was switched. There's this thing called the archives. There's also this thing called "knowing the technology you use". > and he has already stated he isn't responsible for administering the > server. Not responsible for administering the server is fine, but php.ini is part of PHP and he did state he wrote the script. If you're suggesting a PHP developer shouldn't need to be aware of the associated ini configuration (regardless of whether they can admin it) then you also need to get your head out of the sand. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] convert w date to l format
Um ... can anyone point me to somewhere that it explains this ... I am trying to convert a "int" (1 through 7) to a day name (Monday through Friday) while in a loop with mysql results I have tried $day = date('w', $day); But this does not seem to work ... can anyone assist? Kind Regards, Steven Macintyre http://steven.macintyre.name -- http://www.friends4friends.co.za -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] convert w date to l format
Steven Macintyre wrote: Um ... can anyone point me to somewhere that it explains this ... I am trying to convert a "int" (1 through 7) to a day name (Monday through Friday) while in a loop with mysql results What happened to the weekend? I'd hate to lose the weekend!! I have tried $day = date('w', $day); But this does not seem to work ... can anyone assist? That's because the date function expects a timestamp. What you want is an array, nothing more complicated than that. $days = array(1 => 'Monday', 2 => 'Tuesday', 3 => 'Wednesday', 4 => 'Thursday', 5 => 'Friday', 6 => 'Saturday', 7 => 'Sunday'); $day = $days[$day]; -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] convert w date to l format
On Sat, 2007-01-06 at 14:46 +0200, Steven Macintyre wrote: > Um ... can anyone point me to somewhere that it explains this ... > > I am trying to convert a "int" (1 through 7) to a day name (Monday through > Friday) while in a loop with mysql results > > I have tried $day = date('w', $day); > > But this does not seem to work ... can anyone assist? Something like: Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] convert w date to l format
On Sat, 2007-01-06 at 12:59 +, Stut wrote: > Steven Macintyre wrote: > > Um ... can anyone point me to somewhere that it explains this ... > > > > I am trying to convert a "int" (1 through 7) to a day name (Monday through > > Friday) while in a loop with mysql results > > What happened to the weekend? I'd hate to lose the weekend!! > > > I have tried $day = date('w', $day); > > > > But this does not seem to work ... can anyone assist? > > That's because the date function expects a timestamp. > > What you want is an array, nothing more complicated than that. > > $days = array(1 => 'Monday', >2 => 'Tuesday', >3 => 'Wednesday', >4 => 'Thursday', >5 => 'Friday', >6 => 'Saturday', >7 => 'Sunday'); > > $day = $days[$day]; That's not locale portable :B Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] convert w date to l format
Robert Cummings wrote: > On Sat, 2007-01-06 at 14:46 +0200, Steven Macintyre wrote: >> Um ... can anyone point me to somewhere that it explains this ... >> >> I am trying to convert a "int" (1 through 7) to a day name (Monday through >> Friday) while in a loop with mysql results >> >> I have tried $day = date('w', $day); >> >> But this does not seem to work ... can anyone assist? > > Something like: > > > $monday = strtotime( "next monday" ); > for( $i = 0; $i < 7; $i++ ) > { > echo date( 'w', $monday + (24 * 60 * 60 * $i) )."\n"; > } > > ?> let do a merge of Robbert and Stut ;-) a mindmeld of sorts. > Cheers, > Rob. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Access array data in foreach?
Hello, I Have an array $toplevel containing arrays: Array ( [0] => Array ( [0] => 1 [1] => 1 [2] => eka [3] => eka.php ) [1] => Array ( [0] => 2 [1] => 1 [2] => toka [3] => toka.php ) [2] => Array ( [0] => 3 [1] => 1 [2] => kolmaz [3] => kolmas.php ) [3] => Array ( [0] => 4 [1] => 1 [2] => nepa [3] => nepa.php ) ) How access the data in foreach? Now I do this and it prints Array[2] to screenin every loop. foreach ($toplevel as $value){ print "myTest.addLabel('labelBullet', '$toplevel[2][2]', $TopLevelCounter+1, 250, '#CC', '#aa', '$toplevel[3]', 'left');\n"; $TopLevelCounter ++; } But print $toplevel[2][2] outside foreach prints kolmaz like I suppose it should Thanks again -Will -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Access array data in foreach?
$value holds the value of the current array element. On 1/6/07, William Stokes <[EMAIL PROTECTED]> wrote: Hello, I Have an array $toplevel containing arrays: Array ( [0] => Array ( [0] => 1 [1] => 1 [2] => eka [3] => eka.php ) [1] => Array ( [0] => 2 [1] => 1 [2] => toka [3] => toka.php ) [2] => Array ( [0] => 3 [1] => 1 [2] => kolmaz [3] => kolmas.php ) [3] => Array ( [0] => 4 [1] => 1 [2] => nepa [3] => nepa.php ) ) How access the data in foreach? Now I do this and it prints Array[2] to screenin every loop. foreach ($toplevel as $value){ print "myTest.addLabel('labelBullet', '$toplevel[2][2]', $TopLevelCounter+1, 250, '#CC', '#aa', '$toplevel[3]', 'left');\n"; $TopLevelCounter ++; } But print $toplevel[2][2] outside foreach prints kolmaz like I suppose it should Thanks again -Will -- 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] Access array data in foreach?
Uh. (Embarrassed) Thanks anyway!! -W ""Casey Chu"" <[EMAIL PROTECTED]> kirjoitti viestissä:[EMAIL PROTECTED] > $value holds the value of the current array element. > > On 1/6/07, William Stokes <[EMAIL PROTECTED]> wrote: >> Hello, >> >> I Have an array $toplevel containing arrays: >> Array ( >> >>[0] => Array ( >>[0] => 1 >>[1] => 1 >>[2] => eka >>[3] => eka.php ) >> >>[1] => Array ( >>[0] => 2 >>[1] => 1 >>[2] => toka >>[3] => toka.php ) >> >>[2] => Array ( >> [0] => 3 >> [1] => 1 >> [2] => kolmaz >> [3] => kolmas.php ) >> >>[3] => Array ( >> [0] => 4 >> [1] => 1 >> [2] => nepa >> [3] => nepa.php ) >> >> ) >> >> How access the data in foreach? Now I do this and it prints Array[2] to >> screenin every loop. >> >> foreach ($toplevel as $value){ >> print "myTest.addLabel('labelBullet', '$toplevel[2][2]', >> $TopLevelCounter+1, >> 250, '#CC', '#aa', '$toplevel[3]', 'left');\n"; >> $TopLevelCounter ++; >> } >> >> But >> print $toplevel[2][2] >> >> outside foreach prints kolmaz like I suppose it should >> >> Thanks again >> -Will >> >> -- >> 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] Windows directory listings
Hi, I am trying to write a script that reads a directory on Windows. All the PHP functions I have looked at all seem to work with the Linux dietary structure. Is there another way to do this. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Uninitialized string offset: 0
I have the following class that generates a Notice: Uninitialized string offset: 0 each time it is called. The lines generating the notice are marked. How do I fix this? class InputFilter { var $tagsArray; var $attrArray; var $tagsMethod; var $attrMethod; var $xssAuto; var $tagBlacklist = array('applet', 'body', 'bgsound', 'base', 'basefont', 'embed', 'frame', 'frameset', 'head', 'html', 'id', 'iframe', 'ilayer', 'layer', 'link', 'meta', 'name', 'object', 'script', 'style', 'title', 'xml'); var $attrBlacklist = array('action', 'background', 'codebase', 'dynsrc', 'lowsrc'); function inputFilter($tagsArray = array(), $attrArray = array(), $tagsMethod = 0, $attrMethod = 0, $xssAuto = 1) { for ($i = 0; $i < count($tagsArray); $i++) $tagsArray[$i] = strtolower($tagsArray[$i]); //<< Notice Generated Here for ($i = 0; $i < count($attrArray); $i++) $attrArray[$i] = strtolower($attrArray[$i]); //<< Notice Generated Here also $this->tagsArray = (array) $tagsArray; $this->attrArray = (array) $attrArray; $this->tagsMethod = $tagsMethod; $this->attrMethod = $attrMethod; $this->xssAuto = $xssAuto; } } TIA. Al Padley -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Uninitialized string offset: 0
Can you show us what you're calling it with? Al Padley -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.web-buddha.co.uk
Re: [PHP] Uninitialized string offset: 0
Sure. $myFilter = new InputFilter('','',0,0); $_POST = $myFilter->process($_POST); BTW - for what I'm trying to do at the moment, if I change the first line to: $myFilter = new InputFilter(); it takes care of the Notice problem. Thanks. Al On Jan 6, 2007, at 12:36 PM, Dave Goodchild wrote: Can you show us what you're calling it with? Al Padley -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.web-buddha.co.uk
Re: [PHP] Uninitialized string offset: 0
On Sat, 2007-01-06 at 12:43 -0700, Albert Padley wrote: > Sure. > > $myFilter = new InputFilter('','',0,0); The first two parameters should be arrays (not strings as you have above). Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Uninitialized string offset: 0
Ah, of course. Thanks. Al On Jan 6, 2007, at 12:57 PM, Robert Cummings wrote: On Sat, 2007-01-06 at 12:43 -0700, Albert Padley wrote: Sure. $myFilter = new InputFilter('','',0,0); The first two parameters should be arrays (not strings as you have above). Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- 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 Sockets - How to detect client disconnection?
How do I detect a disconnected client from a socket resource? In an infinite loop, I socket_read() every open resource that passes a socket_select(). As far as I know, the only way to detect if the client disconnected unexpectedly from their socket resource is when socket_read() returns FALSE (which, during my testing, produced the warning: "An established connection was aborted by the software in your host machine."). However, socket_read() doesn't return FALSE on a disconnected client's socket resource until I first attempt to socket_write() to that resource. In brief pseudo code... socket_create(AF_INET, SOCK_STREAM, SOL_TCP) while (TRUE) foreach (resource where (false === socket_select($arrayofresources, NULL, NULL, 0, 0)) if (socket_read() === false) WON'T DETECT DISCONNECT UNTIL I FIRST socket_write() I appreciate any support you offer and thank you for your time. Best regards, -Tony _ Type your favorite song. Get a customized station. Try MSN Radio powered by Pandora. http://radio.msn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Sockets - How to detect client disconnection?
I used Process Control Functions in PHP and installed some signals to catch socket disconnection. My attempt to do this in loops were a harder way or i could not manage it. There must be some notes about this in archives or i can send some of my code so that you can have a look at them. Aras Koktas [EMAIL PROTECTED] Business Excellence Development Phi.dot Internet Systems -Original Message- From: Anthony Rasmussen [mailto:[EMAIL PROTECTED] Sent: Saturday, January 06, 2007 11:12 PM To: php-general@lists.php.net Subject: [PHP] PHP Sockets - How to detect client disconnection? How do I detect a disconnected client from a socket resource? In an infinite loop, I socket_read() every open resource that passes a socket_select(). As far as I know, the only way to detect if the client disconnected unexpectedly from their socket resource is when socket_read() returns FALSE (which, during my testing, produced the warning: "An established connection was aborted by the software in your host machine."). However, socket_read() doesn't return FALSE on a disconnected client's socket resource until I first attempt to socket_write() to that resource. In brief pseudo code... socket_create(AF_INET, SOCK_STREAM, SOL_TCP) while (TRUE) foreach (resource where (false === socket_select($arrayofresources, NULL, NULL, 0, 0)) if (socket_read() === false) WON'T DETECT DISCONNECT UNTIL I FIRST socket_write() I appreciate any support you offer and thank you for your time. Best regards, -Tony _ Type your favorite song. Get a customized station. Try MSN Radio powered by Pandora. http://radio.msn.com -- 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] reading/editing php file with php script
Hello; I have been writing a php script which is supposed to open and edit a php file on the same server, in the same directory. But I have not been able to get regex as in function ereg() to work to match a line of code to alter. I also have not been able to get strpos() to work in this code. I am not complaining, i am just curious if this is a security feature of php, that it can't be used to open and edit existing script files on a web server. Or am I doing something wrong? I have successfully used php to write a php script file from scratch and then include it. It works good for keeping track of things on the server. Thanks JK -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Search script problem
Hi. I am having problems with a script I wrote which searches keywords from a field in a mysql db table. It is a very simple, one-page script. My site is a toplist, very basic, still in it's infancy. When I go to the page, key in the keywords and press submit, the head, body etc. part of the result script is shown, but no results. , although there are rows in my database containing the `keyword` field data. Below is the script, please see if you find any errors, it could be that I just made a stupid mistake. "; echo "http://www.wapforum.org/DTD/xhtml-mobile10.dtd\";>"; echo "http://www.w3.org/1999/xhtml\";>"; error_reporting(E_ALL ^ E_NOTICE); $pwd = $_GET["pwd"]; $uid = $_GET["uid"]; $action = $_GET["action"]; $cid = $_GET["cid"]; $sid = $_GET["sid"]; $var = $_GET["q"]; include ("function.php"); include ("config.php"); connect($dbserver,$dbname,$dbuser,$dbpass); /Search main page if(!isset($var)){ echo ""; echo "Search Engine"; echo " .m3 {background-color: #291C6F;} .n1 {background-color: #A0A0A0;} .n2 {background-color: #88;} .c2 {color: #00;} .m2 {color: #91D0FF;} body {font-family: Arial, sans-serif; font-size: 12px; color: #ff; background-color: #33; margin-left: 0px; margin-right: 0px; margin-top: 0px;} .ct1 {font-family: Arial, sans-serif; font-size: 12px; color: #800080;} .cre {background-color: #1300A4; padding: 2px 2px 2px 2px; margin: 3px 0 0; font-size: 12px; color:#00; text-align: center; border-width:1px 0; border-style:solid; border-color:#00;} "; echo ""; echo ""; echo ""; echo ""; echo "Search Engine"; echo ""; ///the uid and pwd is nessecary cause my member features are very basic and the urls is used to keep the user 'logged in' echo "Keywords: "; echo ""; echo ""; echo ""; echo "Home"; echo ""; echo ""; } ///Display Results if(isset($var)){ $var = $_GET["q"]; $trimmed = trim($var); //trim whitespace from the stored variable echo ""; echo "Search Results"; echo " .m3 {background-color: #291C6F;} .n1 {background-color: #A0A0A0;} .n2 {background-color: #88;} .c2 {color: #00;} .m2 {color: #91D0FF;} body {font-family: Arial, sans-serif; font-size: 12px; color: #ff; background-color: #33; margin-left: 0px; margin-right: 0px; margin-top: 0px;} .ct1 {font-family: Arial, sans-serif; font-size: 12px; color: #800080;} .cre {background-color: #1300A4; padding: 2px 2px 2px 2px; margin: 3px 0 0; font-size: 12px; color:#00; text-align: center; border-width:1px 0; border-style:solid; border-color:#00;} "; echo ""; echo ""; echo ""; echo "Search Results"; echo ""; // Get the search variable from URL // check for an empty string and display a message. if ($trimmed == "") { echo "Please enter a search..."; exit; } if($pg==0)$pg=1; $pg--; $lmt = $pg*20; $pg++; $cou =$lmt+1; $scount = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM table WHERE keywords like \"%$trimmed%\" AND banned='0' AND hitsin >= '2'")); $pgs = ceil($scount[0]/20); // Build SQL Query $sql = "SELECT * FROM table WHERE keywords like \"%$trimmed%\" AND banned='0' and hits_in >='2' ORDER by hin DESC LIMIT ".$lmt.", 20;"; // EDIT HERE and specify your table and field names for the SQL query $sites=mysql_query($sql); while ($site = mysql_fetch_array($sites)) { $dscr =htmlspecialchars($site[11]); $snm=htmlspecialchars($site[1]); echo "$snm"; echo "$dscr"; $cou++; } $npage = $pg+1; $ppage = $pg-1; if($pg<$pgs) //this is just for clicking on the site's name when the results are displayed { $nlink = "Next"; } if($pg >1) { $plink = "Prev"; } echo "$nlink"; echo "$plink"; echo ""; echo "Home"; echo ""; echo ""; } ?> Like I said, very basic. I know there must be a screw-up somewhere but I can't seem to find it. Thanks Wikus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Search script problem
And the hits_in of the mysql query are the same, I just made a typing mistake. On 1/7/07, Wikus Moller <[EMAIL PROTECTED]> wrote: Hi. I am having problems with a script I wrote which searches keywords from a field in a mysql db table. It is a very simple, one-page script. My site is a toplist, very basic, still in it's infancy. When I go to the page, key in the keywords and press submit, the head, body etc. part of the result script is shown, but no results. , although there are rows in my database containing the `keyword` field data. Below is the script, please see if you find any errors, it could be that I just made a stupid mistake. "; echo "http://www.wapforum.org/DTD/xhtml-mobile10.dtd\";>"; echo "http://www.w3.org/1999/xhtml\";>"; error_reporting(E_ALL ^ E_NOTICE); $pwd = $_GET["pwd"]; $uid = $_GET["uid"]; $action = $_GET["action"]; $cid = $_GET["cid"]; $sid = $_GET["sid"]; $var = $_GET["q"]; include ("function.php"); include ("config.php"); connect($dbserver,$dbname,$dbuser,$dbpass); /Search main page if(!isset($var)){ echo ""; echo "Search Engine"; echo " .m3 {background-color: #291C6F;} .n1 {background-color: #A0A0A0;} .n2 {background-color: #88;} .c2 {color: #00;} .m2 {color: #91D0FF;} body {font-family: Arial, sans-serif; font-size: 12px; color: #ff; background-color: #33; margin-left: 0px; margin-right: 0px; margin-top: 0px;} .ct1 {font-family: Arial, sans-serif; font-size: 12px; color: #800080;} .cre {background-color: #1300A4; padding: 2px 2px 2px 2px; margin: 3px 0 0; font-size: 12px; color:#00; text-align: center; border-width:1px 0; border-style:solid; border-color:#00;} "; echo ""; echo ""; echo ""; echo ""; echo "Search Engine"; echo ""; ///the uid and pwd is nessecary cause my member features are very basic and the urls is used to keep the user 'logged in' echo "Keywords: "; echo ""; echo ""; echo ""; echo "Home"; echo ""; echo ""; } ///Display Results if(isset($var)){ $var = $_GET["q"]; $trimmed = trim($var); //trim whitespace from the stored variable echo ""; echo "Search Results"; echo " .m3 {background-color: #291C6F;} .n1 {background-color: #A0A0A0;} .n2 {background-color: #88;} .c2 {color: #00;} .m2 {color: #91D0FF;} body {font-family: Arial, sans-serif; font-size: 12px; color: #ff; background-color: #33; margin-left: 0px; margin-right: 0px; margin-top: 0px;} .ct1 {font-family: Arial, sans-serif; font-size: 12px; color: #800080;} .cre {background-color: #1300A4; padding: 2px 2px 2px 2px; margin: 3px 0 0; font-size: 12px; color:#00; text-align: center; border-width:1px 0; border-style:solid; border-color:#00;} "; echo ""; echo ""; echo ""; echo "Search Results"; echo ""; // Get the search variable from URL // check for an empty string and display a message. if ($trimmed == "") { echo "Please enter a search..."; exit; } if($pg==0)$pg=1; $pg--; $lmt = $pg*20; $pg++; $cou =$lmt+1; $scount = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM table WHERE keywords like \"%$trimmed%\" AND banned='0' AND hitsin >= '2'")); $pgs = ceil($scount[0]/20); // Build SQL Query $sql = "SELECT * FROM table WHERE keywords like \"%$trimmed%\" AND banned='0' and hits_in >='2' ORDER by hin DESC LIMIT ".$lmt.", 20;"; // EDIT HERE and specify your table and field names for the SQL query $sites=mysql_query($sql); while ($site = mysql_fetch_array($sites)) { $dscr =htmlspecialchars($site[11]); $snm=htmlspecialchars($site[1]); echo "$snm"; echo "$dscr"; $cou++; } $npage = $pg+1; $ppage = $pg-1; if($pg<$pgs) //this is just for clicking on the site's name when the results are displayed { $nlink = "Next"; } if($pg >1) { $plink = "Prev"; } echo "$nlink"; echo "$plink"; echo ""; echo "Home"; echo ""; echo ""; } ?> Like I said, very basic. I know there must be a screw-up somewhere but I can't seem to find it. Thanks Wikus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php
[PHP] Re: Search script problem
So it should be like this (it still doesn't show the results): "; echo "http://www.wapforum.org/DTD/xhtml-mobile10.dtd\";>"; echo "http://www.w3.org/1999/xhtml\";>"; error_reporting(E_ALL ^ E_NOTICE); $pwd = $_GET["pwd"]; $uid = $_GET["uid"]; $action = $_GET["action"]; $cid = $_GET["cid"]; $sid = $_GET["sid"]; $var = $_GET["q"]; include ("function.php"); include ("config.php"); connect($dbserver,$dbname,$dbuser,$dbpass); /Search main page if(!isset($var)){ echo ""; echo "Search Engine"; echo " .m3 {background-color: #291C6F;} .n1 {background-color: #A0A0A0;} .n2 {background-color: #88;} .c2 {color: #00;} .m2 {color: #91D0FF;} body {font-family: Arial, sans-serif; font-size: 12px; color: #ff; background-color: #33; margin-left: 0px; margin-right: 0px; margin-top: 0px;} .ct1 {font-family: Arial, sans-serif; font-size: 12px; color: #800080;} .cre {background-color: #1300A4; padding: 2px 2px 2px 2px; margin: 3px 0 0; font-size: 12px; color:#00; text-align: center; border-width:1px 0; border-style:solid; border-color:#00;} "; echo ""; echo ""; echo ""; echo ""; echo "Search Engine"; echo ""; ///the uid and pwd is nessecary cause my member features are very basic and the urls is used to keep the user 'logged in' echo "Keywords: "; echo ""; echo ""; echo ""; echo "Home"; echo ""; echo ""; } ///Display Results if(isset($var)){ $var = $_GET["q"]; $trimmed = trim($var); //trim whitespace from the stored variable echo ""; echo "Search Results"; echo " .m3 {background-color: #291C6F;} .n1 {background-color: #A0A0A0;} .n2 {background-color: #88;} .c2 {color: #00;} .m2 {color: #91D0FF;} body {font-family: Arial, sans-serif; font-size: 12px; color: #ff; background-color: #33; margin-left: 0px; margin-right: 0px; margin-top: 0px;} .ct1 {font-family: Arial, sans-serif; font-size: 12px; color: #800080;} .cre {background-color: #1300A4; padding: 2px 2px 2px 2px; margin: 3px 0 0; font-size: 12px; color:#00; text-align: center; border-width:1px 0; border-style:solid; border-color:#00;} "; echo ""; echo ""; echo ""; echo "Search Results"; echo ""; // Get the search variable from URL // check for an empty string and display a message. if ($trimmed == "") { echo "Please enter a search..."; exit; } if($pg==0)$pg=1; $pg--; $lmt = $pg*20; $pg++; $cou =$lmt+1; $scount = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM table WHERE keywords like \"%$trimmed%\" AND banned='0' AND hits_in >= '2'")); $pgs = ceil($scount[0]/20); // Build SQL Query $sql = "SELECT * FROM table WHERE keywords like \"%$trimmed%\" AND banned='0' and hits_in >='2' ORDER by hits_in DESC LIMIT ".$lmt.", 20;"; // EDIT HERE and specify your table and field names for the SQL query $sites=mysql_query($sql); while ($site = mysql_fetch_array($sites)) { $dscr =htmlspecialchars($site[11]); $snm=htmlspecialchars($site[1]); echo "$snm"; echo "$dscr"; $cou++; } $npage = $pg+1; $ppage = $pg-1; if($pg<$pgs) //this is just for clicking on the site's name when the results are displayed { $nlink = "Next"; } if($pg >1) { $plink = "Prev"; } echo "$nlink"; echo "$plink"; echo ""; echo "Home"; echo ""; echo ""; } ?> On 1/7/07, Wikus Moller <[EMAIL PROTECTED]> wrote: And the hits_in of the mysql query are the same, I just made a typing mistake. On 1/7/07, Wikus Moller <[EMAIL PROTECTED]> wrote: > Hi. > > I am having problems with a script I wrote which searches keywords > from a field in a mysql db table. > > It is a very simple, one-page script. My site is a toplist, very > basic, still in it's infancy. When I go to the page, key in the > keywords and press submit, the head, body etc. part of the result > script is shown, but no results. > , although there are rows in my database containing the `keyword` field > data. > > Below is the script, please see if you find any errors, it could be > that I just made a stupid mistake. > > > echo ""; > echo " \"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\";>"; > echo "http://www.w3.org/1999/xhtml\";>"; > > error_reporting(E_ALL ^ E_NOTICE); > > $pwd = $_GET["pwd"]; > $u
RE: [PHP] Re: Search script problem
Have you tried to catch (echo) the query you try to execute in mysql and then debug it from there? I saw that you in your code did all in one row. Separate it to: $Query = "your query"; echo $Query; //Use this in phpMyAdmin or any other MySQL administrator and see if the query is correct. If you get matches there your code should be fine. $Result = mysql_query($Query); ... ... Best regards, Peter Lauri www.dwsasia.com - company web site www.lauri.se - personal web site www.carbonfree.org.uk - become Carbon Free -Original Message- From: Wikus Moller [mailto:[EMAIL PROTECTED] Sent: Sunday, January 07, 2007 1:20 AM To: php-general@lists.php.net Subject: [PHP] Re: Search script problem So it should be like this (it still doesn't show the results): "; echo "http://www.wapforum.org/DTD/xhtml-mobile10.dtd\";>"; echo "http://www.w3.org/1999/xhtml\";>"; error_reporting(E_ALL ^ E_NOTICE); $pwd = $_GET["pwd"]; $uid = $_GET["uid"]; $action = $_GET["action"]; $cid = $_GET["cid"]; $sid = $_GET["sid"]; $var = $_GET["q"]; include ("function.php"); include ("config.php"); connect($dbserver,$dbname,$dbuser,$dbpass); /Search main page if(!isset($var)){ echo ""; echo "Search Engine"; echo " .m3 {background-color: #291C6F;} .n1 {background-color: #A0A0A0;} .n2 {background-color: #88;} .c2 {color: #00;} .m2 {color: #91D0FF;} body {font-family: Arial, sans-serif; font-size: 12px; color: #ff; background-color: #33; margin-left: 0px; margin-right: 0px; margin-top: 0px;} .ct1 {font-family: Arial, sans-serif; font-size: 12px; color: #800080;} .cre {background-color: #1300A4; padding: 2px 2px 2px 2px; margin: 3px 0 0; font-size: 12px; color:#00; text-align: center; border-width:1px 0; border-style:solid; border-color:#00;} "; echo ""; echo ""; echo ""; echo ""; echo "Search Engine"; echo ""; ///the uid and pwd is nessecary cause my member features are very basic and the urls is used to keep the user 'logged in' echo "Keywords: "; echo ""; echo ""; echo ""; echo "Home"; echo ""; echo ""; } ///Display Results if(isset($var)){ $var = $_GET["q"]; $trimmed = trim($var); //trim whitespace from the stored variable echo ""; echo "Search Results"; echo " .m3 {background-color: #291C6F;} .n1 {background-color: #A0A0A0;} .n2 {background-color: #88;} .c2 {color: #00;} .m2 {color: #91D0FF;} body {font-family: Arial, sans-serif; font-size: 12px; color: #ff; background-color: #33; margin-left: 0px; margin-right: 0px; margin-top: 0px;} .ct1 {font-family: Arial, sans-serif; font-size: 12px; color: #800080;} .cre {background-color: #1300A4; padding: 2px 2px 2px 2px; margin: 3px 0 0; font-size: 12px; color:#00; text-align: center; border-width:1px 0; border-style:solid; border-color:#00;} "; echo ""; echo ""; echo ""; echo "Search Results"; echo ""; // Get the search variable from URL // check for an empty string and display a message. if ($trimmed == "") { echo "Please enter a search..."; exit; } if($pg==0)$pg=1; $pg--; $lmt = $pg*20; $pg++; $cou =$lmt+1; $scount = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM table WHERE keywords like \"%$trimmed%\" AND banned='0' AND hits_in >= '2'")); $pgs = ceil($scount[0]/20); // Build SQL Query $sql = "SELECT * FROM table WHERE keywords like \"%$trimmed%\" AND banned='0' and hits_in >='2' ORDER by hits_in DESC LIMIT ".$lmt.", 20;"; // EDIT HERE and specify your table and field names for the SQL query $sites=mysql_query($sql); while ($site = mysql_fetch_array($sites)) { $dscr =htmlspecialchars($site[11]); $snm=htmlspecialchars($site[1]); echo "$ snm"; echo "$dscr"; $cou++; } $npage = $pg+1; $ppage = $pg-1; if($pg<$pgs) //this is just for clicking on the site's name when the results are displayed { $nlink = "Next"; } if($pg >1) { $plink = "Prev"; } echo "$nlink"; echo "$plink"; echo ""; echo "Home"; echo ""; echo ""; } ?> On 1/7/07, Wikus Moller <[EMAIL PROTECTED]> wrote: > And the hits_in of the mysql query are the same, I just made a typing > mistake. >
Re: [PHP] reading/editing php file with php script
On Sat, 2007-01-06 at 15:12 -0800, jekillen wrote: > Hello; > I have been writing a php script which is supposed to open and edit a > php file on the same server, > in the same directory. But I have not been able to get regex as in > function ereg() to work to match > a line of code to alter. I also have not been able to get strpos() to > work in this code. I am not > complaining, i am just curious if this is a security feature of php, > that it can't be used to open > and edit existing script files on a web server. Or am I doing something > wrong? I have successfully > used php to write a php script file from scratch and then include it. > It works good for keeping track > of things on the server. PHP can open and write to any file for which it has permissions. Have you checked your error log? Have you checked the return value of fopen()? Have you checked that the file permissions allow the webserver read/write access to the target file? Can you read the file but not write? Does file_exists() return true or false for the file? Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php, curl and aol addressbook import problem
On Fri, January 5, 2007 10:31 pm, Iqbal Naved wrote: > I am desparately looking for a solution for importing address book > from aol > webmail to my browser. I found some commercial solution (such as, > http://svetlozar.net) which was done using cURL. But couldnt find any > php > classes to implement it. Anyone can help me how to implement this ? As > far > as i could go is this code which can successfully log in to aol : > > $login = 'abcd'; > $pass = '1234'; > > $url = "https://my.screenname.aol.com/_cqr/login/login.psp";; > $user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"; > $postvars = > "screenname=".$login."&password=".$pass."&submitSwitch=1&siteId=aolcomprod&mcState=initialized&authLev=1"; > $cookie = "cookies/test"; > @unlink($cookie); > > $ch = curl_init($url); > curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); > curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); > curl_setopt($ch, CURLOPT_CAINFO, "E:/aol_grab/curl-ca-bundle.crt"); > curl_setopt($ch, CURLOPT_HEADER, 1); > curl_setopt($ch, CURLOPT_POST, 1); > curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars); > curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); > curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); > curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); > $content = curl_exec ($ch); > file_get_contents("http://d02.webmail.aol.com/22250/aol/en-us/Suite.aspx";); > //print_r(curl_getinfo($ch)); > //echo "\n\ncURL error number:" .curl_errno($ch); > //echo "\n\ncURL error:" . curl_error($ch); > curl_close ($ch); > unset($ch); > echo "".htmlentities($content); > ?> > > and I was able to log in to it successfully..the output is as below > HTML Code: > > HTTP/1.0 200 OK Date: Wed, 20 Dec 2006 09:31:47 GMT Server: > Apache > Pragma: No-cache Expires: Thu, 01 Jan 1970 00:00:00 GMT Set-Cookie: > RSP_COOKIE=type=23&name=SXFiYWxuYXZlZA%3D%3D&stype =100; > Domain=.aol.com; Expires=Sat, 15-Dec-2007 09:31:47 GMT; Path=/ > Set-Cookie: > SNS_TT=AAppcWJhbG5hdmVkRYkDAwAAEAABADzZgUOA2md9Z10 > eZXKIoglrjoCeCrbwVT0pwLi4eVd8mDKn%2BVKco%2FRRi%2F5 > rNTsm5vMgc1UlyzEDQ%2BXxYeQ%3D; Domain=my.screenname.aol.com; > Expires=Fri, > 19-Jan-2007 09:31:47 GMT; Path=/ Set-Cookie: MC_CMP_ESK=NonSense; > Domain=.aol.com; Path=/ Set-Cookie: > SNS_SKWAT=diAyLjAga2lkIDEgdDF5SDJxYmROcHhxN0FHbEh6 > V1hDMmJLc0djPQ%3D%3D-b0o7Q4xCU%2F39IESbtoTm9mBdSL47fxxUnmD4X1Pn82%2Fol% > 2B03%2BtxOLynThOHeQsaL5xdmerZnzZT34sulbmtlrezipaPL > kGMHiXQBbDQpCZb53AT7EPRZ2sWEvYfeP0a9rf%2FDn%2F2ER3 > 2h0rLA5%2B7UMs6NmHharvEJQCFkTVYUHyjUa6btTL8twXF4Jm > siXUX0uXBuOHibk6Pl9lKtKJj779U%2BiXUU4oBiSpcg6Q%2FY > KJUvGNsk4cjDURDglR9SsQL0iCJ2S1w4YGA%3D; Domain=screenname.aol.com ; > Path=/ > Set-Cookie: SNS_SC=diAxLjAga2lkIDEgQ2R1RXNSeDJGTDZ3SmNNMXRkMUt > hQ25kdEhZPQ%3D%3D-dwYGM2lmn8IsM5qbIMCD4cF876hxn28LVqa2CrLuSNY%2FClN5 > 8OIf%2Bg1GbhwkQ8c4%2BoZTQgtZjkKb0gS4x9xI2v1HzzyBQU > 7%2FUGAuyvgR9SWpqJmjzOpUJldJIJHA43WwgahRfwXBKCp8Ci > B%2FPMLCa4bSsNdpgaEVUgc%2FrdXCOOU%3D; Domain=my.screenname.aol.com; > Path=/ > Set-Cookie: SNS_L0=diAxLjAga2lkIDEgUUpsdVVrUWtzb21SOFhPdGo1SFo > 2R2swQzJzPQ%3D%3D-RgHJcTIzyWP%2BQIb7S6lE%2BpdmQv1XVmfP; Domain= > screenname.aol.com ; Expires=Tue, 15-Jul-2036 09:31:47 GMT; Path=/ > Set-Cookie: SNS_LDC=1 aolcomprod 1 1166607107 0 1166607107 0; Domain= > my.screenname.aol.com; Expires=Fri, 19-Jan-2007 09:31:47 GMT; Path=/ > Set-Cookie: SNS_AA=asrc=2&sst=1166607107; Domain=.aol.com; Path=/ > P3P: > CP="PHY ONL PRE STA CURi OUR IND" Content-length: 1505 Cache-control: > no-cache Content-language: en-US Content-type: text/html;charset=utf-8 > Connection: closeScr > > > > But i dont know how to fetch the email addresses from the contact > list. Any > one can help me on this ? Login to AOL "by hand" and compare the two outputs. Then look for the link or button that accesses your address book. Then have your curl script do that, just like it logged in. You will want your COOKIEJAR to be your COOKIEFILE as well for all subsequent curl operations. COOKIEJAR is for the cookies coming "in" and then COOKIEFILE sends them out again -- Make them the same to maintain state. (The Usual) They are different just in case you need to do that, but it's kinda rare, I think. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php