php-general Digest 25 May 2006 18:33:49 -0000 Issue 4148
php-general Digest 25 May 2006 18:33:49 - Issue 4148 Topics (messages 236872 through 236899): Re: calling JS function from php 236872 by: Ryan Creaser 236873 by: David Tulloh 236874 by: Rabin Vincent 236882 by: Mindaugas L Re: captcha or other recommendations 236875 by: Angelo Zanetti Re: preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm) 236876 by: Kevin Waterson 236899 by: Micky Hulse Slow query-building function 236877 by: George Pitcher Re: Generating thumbnails from tiff images 236878 by: mbneto 236879 by: mbneto 236883 by: Jay Blanchard Re: storing single and double quote in MySQL 236880 by: Mindaugas L 236884 by: afan.afan.net help needed with pager 236881 by: Ross 236885 by: Rabin Vincent Monitoring Remote Server Services using php !!! 236886 by: Phil Martin 236888 by: chris smith 236890 by: Rabin Vincent Õý¹æ´ó¹«Ë¾£¬Ãâ·Ñ°ïÄú°ìÐÅÓÿ¨ 236887 by: zfe PHP halts after calling non-existing socket 236889 by: Artzi, Yoav \(Yoav\) Re: Upload File (binary files?) 236891 by: Michelle Konzack 236892 by: Michelle Konzack syntax highlighting for Shell scripts and C? 236893 by: Michelle Konzack str_replace(), and correctly positioned HTML tags 236894 by: Dave M G 236896 by: Adam Zey 236897 by: tedd Can the pic include be based on a variable? 236895 by: Tristan 236898 by: tedd Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: php-general@lists.php.net -- ---BeginMessage--- suresh kumar wrote: I am facing one problem in my project.I am trying to call a javascript function from php.but it not executing.this is my code. function clientTime() { var cNow = new Date(); var cHour = cNow.getHours(); var cMin = cNow.getMinutes(); var hour= cHour + : + cMin; return hour; } //End function clientTime function clientDate() { var cDate = new Date(); var clientYear = cDate.getFullYear(); var clientMonth = cDate.getMonth(); var clientDay = cDate.getDate(); var year= clientYear + - + clientMonth + - + clientDay; return year; } //End function clientDate ? print span style=padding-left:14.2cmfont size=2 face=Arial color=#55script type=\text/javascript\; print clientTime(); print clientDate()/script/font/span; ? i need help from u. - Yahoo! India Answers Share what your know-how and wisdom Send free SMS to your Friends on Mobile from your Yahoo! Messenger Download now Hi Suresh Unfortunately you cannot call a javascript function from directly within php. What you are doing is generating a web page that has invalid javascript. Try looking at your output with view source for clues. Ryan ---End Message--- ---BeginMessage--- suresh kumar wrote: I am facing one problem in my project.I am trying to call a javascript function from php.but it not executing.this is my code. This is not a php problem, php produces a text file which is interpreted by the browser as html and javascript. Have a look at your html/javascript (view source) and figure out the problem. The use of php is completely incidental. David ---End Message--- ---BeginMessage--- On 5/25/06, suresh kumar [EMAIL PROTECTED] wrote: I am facing one problem in my project.I am trying to call a javascript function from php.but it not executing.this is my code. You can't call a javascript function from php. What you can do is output javascript code that calls a javascript function. function clientTime() { var cNow = new Date(); var cHour = cNow.getHours(); var cMin = cNow.getMinutes(); var hour= cHour + : + cMin; return hour; } //End function clientTime function clientDate() { var cDate = new Date(); var clientYear = cDate.getFullYear(); var clientMonth = cDate.getMonth(); var clientDay = cDate.getDate(); var year= clientYear + - + clientMonth + - + clientDay; return year; } //End function clientDate ? print span style=padding-left:14.2cmfont size=2 face=Arial color=#55script type=\text/javascript\; print clientTime(); print clientDate()/script/font/span; ? Your functions are returning values, but you aren't printing out those values. Try: print document.write(clientTime());; Rabin ---End Message--- ---BeginMessage--- Hi, print needs escaping, so fix style=\\. Read XHTML requirements. span style=padding-left:14.2cmfont size=2 face=Arial color=#55script
[PHP] calling JS function from php
I am facing one problem in my project.I am trying to call a javascript function from php.but it not executing.this is my code. function clientTime() { var cNow = new Date(); var cHour = cNow.getHours(); var cMin = cNow.getMinutes(); var hour= cHour + : + cMin; return hour; } //End function clientTime function clientDate() { var cDate = new Date(); var clientYear = cDate.getFullYear(); var clientMonth = cDate.getMonth(); var clientDay = cDate.getDate(); var year= clientYear + - + clientMonth + - + clientDay; return year; } //End function clientDate ? print span style=padding-left:14.2cmfont size=2 face=Arial color=#55script type=\text/javascript\; print clientTime(); print clientDate()/script/font/span; ? i need help from u. - Yahoo! India Answers Share what your know-how and wisdom Send free SMS to your Friends on Mobile from your Yahoo! Messenger Download now
Re: [PHP] calling JS function from php
suresh kumar wrote: I am facing one problem in my project.I am trying to call a javascript function from php.but it not executing.this is my code. function clientTime() { var cNow = new Date(); var cHour = cNow.getHours(); var cMin = cNow.getMinutes(); var hour= cHour + : + cMin; return hour; } //End function clientTime function clientDate() { var cDate = new Date(); var clientYear = cDate.getFullYear(); var clientMonth = cDate.getMonth(); var clientDay = cDate.getDate(); var year= clientYear + - + clientMonth + - + clientDay; return year; } //End function clientDate ? print span style=padding-left:14.2cmfont size=2 face=Arial color=#55script type=\text/javascript\; print clientTime(); print clientDate()/script/font/span; ? i need help from u. - Yahoo! India Answers Share what your know-how and wisdom Send free SMS to your Friends on Mobile from your Yahoo! Messenger Download now Hi Suresh Unfortunately you cannot call a javascript function from directly within php. What you are doing is generating a web page that has invalid javascript. Try looking at your output with view source for clues. Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] calling JS function from php
suresh kumar wrote: I am facing one problem in my project.I am trying to call a javascript function from php.but it not executing.this is my code. This is not a php problem, php produces a text file which is interpreted by the browser as html and javascript. Have a look at your html/javascript (view source) and figure out the problem. The use of php is completely incidental. David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] calling JS function from php
On 5/25/06, suresh kumar [EMAIL PROTECTED] wrote: I am facing one problem in my project.I am trying to call a javascript function from php.but it not executing.this is my code. You can't call a javascript function from php. What you can do is output javascript code that calls a javascript function. function clientTime() { var cNow = new Date(); var cHour = cNow.getHours(); var cMin = cNow.getMinutes(); var hour= cHour + : + cMin; return hour; } //End function clientTime function clientDate() { var cDate = new Date(); var clientYear = cDate.getFullYear(); var clientMonth = cDate.getMonth(); var clientDay = cDate.getDate(); var year= clientYear + - + clientMonth + - + clientDay; return year; } //End function clientDate ? print span style=padding-left:14.2cmfont size=2 face=Arial color=#55script type=\text/javascript\; print clientTime(); print clientDate()/script/font/span; ? Your functions are returning values, but you aren't printing out those values. Try: print document.write(clientTime());; Rabin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] captcha or other recommendations
tedd wrote: Hi all. I've been playing with captcha for one of my sites. It works well but have had a few issues integrating it into the site and sometimes it appears not to work/show the textfield and graphic. Anyway are there any other suggestions for something with similiar functionality as captcha and what are your experiences with these code bases? TIA -- Angelo Zanetti Z Logic Angelo: Read this: http://www.access-matters.com/2005/05/22/quiz-115-did-a-captcha-catch-ya/ While not prefect by any means (i.e., blind can't see it), you may want to review my click the circle solution: http://xn--ovg.com/captcha If you want the code, I'll provide -- BUT -- try to find another way. tedd thank Tedd, very interesting, and I agree its not nice to eliminate the visually impaired. However my client is getting bombed with posts so I need to put something in place to prevent this. Is it possible for me to get the captcha code for that link you sent me? preferabbly off list. thanks in advance -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm)
This one time, at band camp, Micky Hulse [EMAIL PROTECTED] wrote: Hi all, I have been rtfm on preg_replace, and I am a bit turned-off by how complex reg-exing appears to be anyway, I would like to spend some time learning how I would convert a file full of links that look like: Try this quicky http://phpro.org/tutorials/Introduction-to-PHP-Regular-Expressions.html Kevin -- Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Slow query-building function
Hi, Last year I switched from using FileMaker Pro to MySQL. One of FileMaker's quirks was that if, in a text field, you searched for say, 'free ass boo', it would find any records with those three substrings in that field (in this example, its 'Free Association Books'). I want to have this quirkiness on my site, along with the option of adding + or ! before substrings. I've got it working using the following function: function sql_fltr($sql,$field,$input){ $input = addslashes($input); if(strlen($input)0){ if(substr_count($input,*)0 || substr_count($input,!)0 || substr_count($input,^)0 || substr_count($input,+)0){ $output=; /* search for substring conditions */ $tempy = str_replace( +,|+,str_replace( !,|!,str_replace( *,|*,str_replace( ^,|^,($input); $temp = explode(|,$tempy); $i=0; while($i sizeof($temp)){ if(substr($temp[$i],0,1)==*){ $temp[$i]= and .$field. LIKE '%.strim(str_replace(*,,$temp[$i])).%'; $output.= $temp[$i].|; }elseif(substr($temp[$i],0,1)==!){ $temp[$i]= and .$field. NOT LIKE '%.strim(str_replace(!,,$temp[$i])).%'; $output.= $temp[$i].|; }elseif(substr($temp[$i],0,1)==+){ $temp[$i]= and .$field. LIKE '%.strim(str_replace(+,,$temp[$i])).%'; $output.= $temp[$i].|; }else{ $temp[$i]=and .$field. LIKE '%.strim($temp[$i]).%'; $output.= $temp[$i].|; } $i++; } $output = strim(substr($output,0,strlen($output)-1)); if(substr(strtolower(strim($output)),0,3)=='and'){ $output = str_replace(|, ,$output); } else { $output = substr($output,4,strlen($output)-1); } /* search for whole string conditions */ } elseif(substr($input,0,1)==*){ $output=$field. LIKE '%.strim(str_replace(*,,$input)).%'; } elseif(substr($input,0,1)==!){ $output=$field. NOT LIKE '%.strim(str_replace(!,,$input)).%'; } elseif(substr($input,0,1)===){ $output=$field.='.strim(str_replace(=,,$input)).'; } else { $input = str_replace( ,|,$input); $output =; /* search for all substrings */ if(substr_count($input,|)0){ $temp = explode(|,$input); $d=0; while($d sizeof($temp)){ $temp[$d]= and .$field. LIKE '%.rtrim($temp[$d]).%'; $output.= $temp[$d].|; $d++; } } else { $output=$field. LIKE '%.rtrim(str_replace(|, ,$temp)).%'; } } } else { $output=; } if(substr(strtolower(strim($output)),0,3)=='and'){ $query = str_replace(|, ,$output); } else { $query = substr($output,4,strlen($output)-1); } $output = str_replace(|, ,$query); return str_replace(and and,and,$output); } For info the strim() function combines ltrim() and rtrim(). My usage example is: $sqlp = select supplier_id from suppliers where (supplier_id0 ; $sqlp.= sql_fltr($sqlp, 'imprint', $pubname); $sqlp.=); echo brbrbr.$sqlp.brbrbr; I just add extra sql_fltr() lines for additional fields. The main problem with this function is that takes 12 seconds on my XP laptop, to build the query (I'm not even hitting the DB, but pasting that into my DB front end gives a quick result. I'm running PHP5.1RC on the laptop (PHP5.0.2 on my server) - both with Apache 2. Can anyone suggest a solution that will improve performance while retaining the functionality? George -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Generating thumbnails from tiff images
Jay, I am not quite sure if you've made sarcastic comments but to make things more clear... I'd like to use GD instead of ImageMagick beacuse I would not want to install extra packages if I can. When I mentioned that I use convert I said 'when GD is not available...' So I have alternatives: if there is no GD support go with ImageMagick. If there is support use GD. On 5/22/06, Jay Blanchard [EMAIL PROTECTED] wrote: [snip] I know the imagemagick tools. I use convert when I need to perform operations on images and gd is not available. I'd like an alternative without having to install any extra packages specially that in this case the scripts will be hosted in a win32 machine (windows xp). [/snip] Ah. Well. You could have saved me the effort by being more descriptive in your first post. 1. Doesn't want to use GD. Check. 2. Doesn't want to use Imagemagick. Check. 3. Doesn't want to install extra packages. Check. 4. SOL. Check.
Re: [PHP] Generating thumbnails from tiff images
Hi, Is this a non documented api? http://www.php.net/manual/en/ref.image.php does not show this. On 5/23/06, Richard Lynch [EMAIL PROTECTED] wrote: On Mon, May 22, 2006 5:10 pm, mbneto wrote: I am looking for sample code/class that can generate a thumbnail (can be a png/jpeg) image from a tiff image. So far I've only found examples using png/jpg/gif as input. In those examples, change the line that reads: imagecreatefromjpeg(...) to imagecreatefromtiff(...) That's pretty much it... -- Like Music? http://l-i-e.com/artists.htm
Re: [PHP] storing single and double quote in MySQL
Yesterday I read this discussion and looked at php manual for mysql_real_escape... There is good example with extra function to check php magic quotes status. I like the idea, because the code is more portable. You don't have to add .htaccess files nor configre php.. Beginner Mindaugas On 5/24/06, tedd [EMAIL PROTECTED] wrote: At 8:14 PM +0200 5/24/06, [EMAIL PROTECTED] wrote: if magic_quotes_gpc is On, does it add slashes in front of quotes when submit through form? Mean, if I submit in input form (text) afan's crazy web, after echo $_POST['record']; I'll get afan\'s \crazy\ web. Is this because of magic_quote_gps is On? -afan afan: You're getting the idea. Whatever is in your mysql dB should look just like it would in print with quotes and all -- and without any escape characters preceding them. So, if your records in mysql (when viewed via something like myphpadmin) have something like this O\'Mally, then the data is wrong. It should be O'Mally and thus somewhere you, or magic_quotes, have added slashes. So, backup to your original data, turn magic_quotes OFF, use mysql_real_escape_string to prepare the data and then add that data to your mysql. Upon retrieval of the data from mysql -- if -- you want to show it to a browser, then use htmlentities. Remember mysql_real_escape_string IN and htmlentities OUT and the world will be well. I don't know if you are working in the same type of environment as me, but I fixed mine by adding a .htacess file to my root. The code is simply a text file like so: php_value magic_quotes_gpc 0 php_value magic_quotes_sybase 0 php_value magic_quotes_runtime 0 That might work for you -- others on this list may have more detailed information. In any event, IMO do everything you can to turn magic_quotes OFF because after that, then everything will be easier and you'll never have to worry about when, or if, you should add_lashes, strip_lashes, and other such confusing stuff. hth's tedd -- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Mindaugas
[PHP] help needed with pager
http://scottishsocialnetworks.org/editor.php http://scottishsocialnetworks.org/editor.phps the pager in this page works except try and choose aberdeen from the area dropdown. You should get 18 answers which is fine except when page 2 is pressed at the bottom the query seems to be scrubbed and it returns the full database. any ideas how I can 'save' the query and not create a new blank query every time the page is slef submitted? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] calling JS function from php
Hi, print needs escaping, so fix style=\\. Read XHTML requirements. span style=padding-left:14.2cmfont size=2 face=Arial color=#55script type=\text/javascript\; I see you are missing semicolon when calling clientDate(); The same for clientTime(); Javascripts need semicolons at the end of statement. in the beginning style must be On 5/25/06, Rabin Vincent [EMAIL PROTECTED] wrote: On 5/25/06, suresh kumar [EMAIL PROTECTED] wrote: I am facing one problem in my project.I am trying to call a javascript function from php.but it not executing.this is my code. You can't call a javascript function from php. What you can do is output javascript code that calls a javascript function. function clientTime() { var cNow = new Date(); var cHour = cNow.getHours(); var cMin = cNow.getMinutes(); var hour= cHour + : + cMin; return hour; } //End function clientTime function clientDate() { var cDate = new Date(); var clientYear = cDate.getFullYear(); var clientMonth = cDate.getMonth(); var clientDay = cDate.getDate(); var year= clientYear + - + clientMonth + - + clientDay; return year; } //End function clientDate ? print span style=padding-left:14.2cmfont size=2 face=Arial color=#55script type=\text/javascript\; print clientTime(); print clientDate()/script/font/span; ? Your functions are returning values, but you aren't printing out those values. Try: print document.write(clientTime());; Rabin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Mindaugas
RE: [PHP] Generating thumbnails from tiff images
[snip] I'd like to use GD instead of ImageMagick beacuse I would not want to install extra packages if I can. [/snip] GD is an extra package. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] storing single and double quote in MySQL
I have an access as root user to the server and it shouldn't be a problem to turn Off magic quote, but I really CANNOT do it right now because, as I said earlier, just put live our new (pretty big) web site and there is no chance to put it again under construction for a next couple of weekls (redo site and test it again). As far as I can see, the only solution is make on extra server whole thing and then, once it's finished and tested, replace the old one? Also, there is a lot of info with slashes i DB - that has to be cleaned too, right? But, as sombody mentioned earlier, the whole php development goes in that direction (like global's Off/On before) and one day I will have to do it anyway. But, at least I can wait for version 2.0 of the web site :). Thanks. -afan At 8:14 PM +0200 5/24/06, [EMAIL PROTECTED] wrote: if magic_quotes_gpc is On, does it add slashes in front of quotes when submit through form? Mean, if I submit in input form (text) afan's crazy web, after echo $_POST['record']; I'll get afan\'s \crazy\ web. Is this because of magic_quote_gps is On? -afan afan: You're getting the idea. Whatever is in your mysql dB should look just like it would in print with quotes and all -- and without any escape characters preceding them. So, if your records in mysql (when viewed via something like myphpadmin) have something like this O\'Mally, then the data is wrong. It should be O'Mally and thus somewhere you, or magic_quotes, have added slashes. So, backup to your original data, turn magic_quotes OFF, use mysql_real_escape_string to prepare the data and then add that data to your mysql. Upon retrieval of the data from mysql -- if -- you want to show it to a browser, then use htmlentities. Remember mysql_real_escape_string IN and htmlentities OUT and the world will be well. I don't know if you are working in the same type of environment as me, but I fixed mine by adding a .htacess file to my root. The code is simply a text file like so: php_value magic_quotes_gpc 0 php_value magic_quotes_sybase 0 php_value magic_quotes_runtime 0 That might work for you -- others on this list may have more detailed information. In any event, IMO do everything you can to turn magic_quotes OFF because after that, then everything will be easier and you'll never have to worry about when, or if, you should add_lashes, strip_lashes, and other such confusing stuff. hth's tedd -- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help needed with pager
On 5/25/06, Ross [EMAIL PROTECTED] wrote: http://scottishsocialnetworks.org/editor.php http://scottishsocialnetworks.org/editor.phps the pager in this page works except try and choose aberdeen from the area dropdown. You should get 18 answers which is fine except when page 2 is pressed at the bottom the query seems to be scrubbed and it returns the full database. any ideas how I can 'save' the query and not create a new blank query every time the page is slef submitted? Get your variables, like 'area', from $_GET if they're not in $_POST. And then you can change your page navigation links to something like: echo $pager-get_prev('a href={LINK_HREF}area=' . $area . ' title=Previouslaquo;/a'); Rabin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Monitoring Remote Server Services using php !!!
Hi everybody, I'm new to the list and also new to php, I hope I can learn many things from here. My first doubt is the following: I'm trying to create a small monitor system, just to suit my needs in monitoring some services in my application. I've found some functions that return to me the service by port, name and so on (getservbyport, getservbyname). What I need is to monitor remote server services, I mean, lets suppose I have a server 192.168.0.2 with a ssh server running. I'd like to see the status (up/down) of that server from another machine, like 192.168.0.1. I don't want to use some monitoring softwares out there in the web, i know they exist and in fact I use many of them like nagios, cacti and so on, but I'm planning to do my own small solution. What I need is some function that asks me a remote IP, port and protocol as input data and results TRUE/FALSE (any boolean value), just to see if the service is up. I did that making a function using nmap, but i don't want to hold that solution to linux, I'd like to use it at other OS. My function's syntax is like this ?php $ssh_status=service_status (192.168.0.2, 22, tcp); if ($ssh_status==TRUE); { echo Service UP; } else { echo Service DOWN; } ? Does anyone know if there is a similar function in PHP ? I'd be very happy if somebody knows about a function like that. Thanks in advance att. Felipe Martins
[PHP] 正规大公司,免费帮您办信用卡
如果此mail无法正常显示,请点击 http://www.51credit.com/minisite/cardjoin/index.php 我爱卡首页 | 关于我们 | 联系方式 热门信用卡推荐 中信STAR卡详情 立即申请中信魔力卡详情 立即申请 加菲猫卡详情 立即申请 兴业信用卡详情 立即申请 据最新统计显示,我国内地信用卡累计发行数量达到已超过 1000 万张,可见国人对信用卡的接受程度之强,如果皮夹里还没有一张信用卡,是否有点落伍了呢!办理信用卡不需要担保,既不需要担保人也不需要质押,方便快捷,现在通过信用卡门户网站――我爱卡网站(www.51credit.com)即可方便快捷的申请信用卡。 我爱卡网上申请信用卡步骤: 模拟评审→在线填写申请表→上门服务→银行审核发卡 客服热线:010-51778989 富有创意的设计,精美的图案,原来信用卡也可以这样酷! 你心动了吗,快快来预约申请吧! 银行卡对比查询 商户优惠查询 中信STAR卡特色服务介绍 安全 挂失卡 零风险 方便 预借现金 全球通行 轻松 先消费 后还款 简易 免担保人 免保证金 精彩 刷卡回馈 积分礼遇 周全 灵活缴款 轻松省力 特色服务 ・ 24 小时全球免费旅游交通意外保险 ・ 24 小时免费意外入院医疗保险 ・ 24 小时手机短信通知服务 ・ 24 小时全球免费客服热线 立即申请 关于我们 联系我们 加入我们 服务条款 隐私条款 友情链接 Copyright 2005 Sino Credit Technologies Inc. All Rights Reserved 京ICP证050596号
Re: [PHP] Monitoring Remote Server Services using php !!!
On 5/25/06, Phil Martin [EMAIL PROTECTED] wrote: Hi everybody, I'm new to the list and also new to php, I hope I can learn many things from here. My first doubt is the following: I'm trying to create a small monitor system, just to suit my needs in monitoring some services in my application. I've found some functions that return to me the service by port, name and so on (getservbyport, getservbyname). What I need is to monitor remote server services, I mean, lets suppose I have a server 192.168.0.2 with a ssh server running. I'd like to see the status (up/down) of that server from another machine, like 192.168.0.1. I don't want to use some monitoring softwares out there in the web, i know they exist and in fact I use many of them like nagios, cacti and so on, but I'm planning to do my own small solution. What I need is some function that asks me a remote IP, port and protocol as input data and results TRUE/FALSE (any boolean value), just to see if the service is up. I did that making a function using nmap, but i don't want to hold that solution to linux, I'd like to use it at other OS. My function's syntax is like this ?php $ssh_status=service_status (192.168.0.2, 22, tcp); if ($ssh_status==TRUE); { echo Service UP; } else { echo Service DOWN; } ? Does anyone know if there is a similar function in PHP ? I'd be very happy if somebody knows about a function like that. No such function exists. You should check out http://www.nagios.org - it's not php but it does what you want. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP halts after calling non-existing socket
After calling a non existing socket PHP halts and doesn't return. It happens when we do it through our web server (AppWeb) or through the command line. The problem is with socket_recvfrom. (see code below) Is this a known bug? a mistake I make in accessing sockets? installation error on my side? Thanks. Code: ?php unlink (/tmp/local_domain); $addr = /tmp/main_adaptor_sock; $socket = socket_create(AF_UNIX, SOCK_DGRAM, 0); if (!$socket) echo problem in creating socket; if (!socket_bind($socket, /tmp/local_domain)) echo problem in binding socket; $buffer = Update; socket_sendto($socket, $buffer, strlen($buffer), 0, $addr); socket_recvfrom($socket, $buffer, 100, 0, $from); echo message recv $buffer \n; ?
Re: [PHP] Monitoring Remote Server Services using php !!!
On 5/25/06, Phil Martin [EMAIL PROTECTED] wrote: Hi everybody, I'm new to the list and also new to php, I hope I can learn many things from here. My first doubt is the following: I'm trying to create a small monitor system, just to suit my needs in monitoring some services in my application. I've found some functions that return to me the service by port, name and so on (getservbyport, getservbyname). What I need is to monitor remote server services, I mean, lets suppose I have a server 192.168.0.2 with a ssh server running. I'd like to see the status (up/down) of that server from another machine, like 192.168.0.1. I don't want to use some monitoring softwares out there in the web, i know they exist and in fact I use many of them like nagios, cacti and so on, but I'm planning to do my own small solution. What I need is some function that asks me a remote IP, port and protocol as input data and results TRUE/FALSE (any boolean value), just to see if the service is up. I did that making a function using nmap, but i don't want to hold that solution to linux, I'd like to use it at other OS. My function's syntax is like this ?php $ssh_status=service_status (192.168.0.2, 22, tcp); if ($ssh_status==TRUE); { echo Service UP; } else { echo Service DOWN; } ? Does anyone know if there is a similar function in PHP ? I'd be very happy if somebody knows about a function like that. You can use php.net/fsockopen. Rabin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Re: Re: Upload File (binary files?)
Am 2006-05-15 20:06:06, schrieb Richard Lynch: After you start working for the CIA and actually write a function that *DOES* something with the blob data to search for common facial features or something, you can use this argument... Until then, it's really rather empty. :-) :-):-) I do not work for the CIA because I live in FR and working for the concurence :-) We have very big servers serving the binaries (pics, docs and more but only the biometric datas are stored in the databases... (the guys there have nothing to do as spidering the internet for PIC's...) Maybe around 400.000.000 peoples allready indexed... The CIA is maybe a little bit more crazy since they are createing a 12-page file of each people of the world... Which IS allready enough to make HDD sellers happy... Oh yes, at the DGSE (where I am PMC) we are using Debian and PostgreSQL 7.4. My little database of 370 GByte + 1,8 TByte binaries has only 83.000 peoples indexed. Greetings Michelle Konzack -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ # Debian GNU/Linux Consultant # Michelle Konzack Apt. 917 ICQ #328449886 50, rue de Soultz MSM LinuxMichi 0033/6/6192519367100 Strasbourg/France IRC #Debian (irc.icq.com) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Re: Upload File (binary files?)
Am 2006-05-15 17:25:05, schrieb Rory Browne: Bullshit. there are multiple tools for copying files from host to host, including ftp, scp, sftp, rsync, nfs, etc. Planning ahead, is a better way to avoid breaking links than using MySQL to store your images. Right, currently I am using a php5 script which generate temporary tables and references where to find the binaries and the I dump the temporary table. After this I put the dump plus the images into a tar-ball and transfer it. The receiver has an equivalent script which can import the table dump and install the binaries correctly. I notice you've misspelt the most important word there. He says the lookup _MAY_ become slow. This behavour is dependent on the filesystem you are using. You will encounter this problem with ext3 if you have too many files in the same dir. You're less likely to encounter it with reiser. This comes down to the competance of the administrator. An incompetantly setup mysql table ( without indexes ) would have the same problem. Right, I have had to create a filesystem with directory structure where I use the md5sum of the binary and split the 32 Bytes it up into several subdirectories (e.g. 4 Byte wise) Now this has speed up my binary-server over the factor 3-5 Oh yes, one thing: For some years as I begun to use PostgreSQL (I think it was 6.5) I have stored *.doc, *.xls and such stuff into the PostgreSQL which gaved me a performance as the hell... Since I do not realy like the hell and found many usefull *NIX-Tools I have extracted the Data into text/plain of for the *.xls stuff into XLM-Tables which can very good stored into the Database and searching is working perfectly... The original are always stored on my binary-server. Having infos about JPEG's? I extract teh EXIF data and store it in the Database... Greetings Michelle Konzack -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ # Debian GNU/Linux Consultant # Michelle Konzack Apt. 917 ICQ #328449886 50, rue de Soultz MSM LinuxMichi 0033/6/6192519367100 Strasbourg/France IRC #Debian (irc.icq.com) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] syntax highlighting for Shell scripts and C?
Hello, since I include source sniplets into some of my webpages I like this syntax highlighting for php scripts... because it make scripts more readable. My question is: Does such thing exist for Shell scripts and C? (It would be realy nice) Thanks Michelle Konzack -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ # Debian GNU/Linux Consultant # Michelle Konzack Apt. 917 ICQ #328449886 50, rue de Soultz MSM LinuxMichi 0033/6/6192519367100 Strasbourg/France IRC #Debian (irc.icq.com) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] str_replace(), and correctly positioned HTML tags
PHP list, This may be a simple matter. Please feel free to tell me to RTFM if you can direct me to exactly where in the FM to R. Or, alternately, please use simple explanations, as I'm not an experienced PHP coder. I'm building a simple content management system, where users can enter text into a web form. The text is stored in a MySQL database. The text should be plain text. When the text is retrieved from the database for display, I want to add some HTML tags so I can control the format with an external CSS. I'm assuming the best way to do this is with str_replace(). But there are some complications which make me unsure of its usage. First, here is the code I initially made: $content = p . str_replace(\r\n, /p\np, $text) . /p\n; echo $content; The problem is that I want to give the users the ability to add text that will be converted to h3 tags. I figure the best and easiest way to do this is give them some text markers, like --++ and ++-- that can be converted to h3 and /h3 respectively. So I guess I do: $content = str_replace(--++, h3, $text); $content1 = str_replace(++--, /h3, $content); $content2 = p . str_replace(\r\n, /p\np, $content1) . /p\n; echo $content2; But of course a user is likely to put their h3 heading at the beginning of their text. Which would generate: ph3Heading/h3text text text/p That's not good. What I need is: h3Heading/h3ptext text text/p And figuring out how to do that was where my brain stopped. I need to be able to account for circumstances where it may not be appropriate to arbitrarily put a p tag at the beginning. As well as h3 tags, there may also be things such as images and hr lines, but they are all similar in that they will take some text code and convert into an HTML entity. I need to be able to separate those out and then be able to place opening and closing p tags at the right place before and after paragraphs. Is there a way to do this? Is there a good tutorial available? Any advice appreciated. Thank you for taking the time to read this. -- Dave M G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Can the pic include be based on a variable?
Can the pic include be based on a variable? my client asked me this question. I have a movie that is the header to the site and it pulls in a swf that calls a picture from pic00.jpg. I'm not sure exactly what he means by this. I'm assuming he wants to pass flash a variable name instead of a hardcoded file name but, I'm not sure exactly how to do this. Am I on the right track? Can someone show me an example or point me in the right direction? Thanks, T -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: str_replace(), and correctly positioned HTML tags
Dave M G wrote: PHP list, This may be a simple matter. Please feel free to tell me to RTFM if you can direct me to exactly where in the FM to R. Or, alternately, please use simple explanations, as I'm not an experienced PHP coder. I'm building a simple content management system, where users can enter text into a web form. The text is stored in a MySQL database. The text should be plain text. When the text is retrieved from the database for display, I want to add some HTML tags so I can control the format with an external CSS. I'm assuming the best way to do this is with str_replace(). But there are some complications which make me unsure of its usage. First, here is the code I initially made: $content = p . str_replace(\r\n, /p\np, $text) . /p\n; echo $content; The problem is that I want to give the users the ability to add text that will be converted to h3 tags. I figure the best and easiest way to do this is give them some text markers, like --++ and ++-- that can be converted to h3 and /h3 respectively. So I guess I do: $content = str_replace(--++, h3, $text); $content1 = str_replace(++--, /h3, $content); $content2 = p . str_replace(\r\n, /p\np, $content1) . /p\n; echo $content2; But of course a user is likely to put their h3 heading at the beginning of their text. Which would generate: ph3Heading/h3text text text/p That's not good. What I need is: h3Heading/h3ptext text text/p And figuring out how to do that was where my brain stopped. I need to be able to account for circumstances where it may not be appropriate to arbitrarily put a p tag at the beginning. As well as h3 tags, there may also be things such as images and hr lines, but they are all similar in that they will take some text code and convert into an HTML entity. I need to be able to separate those out and then be able to place opening and closing p tags at the right place before and after paragraphs. Is there a way to do this? Is there a good tutorial available? Any advice appreciated. Thank you for taking the time to read this. -- Dave M G It seems like your life would be a lot easier with break takes instead of paragraph tags. Break tags behave like newlines, so work rather well for a 1 to 1 correspondance when turning \r\n into br /. This way, you don't have to worry about the opening tags. The fastest way to do this may be the function nl2br(), which takes only one parameter, your string, and returns your string with the newlines replaced by break tags. Another piece of advice is that you are creating a lot of strings. Do you need the string $text to be unmodified? Why don't you do this: $text = str_replace(--++, h3, $text); $text = str_replace(++--, /h3, $text); $text = p . str_replace(\r\n, /p\np, $text) . /p\n; echo $text; Remember that PHP works by value, not by reference. So what happens in that first line is that it makes a copy of $text, does the replacement on that copy, and then overwrites $text with that copy. With your method you are creating a bunch of strings that I would imagine go unused later in your script. Since you seem to want to maintain a newline in the HTML source, nl2br might not be exactly perfect for you. Here is your original code modified to work with break tags: $text = str_replace(--++, h3, $text); $text = str_replace(++--, /h3, $text); $text = str_replace(\r\n, br /\n, $text); echo $text; And here is the same code using arrays and one single replace instruction to do it, since replacement order doesn't matter: $text = str_replace(array(--++, ++--, \r\n), array(h3, /h3, br /\n), $text); echo $text; And of course, if you never do anything with your formatted string except echoing it out, don't store it, just echo it: echo str_replace(array(--++, ++--, \r\n), array(h3, /h3, br /\n), $text); So, to sum up my advice: 1) Don't create extra variables that you will never use 2) Consider using break tags instead of paragraph tags, they're easier to deal with in your situation. 3) Use arrays for replacement when appropriate 4) Don't store data if you're only ever going to echo it out right away and never use it again. I think that's it, unless I missed something. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] str_replace(), and correctly positioned HTML tags
At 12:53 AM +0900 5/26/06, Dave M G wrote: PHP list, This may be a simple matter. Please feel free to tell me to RTFM if you can direct me to exactly where in the FM to R. Or, alternately, please use simple explanations, as I'm not an experienced PHP coder. I'm building a simple content management system, where users can enter text into a web form. The text is stored in a MySQL database. The text should be plain text. When the text is retrieved from the database for display, I want to add some HTML tags so I can control the format with an external CSS. I'm assuming the best way to do this is with str_replace(). But there are some complications which make me unsure of its usage. Dave: RTFM -- yeah, unfortunately, there's a lot of that going around -- most justified, some not. In any event, I think this is where you're going wrong -- don't use str_replace() to alter the *content* at all ! If you know css, then keep the content separate from presentation. Content comes from your mysql and you should be able to place it within html markup where its presentation is controlled by css. For example, if I have a text paragraph ($my_paragraph) that's been pulled from mysql and I want to show that paragraph in html, then I would do something like this: div=content p ?php echo($my_paragraph); ? /p /div That way I use use css to control how that paragraph will look with those div and p tags and, at the same time, make the content easy to handle. If you want to allow users to enter html tags themselves, then you're asking for a bit of trouble IMO because you are relying upon them to do the mark-up correctly. For example, if someone entered h1This is what I want to say/h1 -- how would you handle it? Also note that if that was entered as-is your page would not longer be well formed and would probably cause problems with the rest of your page, not to mention not validating. If you think you can write code to fix their mistakes, then I think that's a mistake for users can screw up code even more than programmers can. :-) Additionally, if you don't handle the input right, then there's a security concern, such as mysql injection. If you want to give your users the option of having headlines and body of work, then provide a Headline box and Body of Work box and then manage those entries in your markup. I think you get the idea. I'm sure there are other ways to do this, but this is the way I've done it. hth's tedd -- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can the pic include be based on a variable?
At 9:54 AM -0600 5/25/06, Tristan wrote: Can the pic include be based on a variable? my client asked me this question. I have a movie that is the header to the site and it pulls in a swf that calls a picture from pic00.jpg. I'm not sure exactly what he means by this. I'm assuming he wants to pass flash a variable name instead of a hardcoded file name but, I'm not sure exactly how to do this. Am I on the right track? Can someone show me an example or point me in the right direction? Thanks, T T: If I understand you correctly, you just create a variable for the first part of the image and then add on .jpg or whatever and then place it in your html img tag. The following is an example taken from my: http://xn--ovg.com/location php $flag = flags/.strtolower($country_code)..png; html fieldset class=bgblue legendYour location/legend ?php echo (Country: $country_name - $country_code nbsp; img src=\$flag\ );? /fieldset What this does is pull in a flag image of the county and show it to the user. I have no idea who the user is, but their IP gives me an indication that I then lookup in a dB. From there, I pull out the corresponding flag and assemble the img srcwhatever call. Get the idea? hth's tedd -- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm)
Koen Martens wrote: You might be better off then by parsing the html file with DOM: http://nl2.php.net/manual/en/ref.dom.php Whoa, that is cool, I had no idea this was something PHP could do! Thanks for the links. :D Cheers, Micky -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm)
Kevin Waterson wrote: Try this quicky http://phpro.org/tutorials/Introduction-to-PHP-Regular-Expressions.html Sweet, good links all. Thanks for sharing! :) Have a great day. Cheers, Micky -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm)
On 5/25/06, Micky Hulse [EMAIL PROTECTED] wrote: Kevin Waterson wrote: Try this quicky http://phpro.org/tutorials/Introduction-to-PHP-Regular-Expressions.html Sweet, good links all. Thanks for sharing! :) Have a great day. Cheers, Micky -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I built something similar to the situation that you are describing. One difference though is I used preg_replace_callback (http://us2.php.net/preg_replace_callback) so that I can do custom scripting with the matched string to be replaced. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] problems with xml parser
Hi there, I am having some trouble in parsing some XML. No idea where I have that xml parser for php from, but I believe it worked ok in the past. Now I do have a file to parse with following structure: SEARCHRESULTS RESULTSET DATABASE RESULT POS=1 TITLEI want to grab this title/TITLE With my xml parser I do just get RESULT = Could anybody please give me a hand to get this running. I am some how lost since I do not have to do as much with XML so far. Thank you in advance, Merlin Here comes my xml-parser.php code: ?PHP class XMLParser { var $xml_url; var $xml; var $data; function XMLParser($xml_url) { $this-xml_url = $xml_url; $this-xml = xml_parser_create(); xml_set_object($this-xml, $this); xml_set_element_handler($this-xml, 'startHandler', 'endHandler'); xml_set_character_data_handler($this-xml, 'dataHandler'); $this-parse($xml_url); } function parse($xml_url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $xml_url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $store = curl_exec ($ch); $data = curl_exec ($ch); curl_close ($ch); $parse = xml_parse($this-xml, $data, sizeof($data)); if (!$parse) { die(sprintf(XML error: %s at line %d, xml_error_string(xml_get_error_code($this-xml)), xml_get_current_line_number($this-xml))); xml_parser_free($this-xml ); } return true; } function startHandler($parser, $name, $attributes) { $data['name'] = $name; if ($attributes) { $data['attributes'] = $attributes; } $this-data[] = $data; } function dataHandler($parser, $data) { if ($data = trim($data)) { $index = count($this-data) - 1; // begin multi-line bug fix (use the .= operator) $this-data[$index]['content'] .= $data; // end multi-line bug fix } } function endHandler($parser, $name) { if (count($this-data) 1) { $data = array_pop($this-data); $index = count($this-data) - 1; $this-data[$index]['child'][] = $data; } } } $url = (http://this ist the url with the xml file); $myFile = new XMLParser($url); $xmlRoot = $myFile-data[0];// GEO Element if (sizeof($xmlRoot) 0 ) { $geoLocation = $xmlRoot['child']; if (sizeof($geoLocation) 0) { $geoLocationProperties = $geoLocation[0]['child']; for ($i = 0 ; $i sizeof($geoLocationProperties); $i++) { echo $geoLocationProperties[$i]['name'] . = . $geoLocationProperties[$i]['content'].br/; } } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm)
Eric Butera wrote: On 5/25/06, Micky Hulse [EMAIL PROTECTED] wrote: Kevin Waterson wrote: Try this quicky http://phpro.org/tutorials/Introduction-to-PHP-Regular-Expressions.html Sweet, good links all. Thanks for sharing! :) Have a great day. Cheers, Micky -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I built something similar to the situation that you are describing. One difference though is I used preg_replace_callback (http://us2.php.net/preg_replace_callback) so that I can do custom scripting with the matched string to be replaced. I know I'm entering this discussion a bit late, but one tool that I've found indispensible in writing regular expressions (even after knowing how to write them) is The Regex Coach (http://www.weitz.de/regex-coach) (Free, and runs on Windows and Linux). Essentially, you paste the text to search into the bottom textbox, and then start typing your regular expression into the top one. As you type, it shows you what it is matching in the bottom one. It can also show you what individual submatches are matching, and all sorts of neat stuff. So, if I have an HTML web page and I want to suck some specific information out of it, I'll paste the information in, write up a regex, and make sure it's matching what it's supposed to. But the feedback AS you're typing it is super handy. For example, if I have a regex, and I add a [a-z], then the indicator will show it matching the next character, then if I add *, the text selection will expand to show it matching the rest of the letters, and so on. Anyhow, I find the feedback as I write a regex to be addictively useful. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Escaping double quotes
So I'm writing this page (PHP Newbie here) and it checks to see if a var is set, if it isn't it spits out the form info like so: echo form action=myform.php method=post; Now is there a way to 'wrap' that so I don't have to escape quotes? Something like perls 'qq' function is what I'm looking for. I tried a few different functions from the website, magic_quotes, addslashes, htmlspecial etc etc but none did what I was looking for Jeremy Pavleck Network Engineer - Systems Management IT Networks and Infrastructure Direct Line: 612-977-5881 Toll Free: 1-888-CAPELLA ext. 5881 Fax: 612-977-5053 E-mail: [EMAIL PROTECTED] Capella University 225 South 6th Street, 9th Floor Minneapolis, MN 55402 www.capella.edu -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Escaping double quotes
On 25/05/06, Pavleck, Jeremy D. [EMAIL PROTECTED] wrote: So I'm writing this page (PHP Newbie here) and it checks to see if a var is set, if it isn't it spits out the form info like so: echo form action=myform.php method=post; Now is there a way to 'wrap' that so I don't have to escape quotes? Something like perls 'qq' function is what I'm looking for. I tried a few different functions from the website, magic_quotes, addslashes, htmlspecial etc etc but none did what I was looking for You know you can switch the php parser on and off like so: ?php if (isset($var)) { ? form action=myform.php method=post ?php } ? which is a bit more efficient and better than all those echo statements and escapes? -- http://www.web-buddha.co.uk dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css) look out for project karma, our new venture, coming soon!
Re: [PHP] Escaping double quotes
So I'm writing this page (PHP Newbie here) and it checks to see if a var is set, if it isn't it spits out the form info like so: echo form action=myform.php method=post; Now is there a way to 'wrap' that so I don't have to escape quotes? Something like perls 'qq' function is what I'm looking for. I tried a few different functions from the website, magic_quotes, addslashes, htmlspecial etc etc but none did what I was looking for Jeremy Pavleck Network Engineer - Systems Management IT Networks and Infrastructure Direct Line: 612-977-5881 Toll Free: 1-888-CAPELLA ext. 5881 Fax: 612-977-5053 E-mail: [EMAIL PROTECTED] Capella University 225 South 6th Street, 9th Floor Minneapolis, MN 55402 www.capella.edu I believe you can just use single qiote for this example of yours. echo 'form action=myform.php method=post'; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Escaping double quotes
Pavleck, Jeremy D. wrote: So I'm writing this page (PHP Newbie here) and it checks to see if a var is set, if it isn't it spits out the form info like so: echo form action=myform.php method=post; Now is there a way to 'wrap' that so I don't have to escape quotes? Something like perls 'qq' function is what I'm looking for. I tried a few different functions from the website, magic_quotes, addslashes, htmlspecial etc etc but none did what I was looking for http://us2.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Escaping double quotes
or heredeoc syntax :) On 5/25/06, John Nichel [EMAIL PROTECTED] wrote: Pavleck, Jeremy D. wrote: So I'm writing this page (PHP Newbie here) and it checks to see if a var is set, if it isn't it spits out the form info like so: echo form action=myform.php method=post; Now is there a way to 'wrap' that so I don't have to escape quotes? Something like perls 'qq' function is what I'm looking for. I tried a few different functions from the website, magic_quotes, addslashes, htmlspecial etc etc but none did what I was looking for http://us2.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Mindaugas
Re: [PHP] Escaping double quotes
Not sure I understand your question correctly. I think you can just use soemthing like: echo 'form action=myform.php method=post'; Mindaugas L wrote: or heredeoc syntax :) On 5/25/06, John Nichel [EMAIL PROTECTED] wrote: Pavleck, Jeremy D. wrote: So I'm writing this page (PHP Newbie here) and it checks to see if a var is set, if it isn't it spits out the form info like so: echo form action=myform.php method=post; Now is there a way to 'wrap' that so I don't have to escape quotes? Something like perls 'qq' function is what I'm looking for. I tried a few different functions from the website, magic_quotes, addslashes, htmlspecial etc etc but none did what I was looking for http://us2.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- 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] Filtering (was storing single and double quote in MySQL)
As you said: Filtering. My next queston. I have small form to activate/deactivate member's account. form method=post action=members.php input type=hidden name=username value=?= $Usename ? input type=hidden name=status value=?= $Status ? input type=image name=action value=change src=images/status_live.gif border=0 /form and once adminisrtrator clicks on button: if(isset($_POST['action'])) { $Username = $_POST['Username']; $action = ''; switch($action) { case 'change': mysql_query(UPDATE members SET status='live' WHERE Username = '.$Username.'); break; case 'edit': // ... break; } } Do I have to filter $Username with mysql_real_escape_string() function even if $Username will not be stored in DB and I use it in WHERE part? If no - how to filter it? Thanks -afan At 4:28 PM +0200 5/24/06, [EMAIL PROTECTED] wrote: after these very helpfull comments, I rad (again) Shiflett's (and few others) Security articles about filtering input and output. And more I read - less is clear :( and At 6:07 PM +0200 5/24/06, [EMAIL PROTECTED] wrote: Ok. Looks like I DID miss the point :) I thought that with mysql_real_escape_string() HAVE TO add slash in front of a quote and THAT's filtering. No, that's NOT filtering input, as per Shiflett's book. Filtering input is proving that the data coming is -- IS -- valid data! Take for example the code he shows on page 11 of his book (Essential PHP Security) where: ?php $clean = array(); switch($$_POST['color']) { case 'red': case 'green': case 'blue': $clean['color'} = $_POST['color']; break; } ? If you inspect this code, you will see that the array $clean will never have anything in it that's not 'red', 'green', or 'blue' -- that's filtering input as per Shiflett. And, that makes prefect sense to me. tedd PS: I changed the subject line because it's a different subject. :-) -- http://sperling.com http://ancientstones.com http://earthstones.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
Re: [PHP] Filtering (was storing single and double quote in MySQL)
On 5/25/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: As you said: Filtering. My next queston. I have small form to activate/deactivate member's account. form method=post action=members.php input type=hidden name=username value=?= $Usename ? input type=hidden name=status value=?= $Status ? input type=image name=action value=change src=images/status_live.gif border=0 /form and once adminisrtrator clicks on button: if(isset($_POST['action'])) { $Username = $_POST['Username']; $action = ''; switch($action) { case 'change': mysql_query(UPDATE members SET status='live' WHERE Username = '.$Username.'); break; case 'edit': // ... break; } } Do I have to filter $Username with mysql_real_escape_string() function even if $Username will not be stored in DB and I use it in WHERE part? If no - how to filter it? Thanks -afan Yes, you're sending it into the DB which means it is a command that needs to be escaped. All MySQL commands need to be escaped. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Filtering (was storing single and double quote in MySQL)
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 25 May 2006 22:19 To: tedd Cc: Eric Butera; php Subject: Re: [PHP] Filtering (was storing single and double quote in MySQL) As you said: Filtering. My next queston. I have small form to activate/deactivate member's account. form method=post action=members.php input type=hidden name=username value=?= $Usename ? input type=hidden name=status value=?= $Status ? input type=image name=action value=change src=images/status_live.gif border=0 /form and once adminisrtrator clicks on button: if(isset($_POST['action'])) { $Username = $_POST['Username']; $action = ''; switch($action) { case 'change': mysql_query(UPDATE members SET status='live' WHERE Username = '.$Username.'); break; case 'edit': // ... break; } } Do I have to filter $Username with mysql_real_escape_string() function even if $Username will not be stored in DB and I use it in WHERE part? If no - how to filter it? Thanks -afan Always sanitise data provided externally; whether it's from the user directly (e.g. a POST form or a URL query string (GET)) or from the browser (e.g. cookie data)... always assume it can never be trusted (there are some nasty people out there) In this case using mysql_real_escape_string() on the supplied username should be enough for most injection attacks ( http://www.google.co.uk/search?hl=enq=sql+injectionmeta= ), but to be more sure try this (if your username is alphanumeric only with spaces): if(isset($_POST['action'])) { $Username = preg_replace('/[^a-zA-Z0-9]+/', '', $_POST['Username']); $action = ''; switch($action) { case 'change': if (!empty($Username)) mysql_query(UPDATE members SET status='live' WHERE Username = '.$Username.'); break; case 'edit': // ... break; } } I think that's right :) Dan -- http://chrome.me.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Filtering (was storing single and double quote in MySQL)
At 11:19 PM +0200 5/25/06, [EMAIL PROTECTED] wrote: As you said: Filtering. My next queston. I have small form to activate/deactivate member's account. form method=post action=members.php input type=hidden name=username value=?= $Usename ? input type=hidden name=status value=?= $Status ? input type=image name=action value=change src=images/status_live.gif border=0 /form and once adminisrtrator clicks on button: if(isset($_POST['action'])) { $Username = $_POST['Username']; $action = ''; = ERROR switch($action) { case 'change': mysql_query(UPDATE members SET status='live' WHERE Username = '.$Username.'); break; case 'edit': // ... break; } } Do I have to filter $Username with mysql_real_escape_string() function even if $Username will not be stored in DB and I use it in WHERE part? If no - how to filter it? Thanks -afan -afan: Two things: 1. Anytime you put anything into a dB then use mysql_real_escape_string() function. If you are NOT going to put it in a dB, then you don't need mysql_real_escape_string() function -- understand? 2. Filtering is like the example I gave you before. You take something that comes in from a POST and then compare that with what you expect. As with your example above -- what do you want $_POST('action) to contain? (Please note the ERROR -- your code would never get into the switch). If you want $_POST('action) contain 'change' or 'edit' or whatever, then test for that in the switch. It's the same as the example I gave you. At some point here, you're going to have to start thinking about what you're doing. tedd -- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Filtering (was storing single and double quote in MySQL)
[snip] 1. Anytime you put anything into a dB then use mysql_real_escape_string() function. If you are NOT going to put it in a dB, then you don't need mysql_real_escape_string() function -- understand? [/snip] Untrue... It isn't just inserting into a DB that requires this function... Consider: User enters: anything'; DROP TABLE x; SELECT 'a' = 'a into the form for username... Now your unescaped SQL statement reads: UPDATE members SET status='live' WHERE Username = 'anything'; DROP TABLE x; SELECT 'a' = 'a' Where x can be a brute-forced table name... I can't remember if MySQL allows multiple statements but I seem to remember hearing that MySQL5 does... If I'm wrong correct me and tell me to RTFM :) Nice catch on the error... I didn't notice that :) HTH (and that I'm right :) ) Dan -- http://chrome.me.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax highlighting for Shell scripts and C?
Michelle Konzack wrote: Hello, since I include source sniplets into some of my webpages I like this syntax highlighting for php scripts... because it make scripts more readable. My question is: Does such thing exist for Shell scripts and C? pastebin.com has it and the code is GPL'ed so you could use that as a starting point (go to the blog - http://blog.dixo.net/category/pastebin/ and you can download it). -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problems with xml parser
Merlin wrote: Hi there, I am having some trouble in parsing some XML. No idea where I have that xml parser for php from, but I believe it worked ok in the past. Now I do have a file to parse with following structure: SEARCHRESULTS RESULTSET DATABASE RESULT POS=1 TITLEI want to grab this title/TITLE With my xml parser I do just get RESULT = First of all do you have valid xml? If you don't have valid xml then you will have issues with it being parsed properly. To check if it's valid, put a php header: header(Content-Type: text/xml); then print out your xml - or save the whole lot as an .xml file. Once you have that, view it in a browser. If that comes back as broken, then you need to fix that first before anything else. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] 5.1.4, mysqli, and fastcgi leaving connections open.
When using PHP 5.1.4 under FastCGI and using mysqli, we are seeing that the connections do not close (filling up the max_connections limit for MySQL 5.0). In fact, the number of connections to mysql quickly become GREATER than the number of FastCGI processes. Restarting apache (and thus fastcgi) takes them out. Has anyone else noticed this? I can't imagine anyone with this configuration not noticing this. Another server with 5.1.2 is fine. Considering this knocks out all webservers connecting to the database, I think this is a critical bug in PHP 5.1.4. I'd like to know if anyone else has this issue or not before I spend a couple hours reverifying it. Thanks! -steve-- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Filtering (was storing single and double quote in MySQL)
At 11:51 PM +0100 5/25/06, Chrome wrote: [snip] 1. Anytime you put anything into a dB then use mysql_real_escape_string() function. If you are NOT going to put it in a dB, then you don't need mysql_real_escape_string() function -- understand? [/snip] Untrue... It isn't just inserting into a DB that requires this function... Consider: User enters: anything'; DROP TABLE x; SELECT 'a' = 'a into the form for username... Now your unescaped SQL statement reads: UPDATE members SET status='live' WHERE Username = 'anything'; DROP TABLE x; SELECT 'a' = 'a' Where x can be a brute-forced table name... I can't remember if MySQL allows multiple statements but I seem to remember hearing that MySQL5 does... If I'm wrong correct me and tell me to RTFM :) Nice catch on the error... I didn't notice that :) HTH (and that I'm right :) ) Dan Dan: A couple of things: One, I'm not sure if afan understands multiple statements, so I didn't want to confuse him; Two, I don't use multiple statements because they confuse me. I'm much more of a step-by-step programmer. I find that sometimes it's best to provide something simple for someone to learn rather than confuse them with remote possibilities. I taught at college level and believe me when I say there is nothing dumber than a student. Baby steps are best -- and the same for me when I'm learning as well. In the exchange I had with afan, we were talking about placing data into a dB without the need for escapes and I think the advice I gave him was correct. I realize that there are exceptions to just about anything IF you dig deep enough. For example did you know that if magic_quotes are turned ON and you use escape_data() that function will use mysql_real_escape_string(). So, here's an example that proves your point, but if I was to inform afan of that, what good would it do? Knowing that hasn't done anything for me. In any event, your point is well taken -- thanks for the clarification. tedd -- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to disable PHP's POST caching?
Why not reconfigure the webserver to proxy a certain url subdirectory to your php script that can be running on any old port? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Filtering (was storing single and double quote in MySQL)
-Original Message- From: tedd [mailto:[EMAIL PROTECTED] Sent: 26 May 2006 02:27 To: Chrome; 'tedd'; [EMAIL PROTECTED] Cc: 'Eric Butera'; 'php' Subject: RE: [PHP] Filtering (was storing single and double quote in MySQL) At 11:51 PM +0100 5/25/06, Chrome wrote: [snip] 1. Anytime you put anything into a dB then use mysql_real_escape_string() function. If you are NOT going to put it in a dB, then you don't need mysql_real_escape_string() function -- understand? [/snip] Untrue... It isn't just inserting into a DB that requires this function... Consider: User enters: anything'; DROP TABLE x; SELECT 'a' = 'a into the form for username... Now your unescaped SQL statement reads: UPDATE members SET status='live' WHERE Username = 'anything'; DROP TABLE x; SELECT 'a' = 'a' Where x can be a brute-forced table name... I can't remember if MySQL allows multiple statements but I seem to remember hearing that MySQL5 does... If I'm wrong correct me and tell me to RTFM :) Nice catch on the error... I didn't notice that :) HTH (and that I'm right :) ) Dan Dan: A couple of things: One, I'm not sure if afan understands multiple statements, so I didn't want to confuse him; Two, I don't use multiple statements because they confuse me. I'm much more of a step-by-step programmer. I don't use them either; hence my uncertainty :) I find that sometimes it's best to provide something simple for someone to learn rather than confuse them with remote possibilities. I taught at college level and believe me when I say there is nothing dumber than a student. Baby steps are best -- and the same for me when I'm learning as well. I'm still learning... very much so... which is why all my advice is subject to correction by a higher mortal... step forward, you know who you are :) In the exchange I had with afan, we were talking about placing data into a dB without the need for escapes and I think the advice I gave him was correct. Never doubted that :)... I have seen much of your advice I realize that there are exceptions to just about anything IF you dig deep enough. For example did you know that if magic_quotes are turned ON and you use escape_data() that function will use mysql_real_escape_string(). So, here's an example that proves your point, but if I was to inform afan of that, what good would it do? Knowing that hasn't done anything for me. I only sought to provide knowledge... knowing the pitfalls regardless of how bad the advice is set out/worded surely must be good Security should be foremost and ignorance no excuse... That's not to say anyone can't make a mistake :) In any event, your point is well taken -- thanks for the clarification. tedd -- -- -- http://sperling.com http://ancientstones.com http://earthstones.com __ NOD32 1.1559 (20060525) Information __ This message was checked by NOD32 antivirus system. http://www.eset.com Dan -- http://chrome.me.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] streamlining php.ini; php.ini is not parsable with parse_ini_file
All, I want to clean up my PHP.ini file on production to be as streamlined as possible so that it's easier to work with and maintain. It is easier to do a diff of my INI and the recommended INI if both files are very similar with whitespace removed, comments cleaned out, and keys sorted, etc. I've tried to use parse_ini_file() function to parse the INI file, but that won't work because the 'extension = *' key is used multiple times in the php.ini. parse_ini_file assumes unique assoc array is returned. I'm guessing PHP doesn't actually use the parse_ini_file to read its own ini. So, I then started parsing the ini myself with my own custom code and soon realized that PHP might not be using the [section] tags either as it uses the INI key=values. Seems like the [section] tags are used more like suggestions for key grouping than for anything functional. Is this a correct assumption? If so, I've got the following INI reading code which will munch the php.ini-recommended and output just the strings which are not commented out. See here and let me know if this looks like robust code: //-- #!/usr/bin/php ?php // we pass the name of an INI file on the command line $script = array_shift($argv); $ini_file_name = array_shift($argv); if (!$ini_file_name || !file_exists($ini_file_name)) { die(usage: $script php.ini file\n); } // slurp in the whole ini file and init $lines = file($ini_file_name); $data = array(); foreach ($lines as $line) { // remove trailing comments, newlines, and start/end whitespace $line = trim(preg_replace(/;[^\\']*$/, , trim($line))); // skip blank lines, commented lines, ini sections, or anything without an '=' in the line if (!$line || $line{0} === ';' || $line{0} === '[' || strpos($line, '=') 1) { continue; } // fix spacing between equal sign list ($key, $value) = preg_split(/\s*=\s*/, $line, 2); $line = $key = $value; // save this key=value pair array_push($data, $line); } // sort and print all keys sort($data); print join(\n, $data); ? //-- Dante -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Filtering (was storing single and double quote in MySQL)
tedd wrote: At 11:51 PM +0100 5/25/06, Chrome wrote: [snip] 1. Anytime you put anything into a dB then use mysql_real_escape_string() function. If you are NOT going to put it in a dB, then you don't need mysql_real_escape_string() function -- understand? [/snip] Untrue... It isn't just inserting into a DB that requires this function... Consider: User enters: anything'; DROP TABLE x; SELECT 'a' = 'a into the form for username... Now your unescaped SQL statement reads: UPDATE members SET status='live' WHERE Username = 'anything'; DROP TABLE x; SELECT 'a' = 'a' Where x can be a brute-forced table name... I can't remember if MySQL allows multiple statements but I seem to remember hearing that MySQL5 does... If I'm wrong correct me and tell me to RTFM :) Nice catch on the error... I didn't notice that :) HTH (and that I'm right :) ) Dan Dan: A couple of things: One, I'm not sure if afan understands multiple statements, so I didn't want to confuse him; Two, I don't use multiple statements because they confuse me. I'm much more of a step-by-step programmer. Dan was giving you an example of a really bad sql injection attack where instead of one query: select * from members where email='email_address'; you end up with three: select * from members where email='anything'; DROP TABLE x; SELECT 'a' = 'a'; The point being never trust user data - always escape it whether you're inserting, updating, deleting or selecting. Using mysql_real_escape_string or your db's equivalent means it becomes only one query (which won't return any results, but stops your data from being destroyed). Multiple statements means running multiple queries within the same function call: so mysql_query(select * from members where email='anything'; DROP TABLE x; SELECT 'a' = 'a';); is actually 3 sql statements (select, drop table, select), but only one call to mysql_query. Whether mysql_query allows this to happen is another thing and one left to the readers to check. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] str_replace(), and correctly positioned HTML tags
Tedd, Adam, Thank you for your advice. While I'm very grateful for your advice, unfortunately, it seems that the core of what you suggest do not fit my situation. First, with Adam's suggestion that I use br / instead of p. The output I am generating is akin to what csszengarden.com generates, so that I can have complete CSS control over page layout and style. br / tags are limited in their scope of design control as compared to p tags, so they are insufficient. Second, with Tedd's advice that I place the variable without formatting within the HTML code. I apologize if I was unclear, as I seem to have given you the wrong impression. I am absolutely trying to separate content from design, which is why everything the user stores is in plain text, and all the formatting happens when it is displayed. None of the modifications which add HTML to the variable get put back into the database. The only small formatting consideration that does get stored in the database are the simulated tags (eg: --++ for h3). I'm not totally thrilled about letting users create some formatting with simulated tags, but the trade off is for giving the users more flexibility. I'm following the same model as WikiMedia, SMF Forums, and other PHP based user input interfaces. And I am trying to be more strict and less expansive than they are. I really am grateful for your advice, but it seems that I really do need to find a way to create p tags around the text when it is displayed. But I definitely thank you for giving me something to think about, and also the tips on how to make my code more efficient. It's my hope that someone can still steer me towards the ability to get p tags surrounding paragraphs, and to be able to separate h3 and other tags from within those p tags. -- Dave M G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in
Hi All, I get the error for line 15 for this code, ?php 15 echo font face='$_SESSION['font']'; 16 echo size='$_SESSION['size']'; 17 echo color='$_SESSION['colour']'; 18 echo $_SESSION['text']; 19 echo /font; 20 ? I have put ' ' quotes around the quotes for each font attribute so that the parser doesn't think the echo is finished too early. Is that wrong? I know that this code would get tedious for lots of text and CSS would be better, but, it's just a little study project from the book I'm following. Cheers. Mark Sargent. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 5.1.4, mysqli, and fastcgi leaving connections open.
steve wrote: When using PHP 5.1.4 under FastCGI and using mysqli, we are seeing that the connections do not close (filling up the max_connections limit for MySQL 5.0). In fact, the number of connections to mysql quickly become GREATER than the number of FastCGI processes. Restarting apache (and thus fastcgi) takes them out. Has anyone else noticed this? I can't imagine anyone with this configuration not noticing this. Another server with 5.1.2 is fine. Considering this knocks out all webservers connecting to the database, I think this is a critical bug in PHP 5.1.4. I'd like to know if anyone else has this issue or not before I spend a couple hours reverifying it. Thanks! -steve-- Sounds like you're using persistent connections. Change from mysql_pconnect to mysql_connect or whatever the mysqli version is. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in
Mark Sargent wrote: Hi All, I get the error for line 15 for this code, ?php 15 echo font face='$_SESSION['font']'; 16 echo size='$_SESSION['size']'; 17 echo color='$_SESSION['colour']'; 18 echo $_SESSION['text']; 19 echo /font; 20 ? I have put ' ' quotes around the quotes for each font attribute so that the parser doesn't think the echo is finished too early. Is that wrong? I know that this code would get tedious for lots of text and CSS would be better, but, it's just a little study project from the book I'm following. Cheers. Mark Sargent. any of these will work: echo font face='.$_SESSION['font'].'; //note the . before and after the variable. echo font face='{$_SESSION['font']}'; echo font face='$_SESSION[font]';//no quotes around the index key ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in
Mark Sargent wrote: Hi All, I get the error for line 15 for this code, ?php 15 echo font face='$_SESSION['font']'; 16 echo size='$_SESSION['size']'; 17 echo color='$_SESSION['colour']'; 18 echo $_SESSION['text']; 19 echo /font; 20 ? I have put ' ' quotes around the quotes for each font attribute so that the parser doesn't think the echo is finished too early. Is that wrong? I know that this code would get tedious for lots of text and CSS would be better, but, it's just a little study project from the book I'm following. Cheers. Mark Sargent. Hi All, sorry, I forgot the fundamentals again, . variableName . echo font face=' . $_SESSION['font'] . '; and no around the variable in an echo statement when no other text in it. echo $_SESSION['text']; Cheers. Mark Sargent. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] syntax highlighting for Shell scripts and C?
Check out Geshi http://qbnz.com/highlighter/ -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: Thursday, May 25, 2006 5:54 PM To: Michelle Konzack Cc: PHP - General Subject: Re: [PHP] syntax highlighting for Shell scripts and C? Michelle Konzack wrote: Hello, since I include source sniplets into some of my webpages I like this syntax highlighting for php scripts... because it make scripts more readable. My question is: Does such thing exist for Shell scripts and C? pastebin.com has it and the code is GPL'ed so you could use that as a starting point (go to the blog - http://blog.dixo.net/category/pastebin/ and you can download it). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php