Jump to content

flaab

Members
  • Posts

    56
  • Joined

  • Last visited

    Never

Everything posted by flaab

  1. Hi, I have a really strange problem in a production server and I don't know what it is. I'm going nuts. I'm programming a HTML newsletter that is saved into he hard drive and sent by mail. So, the HTML code must be created dinamically. Take a look at the following (simplified) code. Basically, it grabs an array of strings and displays an image for each one of them. // Iteramos parrafos poniendo fotos si tenemos for($it = 0; $it < count($parrafos); $it++) { // El parrafo debe ser mas alrgo que 3 caracteres if(strlen($parrafos[$it]) > 2) { // Si tenemos foto para este parrafo if(isset($imagenes[$image_it])) { $cuerpo_final .= '<img width="80" src="http://www.ecoturismorural.com'; $cuerpo_final .= $imagenes[$image_it]; $cuerpo_final .= '" />'; $image_it++; } // Ponemos parrafo $cuerpo_final .= "\n<p>". $parrafos[$it] ."</p>\n"; } } The created string is not modified at any time before being printed on the screen. And the local output is the following: <img width="80" src="http://www.ecoturismorural.com/img/Parrafos/File/IMG_0161.JPG" /> <p>Durante la semana del 26 al 30 de Mayo un grupo ... (more text)</p> <img width="80" src="http://www.ecoturismorural.com/img/Parrafos/File/IMG_0166.JPG" /> <p>El programa "Galicia Natural" tiene como objetivo ... (more text)</p> That will be the correct output. The problem is...the same script executed on the production machine outputs other thing completely! - Domain names are removed from all URLS - Characters < > and " are trasnslated into html entities - Image outputs are surrounded by <p> and </p> All these all by its own! :s <p><img src="img/Establecimientos_Mini/4385La%20Monta%F1eta%201.JPG"></p> <p> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed lorem ... (more text)</p> <p><img src="img/Establecimientos_Mini/64266.jpg"></p> <p>Class aptent taciti sociosqu ad litora torquent per ... (more text)</p> And it's just he same echo(). I would really appreciate any help! Thanks!
  2. Hi :-) I've been struggling arround for a while and don't know how to make this. I would like to know if a certain class variable is declared (even if no value has been assigned to it). For example... class foo { var $something; // Declared with no value //var $else; // Commented, not declared } $obj = new foo(); // Note function is_declared does not exists...I need a function to do this... if(is_declared($foo->something)) echo "Something variable is declared"; if(!is_declared($foo->else)) echo "Else is not declared"; When using isset, false is always retrieved because no value is assigned to those vars. Thanks a lot!
  3. Yeah :-) Php version is... arturo@firecracker ~ $ php --version PHP 5.2.4-2 with Suhosin-Patch 0.9.6.2 (cli) (built: Oct 24 2007 20:08:19) Copyright (c) 1997-2007 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies And PHP error triggered is... Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in /var/www/static.php on line 10 And the code is still... <?php class Foo { const constant = 'Cadena de mierda'; } $classname = 'Foo'; print $classname::constant; ?> thx
  4. Hi :-) I've been trying to do this for a long time...how can I make this work? I always get an error :-) <?php class Foo { public static $my_static = 'foo'; } $classname = 'Foo'; print $classname::$my_static ; ?> It's an officla php example from the official website...but it does not work :-S
  5. Hi :-) I'll go straight to the point; MySql has a "native" ENUM|SET datatype that allows you to insert only certain values, and those values can be retrieved from the Php code to create a combobox. Postgres does not have such datatype, so it has to be "emulated" like this... create table foo ( enumField varchar (check enumField in ('value1', 'value2')) ); So far so good but...How can I retrieve those values from my Php code to create a combobox? :-) Thx!
  6. Hi =) I have a class that may have a lot of relationships and I would like to do something like this... public function getRelated<classname>(){ // Whatever logic } But I want <classname> to be variable...for example getRelatedBooks getRelatedArticles, each class has his own relationships. Can that be done? Thx!
  7. I again! That works but I need to make that class function, also available for the subclasses. Is that possible?
  8. Hi I've a little problem. We can iterate an array or a hash doing something right? Well...what I need is something similar but with all the defined variables within my Scope. A little pseudocode example.. class foo extends whatever { public function doSome() { /* lots of variable declaration and assignation */ foreach(Declared_variable_in_my_scope as $name => $value) do something with it } } } Is there any way to do this? Thx!
  9. Hi =) I've set up a rewrite rule like this <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^([^.]+)/?$ index.php?$1 [L] </IfModule> So this this redireccion is applied. http://www.foo.com/client/view/3 -> http://www.foo.com/index.php?client/view/3 http://www.foo.com/video/delete/56 -> http://www.foo.com/index.php?video/delete/56 The redirection works fine but all my Css, images and files links are broken when inside any controller. How can this be fixed? Is there any mod_rewrite rule for that? Cheers.
  10. I got it! Like this <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^([^.]+)/?$ index.php?$1 [L] </IfModule> But now my Css links are broken and some images as well. How can I link them?
  11. Hi :-) The index.php is called with a large query string. Example: index.php?controller/action/param1/../param10 The last url is the same as www.domain.com/?controller/action/param1/../param10 Then in the php code $_SERVER['QUERY_STRING'] is "controller/action/param1/../param10". Then I explode the query string and call the requested controller executing the requested action and passing the given parameters. I just want to get rid of the ugly '?' char in the Url so it can be called like this www.domain.com/controller/action/param1/../param10 I will keep on trying :-) thanks
  12. I've tried and it does not work =) Here's my .htacess Options -Indexes Options +FollowSymLinks RewriteEngine on RewriteRule ^(.*)$ index.php?$1 [L] The problem is that www.foo.com/foo/foo1/foo2 should be pointing to www.foo.com/index.php?foo/foo1/foo2. I've tried with this one also Options -Indexes Options +FollowSymLinks RewriteEngine on RewriteBase / RewriteRule ^(.*)$ index.php?$1 [L] But it does not work either :-) thanks anyway i'll keep trying
  13. Hi folks :-) My problem is dumb but it's driving me nuts. I have an index.php that receives urls like these - www.domainname.com/index.php?foo/fooaction/parameters - www.domainname.com/index.php?articles/view/5 - www.domainname.com/index.php?contact The part behind ? is called QUERY_STRING in Apache and Php and it's JUST ONE string ("foo/foo2/foo3/whatever") I would like to redirect www.domainname.com/controller/action/parameter to www.domainname.com/index.php?controller/action/parameter so the "index.php?" part does not have to appear in the url. I've played around for a long time but i haven't been able to get it. Which is the correct RewriteRule for that? Thanks in advance.
  14. Hi =) You see...I need to extract from a table all possible values for an enum field to create a drop-down menu. How can I do that? Thanks!!!!!
  15. Hi there :-) I would lilke to display Php code on my website for learning purposes, without being interpreted by the web server. Just displayed. Highlighter would be better. How can I do it? Thanks.
  16. I need it to be from outside of the function code cause i'm programming a web developing framework that should not allow any action to be executed if some parameters are missing in the URL. http://www.whatever.com/foo/whatever/param1/param2 will execute the method "whatever" of the class "foo". But if the "whatever" method needs 3 parameters as those in the previos examples, the method "whatever" should not be executed and an error message should be displayed instead, because the result of the method execution would be corrupt. I do not know how many parameters are going to need the functions programmed by the framework's users, so I need a general solution. Is there a php function that returns how many parameters does a certain function require to be executed? Ideas? Thanks!
  17. Thabks for your answers! But I need that to be done from outside of the method code, not from inside. The params are given by an url mapper. I need to convert that warning into an execution error. Ideas?
  18. Hi =) You see i want to prevent a class method to be executed if any parameters are missing Example code: class foo{ public function whatever($param1, $param2, $param3) { // Whatever logic } } Well, if I execute it without any required parameter...it displays a warning message in the browser and get executed badly! I want the method NOT to be executed if some parameter is missing. How can i do that? Thanks.
  19. Wow thanks that was exactly was I was looking for!!!! Following this issue...Is there any way or operator to prevent a class method to be executed if not all required params are satisfied?
  20. Hi thanks for answering I've tried both ways, using a try catch block and using the value of $link to determine wether the connection could be created... The thing is...yeah, that is what i was looking for. But, when the connection fails Php throws a bunch of warnings i do not want to appear. Warning: mysql_pconnect() [function.mysql-pconnect]: Access denied for user 'ComplaintMater'@'localhost' (using password: YES) in /var/www/ArasPhp/core/libs/Core.php on line 57 Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'www-data'@'localhost' (using password: NO) in /var/www/ArasPhp/core/libs/Core.php on line 58 Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /var/www/ArasPhp/core/libs/Core.php on line 58 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /var/www/ArasPhp/core/libs/Core.php:57) in /var/www/ArasPhp/core/helpers/Session.php on line 16 Warning: mysql_pconnect() [function.mysql-pconnect]: Access denied for user 'ComplaintMater'@'localhost' (using password: YES) in /var/www/ArasPhp/core/libs/Core.php on line 37 Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'www-data'@'localhost' (using password: NO) in /var/www/ArasPhp/core/libs/Core.php on line 38 Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /var/www/ArasPhp/core/libs/Core.php on line 38 I would like to test the connection without letting php throw all that...like a silent way and just getting a boolean value. Ideas? Thanks!
  21. Hi =) Is there any way to TEST wether a MySql connection is going to work? Without using mysql_connect that can throw an error? Just to display on the web..."The connection is working" or "The connection is not working" Thanks!
  22. Thanks! I've been reading it so far and I haven't figured out the way it might help me =( Usually, when we execute a method without all required parameters, we get a warning message displayed in our browser, right? I would like to make that an error and do not displaying the result. Example: class foo { public function whatever($a, $b) { } } So if we try to execute foo::whatever(4,5) it works, but if i try to execute foo::whatever(4) it throws an execution error insted of a warning. Maybe catching the exception like this? try { foo::whatever(4); } catch (Exception $e) { // Code here } Will that work?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.