Jump to content

maxudaskin

Members
  • Posts

    628
  • Joined

  • Last visited

Everything posted by maxudaskin

  1. There's number one. Before we continue, let's check out the empty($var) function. It returns true or false, based on the argument passed to it. Notice: Undefined variable: uploadedfile in xxx/index.php on line 9 9| if ($uploadedfile){ You have yet to define this variable. I assume you want to check if it is true? Use !empty(). if(!empty($uploadedfile) { Notice: Undefined variable: backgroundcolor in xxx/index.php on line 18 18| if ($backgroundcolor && $width && $height){ Again, you have not defined the variable. Use empty(). if(!empty($backgroundcolor) && !empty($width) && !empty($height)) { Notice: Undefined variable: backgroundimage in xxx/index.php on line 21 I refuse to go on about this. Notice: Undefined variable: currentimage in xxx/index.php on line 23 Notice: Undefined variable: info in xxx/index.php on line 76 Notice: Undefined variable: info in xxx/index.php on line 82 Notice: Undefined variable: info in xxx/index.php on line 89 Notice: Undefined variable: info in xxx/index.php on line 95 Voeg plaatje in... Notice: Undefined variable: info in xxx/index.php on line 102 Notice: Undefined variable: info in xxx/index.php on line 108 ---- Every single error you have is the exact same. Read up on empty().
  2. Since I'm short on time, I'll help you with one of the errors. Take the lead after this, go through your code, and ask yourself where it could go wrong. Notice: Undefined variable: img_dir in xxx/index.php on line 7 7| if (!$img_dir) $img_dir = IMG_DIR; $img_dir was never instantiated. Your code says, "if $img_dir is not true, set it to IMG_DIR." Because $img_dir never existed, the server is says, "Hey! I'm supposed to check this variable, $img_dir, but it doesn't exist." To fix it, ask if it's empty, or isset. if(empty($img_dir) $img_dir = IMG_DIR; You can shorten it into a variable declaration, if you'd like. $img_dir = empty($img_dir) ? IMG_DIR : $img_dir; That last one says, $img_dir equals, if $img_dir is empty, IMG_DIR, otherwise, $img_dir
  3. Why use a foreach instead of using preg_replace?
  4. This is the file: |Hello world from test.txt When you use fwrite, it moves the pointer from the beginning of the file, to the end. Hello world from test.txt| It then writes the string to the file, leaving the pointer at the end. Hello world from test.txtt| Hello world from test.txtte| Hello world from test.txttes| Hello world from test.txttest| To bring it back to the start, use rewind()
  5. Wait. I'm an idiot. There is good reason for why it does not read as you expected. When you write test to the file, it puts the pointer after the appended text. That means that it will output the EOF (end of file). Either reset the pointer, or use file().
  6. Disregard Try this and tell us what happens. <?php $file_name = 'test.txt'; $file = fopen($file_name, 'r+') or die ('File, "' . $file_name . '", was not found.'); $append = 'test'; fwrite($file, $append); $file_read = fread($file, filesize($file_name)); // Read a certain amount of bytes from the file (in this case, the entire file) $file_get_all = file($file_name); // Read the entire file into an array. Each line is has it's own key. print_r($file_read); echo '<br />---<br /><pre>'; print_r($file_get_all); echo '</pre>';
  7. http://www.php.net/manual/en/function.fopen.php If you read down to what the different modes are, you'll understand why. r Open for reading only; place the file pointer at the beginning of the file. w+ Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it. Use r+ r+ Open for reading and writing; place the file pointer at the beginning of the file.
  8. Here is the setup I would use. You should relate the fields, but it is just as good either way. == Users == Name | Type | Comments ==================================== id | int | The unique id for the user. Auto-increment ------------------------------------ username | varchar | The username ------------------------------------ What ever other fields you want... == Messages == Name | Type | Comments ==================================== id | int | The unique id for the message. Auto-increment ------------------------------------ users_id | int | The id relating to the user whose inbox | | this message will reside. ------------------------------------ sender | int | The id of the sending user. ------------------------------------ message | longtext | The message. ------------------------------------ type | int | The type of message it is. ------------------------------------ status | int | The status of the message The users id will correlate to the user that received the message. The sender id will correlate to the user that sent the message. You can use hard coded negative id's to indicate certain server messages. The message should be rendered safe from sql injection before saving. The type of message is essentially the inbox; less important, regular, more important, spam. The status would indicate whether it's a draft, sent, deleted, or saved. Yes, you should want to keep deleted messages, but make sure that you indicate that you reserve the right to retain any messages sent.
  9. Gah, I guess it's better I switch over now, before I get too far into the script. Thank you --- Also, it worked.
  10. I'm looking to find a a starting and ending phrase and return the text in between. %\{\{items\}\}(.*?)\{\{\/items\}\}% I'm looking for {{items}} and {{/items}}. Anything in between, possibly multiple lines, should be returned ($1?). For some reason, it returns 0 results with the following... <div id="items"> {{items}} <div class="item"> <table> <tr> <td>{{item_number}}</td> <td class="text_right">{{currency}} {{item_extension}}</td> </tr> <tr> <td colspan="2">{{item_units}} at {{item_cost_per_unit}}</td> </tr> </table> {{item_description}} </div> {{/items}} </div>
  11. There are multiple ways to do this. Link to another page with full article Load entire article, truncate the data to a small blurb, and have the rest of the data in a seperate, non-visible div. Use javascript to make it visible when needed. Get truncated data, use AJAX to retrieve full data when wanted.
  12. The header() function must be called before the <head> section of the HTML is echoed. Make your PHP code run first, then output HTML.
  13. http://php.net/manual/en/language.operators.comparison.php
  14. Hi guys, I'm just working on a script to get menu items from a database, sorted by a sort column. Each item needs to be checked to see if it has a parent, then paired with the parent. Would it be best to get all of the items at once and pair them with PHP, or get the children of each item when as a separate array? id label link parent sort 1 Home index.php 0 10 2 About about.php 0 20 3 Contact Us contact.php 2 10
  15. I have this snippit of code to get the CSS from the public folder (rather than the framework folder), but Chrome is making it all too complicated. <link rel="stylesheet" type="text/css" href="{$base}assets/css/style.css" title="style" /> The template system changes {$base} to http://localhost/fuel/public/ but the source comes out as <link rel="stylesheet" type="text/css" href="C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\fuel\fuel\app\rain/tpl/http://localhost/fuel/public/assets/css/style.css" title="style" /> Does anyone have any ideas why this may happen?
  16. The server must be running as I can access it through the host's PHPMyAdmin. I am using all of the information that the host gave me but I am having no luck. The host is Netfirms.
  17. What are some possible causes of the error below? An error has occured in 'mysql.php'. MySQL Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
  18. Just set up a project that interests you, and complete it. When you have troubles, google works, and so does the PHPFreaks.com forums.
  19. Sorry, I'm not sure I understand. Let's say I have a database with 30 fields and I need them all for the page. How does typing them out less resource intensive then using SELECT *? If you need every single one of them, then it's better to use the asterisk. Otherwise, the amount of effort it takes the computer to parse the SQL is less than searching through the database, finding multiple rows, parsing those rows into a result, then php having to put all of those extra columns that you don'r need into the array, and then you just dump the array. It's better to use CPU power than RAM.
  20. +1. Take a look at this article and give the dynamic salt a try.
  21. Out of curiosity, what's wrong with using SELECT *? Of course if you only need a couple fields from the database it's more efficient to list out the columns, but if you need all the columns shouldn't you use SELECT *? It necessarily uses resources that can be used elsewhere. It's like flooring the gas pedal to get to 40kmh (15mph?). It's just not a smart thing to do, but it will still get you where you want to go in seemingly the same amount of time. I do understand that, but at the same time, it's great for inexperienced users to learn the basics of coding. Once you are getting into more complex ideas, the first place I check is the PHPFreaks Tutorials section.
  22. It's not too wordy... detail is good when you want help. Check out preg_replace.
  23. I see that you have changed the look again, even if it's a downloaded template... A few questions... Why would you want a hover pseudo function for your header? Did you know that the hover pseudo doesn't work in IE before 6? Why are you using classes for things such as the header? You should use ids. (.header vs #header and <div class="header"> vs <div id="header"> respectively). The id tag with CSS can only be used on one object in a page.
×
×
  • 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.