Jump to content

adrianTNT

Members
  • Posts

    146
  • Joined

  • Last visited

Everything posted by adrianTNT

  1. Hello. I have a variable called $comments_per_page that is inside settings.php, ($comments_per_page = 10); Then a main file comments.php that contains: <?php // include settings.php that contains the value of $comments_per_page require settings.php; function some_function(){ // I need to use $comments_per_page here (inside a function) } // I also need to use $comments_per_page here (outside of the function) ?> I dont know how to access and use the variable $comments_per_page when inside or outside of a function, I know about 2 things but I am not sure how to use them: $GLOBALS['comments_per_page']; global $comments_per_page; - Which one of these 2 ^ I need to use inside and outside of a function when accessing and modifying $comments_per_page variable? - When I just have "$comments_per_page = 10" inside settings.php does that mean it was created as a global variable? Thank you. - Adrian.
  2. I don't know if they deserve it, when I have a problem and I ask them they are like: "- Not our problem, you should have paid for assistance service" (assistance is something over $100, few months minimum). But I will send them an email about the typo in their help files. Anyway ... their support is as bad as people said it is, I had more problems with their support staff for different services of theirs. I think they got so big that they ran out of good techies.
  3. Thanks WildTeen88, but the problem was something else, I managed to fix it by changing some system files on the server. From what I understood it didnt allowed me to run scripts in that directory inside the site, it somehow had a predefined directory inside the site where I could run scripts, I edited system files and set that directory to site root then it worked. The host has the solution here: http://help.godaddy.com/article.php?article_id=1619&topic_id=&prog_id=GoDaddy& But I was surprised to see that the instructions ware incorrect, for example that XML syntax ^ doesn't close the XML tags properly in their example so if you try exact same thing will not work. This one worked:
  4. Maybe it helps if I show you my phpinfo(), I was still unable to get rid of the error/warning: http://www.adriantnt.com/index2.php php info is on top and at bottom I am trying to include a file and get the errors I mentioned above.
  5. I see in error is says /settings.php but in script it is: require('settings.php'); Script should be ok because it worked on previous server. Maybe some other settings are wrong? include_path maybe ? phpinfo says include_path is .: Any ideas ?
  6. Hello. When I run a script inside a directory in site I get the error: open_basedir restriction in effect. File(/settings.php) is not within the allowed path(s): (/var/www/vhosts/site.com/httpdocs:/tmp Can I disable this 'restriction' ? I understand it doesn't allow me to include files form that directory, how can I fix this? I did some searching but I am confused :-\
  7. Thank you all, this is the one that worked, I added it to my .htaccess file: php_value display_errors 1
  8. I tried this: <?php // Same as error_reporting(E_ALL); ini_set('error_reporting', E_ALL); ?> <?php $comment_id = "comments_script_page";?> <?php include 'scripts/comments/comments.php';?> It shows a complete blank page, no html code in it. Any ideas?
  9. Hello, I moved to a new server and some of my scripts dont work here. I cannot see what is the problem with the scripts because I see no errors on page even if I try to include an unexistent file for example. I think there is something like this that can be placed in .htaccess? php_value show_errors=true ? Thank you. - Adrian.
  10. Corbin, the plain file is stored as _id_of_item_to_be_rated.dat and there is a .dat file for each item id to be rated. An example of database file woudl be: video1.dat and its contents is like this: 3|68.117.115.182 5|34.117.115.122 that is user's vote (1..5) | user's ip. now maybe the script can do this.... get an array of IDs from the user (items to be rated, e.g video1,video2,video3) and from same directory as the php file read the dat file for each one of them, calculate the average (1 to 5) then print them in the right order, this print will later be the display of the swf file. video1 score 5 video2 score 3 video3 score 1 Do I make sense ?
  11. Yes, that is the best way I see it. Order html code for displaying each swf file; not order all the items inside one main swf file. Right [b]Thatisme?[/b]
  12. Hello. I am not very familiar with mod rewrite. It looks like it can have many options and code inside can get very complex. What I need is only this: display the contents of: site.com[b]/read.php?cat=tutorials[/b] by accessing: site.com[b]/tutorials/[/b] How should the .htaccess look like? Thank you.
  13. The system doesn't use a database. It saves to plain file. Maybe is not such a good idea to use my rating system in this case. Or if you want to use it then easiest way would be to talk to a php developer after you have the rating system so that person can see the code and chose best solution. When a php developer sees the system it should be easy for him to do the additional code that sorts the swf files inside html code. What I had in mind is a php script that orders the html code for displaying each swf file in correct order.
  14. Hello. // I am the one that sells the product. Since I am a flash developer myself (not php developer), the php part of this product was made by someone else so I cannot make such updates that require additional php coding, this is why I suggested to the user that he should ask here about such php modifications. Here are some details about how it words, maybe someone knows how it should be done. The rating system is a swf file that sends and loads data by a php file in background, the flash file sends an id (photo1, photo2) ot the php file and the php file returns the rating score (1..5) and flash file shows the stars (1..5). I think this could be done by adding php script inside the html code of same page, send the id of all items to be rated to the php file and record the answers then display the swf files in the right order according to the answers received. [code]<?php $my_ids = array ('photo1','photo2','photo3'); $my_scores = array (); send the id 'photo1' to the php (by GET I think) and record the answer (score 1..5); send the id 'photo2' to the php (by GET I think) and record the answer (score 1..5); send the id 'photo3' to the php (by GET I think) and record the answer (score 1..5); Display the html code to show all swf files in the order according to the scores received above. ?>[/code] That should be a way to do it but I don't know if is possible without the product code and since is commercial product I cannot post he files for download.
  15. [quote author=effigy link=topic=121560.msg500100#msg500100 date=1168296369] Good programming is not only about "working," but also about using the right tools; optimization. Are you going to rent a moving van to haul a box of books when you have a Pinto sitting in the drive way? They both work (Pinto jokes aside).... I thought php.net used to have a blurb in the preg_replace docs about using str_replace for fixed replaces, but I could be wrong. They do have one about using strpos or strstr instead of preg_match, because it's faster. Perhaps it doesn't matter between preg_replace and str_replace, and in our days of fast machines it may not even be a big deal (depending on the usage), but, hopefully you get my point :) [tt]</ramble>[/tt] [/quote] yes, I think I get your point but I am a PHP biginner and I am not very familiar with most of the functions.
  16. [quote author=effigy link=topic=121560.msg500076#msg500076 date=1168294569] See [url=http://www.phpfreaks.com/forums/index.php/topic,120594.msg496080.html#msg496080]this[/url] post. If you're not using patterns, don't use preg. [/quote] Effigy , why not ? It seems to work. I got rigd of that warning above, I think I had some slashes entered in bad locations. Thank you all for your help. I like this forum :)
  17. ok, I used preg_replace and seems to do what I need but I get an error and I dont understand it: [code]<?php $string = 'visit my site http://www.google.com or www.msn.com or at least yahoo.com'; // $patterns = array('/http://www./','/https://www./','/http/','/www./','/.com/','/.net/','/.org/','/.biz/','/.info/','/:\/\//'); // echo preg_replace($patterns, ' ... ', $string); // ?>[/code] It says: [quote][b]Warning: Unknown modifier '/' in /var/www/vhosts/adriantnt.com/httpdocs/temp.php on line 6 Warning: Unknown modifier '/' in /var/www/vhosts/adriantnt.com/httpdocs/temp.php on line 6[/b] visit my site ... ... ... google ... or ... msn ... or at least yahoo ... [/quote]
  18. I want to replace complete URL if possible but I think is easyer to just replce the "www." and ".com:, ".net" I will have a look at str_replace and preg_replace() and see if I can do anything, if you have other ideas please let me know.
  19. Hello. I have a php 'comments script' that allows users to submit comments on web sites. I want to filter the string that represents the actual comment and remove any existent URLs posted by users. For example replace "www." with "..." or .com .net with "..." something like that. Anyone knows a function, code block, etc for this? Thank you. - Adrian.
  20. The commented area at the end are the ones that display the xml in site but the new xml I want to read has an additional level and I do not know what to modify in order to read that new format. //The php script was made by someone else, I am not good with php.
  21. Hello. I have this php script that displays the contents of an xml file like this: [code] <?xml version="1.0" encoding="iso-8859-1"?> <icons> <ico title="Lino Adium Dock" img="enhancedlabs/lino_adium_dock.png" url="http://www.enhancedlabs.com"/> <ico title="The real Christmas" img="enhancedlabs/2005.png" pc="enhancedlabs/the_ico.zip" url="http://www.enhancedlabs.com"/> <ico title="Mac Mini" img="enhancedlabs/mac_mini.gif" pc="enhancedlabs/mac_mini_icons.zip" url="http://www.enhancedlabs.com"/> </icons> [/code] The script to print the above xml file is like this: [code] <?php class XMLparser{ var $main = array(); var $currentparent = "default"; function XMLparser($inputxmlstring){ $lines = explode("\n",$inputxmlstring); $n = 0; foreach ($lines as $line){ if (trim($line) == "") continue; $line = trim($line); $s_regex = "/<([a-z]+)>/i"; $e_regex = "/<\/([a-z]+)>/i"; $s_matches = null; $e_matches = null; $start = preg_match($s_regex, $line, $s_matches); $end = preg_match($e_regex, $line, $e_matches); if ($s_matches == null && $e_matches == null){ //this is a node $attributes = array(); preg_match_all("/([a-z]+)=\"([^\"]*)\"/i", $line, $attributes); $names = $attributes[1]; $values = $attributes[2]; for ($i = 0; $i < count($names); $i++){ $name = $names[$i]; $value = $values[$i]; $this->main[$this->currentparent][$n][$name] = $value; } $n++; }else if($e_matches == null){ //this is a start $parentname = $s_matches[1]; $this->currentparent = $parentname; $n = 0; } } } } $XML = file_get_contents("icons.xml"); $instance = new XMLparser($XML); $parseddata = $instance->main; //get all the nodes under the "icons" parent /* foreach ($parseddata['icons'] as $node){ echo "Title: " . $node['title']; echo " Source: " . $node['img']; echo " Credits: " . $node['url'] . "<br />"; } */ ?> [/code] [color=red][b]Question is: how should the parser look like in order to parse a new XML file formated like this:[/b][/color] [code]<?xml version="1.0" encoding="iso-8859-1"?> <links> <link> <title>Adrian TNT Flash Design</title> <url>http://www.adriantnt.com</url> <description>Flash menus, buttons and components by Adrian. C.</description> </link> <link> <title>FFILES</title> <url>http://www.ffiles.com</url> <description>Sharing resources and creations.</description> </link> </links> [/code] Thank you. - Adrian.
  22. by the above solutions is it required that the new image be physically saved on server? What should the external script contain (if is a short code block). Thank you.
  23. Hello, I thought it should be something easy but I cannot find a simple sample code for this... I have more images that are saved as 250x250px on server and I need to display them on some page as lower size, e.g 125x125px. I do not need to physically store them at the new size. I thought it should be an easy way like: <img src=" <? GD_resize('my_image.jpg',125,125);?> " width="250" height="187"> But I could not find a sample like this. Is there a way to resize an image like above? Thank you. - Adrian.
  24. [quote author=Jenk link=topic=107362.msg430706#msg430706 date=1157733786] you don't have to, you can 'call upon' them within the function with the global key word.. change to:[code]<?php function get_balance($the_user_id){             global $database_affiliates, $affiliates; mysql_select_db($database_affiliates, $affiliates); ?>[/code] [/quote] Yes, that worked fine, I didn't knew that I have to access them from an upper level when working in a function. I also tried to send them in the function parameters when defining the function and when calling the function, that also worked; but your metod is better. Thank you very much. :)
×
×
  • 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.