Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Everything posted by wildteen88

  1. Not sure if thats was a typo but mysql runs on port 3306 Alternatively you can set the default port mysql_connect uses within the php.ini
  2. From my testing it appears to be caused by the line-height set in ul#navigation li setting it to 2.3em or lower removes the space.
  3. Make sure the extension has been loaded by running phpinfo() - scroll down the page and look for a PostrGreSQL subheadng. Also ensure the extension you have downloaded is of the same build as the version of PHP you have installed. Extensions for PHP5.2.5 will not work with PHP5.2.6. I'd recommend you go to php.net and downloaded the zipped binaries package, extract the contents of the zip over your existing installation.
  4. Remembers arrays start at 0 not 1. PHP has a number of functions on text manipulation. What are you trying to find and replace? Can you give an example.
  5. Do: $file = file('http://server/dir/file.xml'); echo $file[48]; // line 49 file() returns an array of each line in the file.
  6. How are running the script? I understand its a template but how is this script invoked? There is nothing wrong with the script you have attached. PHP5 is backwards compatible with PHP4 code. That script will not output anything as its not being told to output anything. All it does is send an email.
  7. getimagesize returns an array which holds the width and height of the image referenced, eg echo '<pre>' . print_r(getimagesize('path/to/image.jpg'), true) . '</pre>';
  8. Because they both do two completely different things. My post got delayed as the page just kept loading and loading. I get this sometimes with my ISP.
  9. You can check to see if the query returned any rows (results) using mysql_num_rows
  10. EDIT: Damn my ISP! The problem with people using isset() is that don't understand how it works, Most think it works the same as empty() which is not true. Both do two completely different actions. isset - checks to see whether a variable is actually defined. It does not check to see if the variable has a value. empty - on the other hand does the opposite. As it assumes the variable does in fact exist and checks that the variable doesn't have a value. So lets go in to the scenarios I posted above. The following is the correct way: if(isset($_POST['var'])) { $var = $_POST['var']; // continue } Here we use isset, which tells PHP does the variable $_POST['var'] actually exist? If it does assign the variable $var the value of $_POST['var']; PHP now knows what to do here. No issues there. Where as if($_POST['var']) or if(empty($_POST['var'])) tells PHP does $_POST['var'] have some form of value. If it does assign $var the value of $_POST['var']; There is one important step missing here, which is to see if the variable exists first. Think of the above in a real-life situation. You live on your own and you're going out. Before going out you'll check you've got your house key on you so you can lock the door when you leave. You're not going to walk straight out the door and try to look the door with no key!
  11. Not really, the difference will be very slight. However before using user defined variables (_GET, _POST, _COOKIE etc) you should check to see if they exist first, eg if(isset($_POST['var'])) { $var = $_POST['var']; // continue } Doing the following is not the same if($_POST['var']) { $var = $_POST['var']; // continue } // nor is $var = $_POST['var']; if(isset($var)) { // continue }
  12. You should also ensure your HTML/CSS always validates too. Plus when working with CSS always apply default margin/padding for elements (event if they dont need it) as different browsers apply different types of margin/padding to elements. This will then ensure every browser will apply the padding/margin you state rather than the browser use its defaults.
  13. eregi_replace should still be able to take an array.
  14. no it means there is a problem with the result resource returned from mysql_query. This normally means you have an error in your query. Whenever you come across such an error always add 'or die(mysql_error())' after your call to mysql_query eg $result = mysql_query($query) or die(mysql_error()); If there is a problem with your query an error message from MySQL will be displayed.
  15. swap eregi_replace with str_replace no point in using eregi replace if you not using regex.
  16. You'll need to define the variables $photo, $name within your second while loop, otherwise the data used from the first loop will be used and thus you get the same results repeated over and over. chnage while ($row = mysql_fetch_array ($result)) { $staffid=$row['staffid']; if($photo == NULL) to while ($row = mysql_fetch_array ($result)) { $staffid = $row['staffid']; $photo = $row['photo']; $name = $row['name'] if($photo == NULL) As for why your images are not displaying change any instance of if($photo == NULL) to if(!empty($photo))
  17. This is explained in the FAQ/Code Snippet Repository
  18. Are you installing two instances of XAMPP so you can run two websites from one computer? If this is the case then you only need to install XAMPP once, then you just need to setup Virtual Hosts within Apache's httpd.conf file which will allow you to do something like http://sitenamehere.localhost/ or http://myfakedomain.com/ etc. Anyway to answer the question you will need to setup the second instance of XAMPP to run on a different port than the first instance, such as 8080.
  19. There could be an exploit within your code somewhere which is allowing the attacker to inject the HTML
  20. OK now I understand your problem. Change echo '<a href="?id='.$row['id'].'">'.$row['title'].'</a><br />'; to echo '<a href="'.$_SERVER['REQUEST_URI'].'&id='.$row['id'].'">'.$row['title'].'</a><br />';
  21. You should all place all HTML within a string. PHP does not understand HTML. echo "\n".' <tr bgcolor="'. $color .'"> <td><a href="#">'.$row['title'].'</a></td> </tr>';
  22. The code above checks to see if the remainder is equal to 0. the modulus operater (%) returns the remainder. Set a condition in your select statement: $sql = "Select * from forumtutorial_posts WHERE lastrepliedto != 0 ORDER BY lastrepliedto DESC LIMIT 10";
  23. Add mysql_error() in your die statement $result = mysql_query($sql, $cxn) or die ("Query died: ". mysql_error()); //line 145
  24. $REMOTE_ADDR should be $_SERVER['REMOTE_ADDR']
  25. remove the comma. Just separate each index with a space
×
×
  • 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.