Jump to content

phil88

Members
  • Posts

    111
  • Joined

  • Last visited

    Never

Everything posted by phil88

  1. Made no difference unfortunately Thanks anyway.
  2. I have a simple javascript function that will clear the contents of a input box and change the colour of the text from grey to black, it's called when the input box is clicked. It works 100% as intended in Firefox, Opera and Chrome, but in IE, the contents of the input box is cleared, as it should be, but the text remains grey. Also, if I click off of the text box, then back into it, it gets cleared again - this doesn't happen in the other browsers. Here's my code; function clearBox(id){ document.getElementById(id).setAttribute('value',''); document.getElementById(id).setAttribute('style','color: #000;'); } Can anybody shed some light as to what's going wrong? It makes sense that every time it's clicked the box is cleared, but none of the other browsers do that, which is a good thing.
  3. Ok, I've got a new problem now, which I can't seem to figure out. Firefox 3, Safari and Opera all display it fine (right of screenshot), but internet explorer (left of screenshot) doesn't. Here's the CSS for the footer bit; #footer-container{ width: 75%; margin: 0 auto; } #footer-left{ float:left; width: 9px; height: 20px; background-image: url('images/footer-left.gif'); } #footer-right{ float:right; width: 9px; height: 20px; background-image: url('images/footer-right.gif'); } #footer-middle{ width: 100%; background-image: url('images/footer-mid.gif'); height: 20px; } And here's the HTML; <div id='footer-container'> <div id='footer-left'></div> <div id='footer-right'></div> <div id='footer-middle'></div> </div> Any ideas what is causing that? The CSS is pretty much the same as I used for the navigation bar, and that works fine in IE. Thanks!
  4. I managed to get it working; <div id='nav-left'></div> <div id='nav-right'></div>** <div id='nav-mid'><a href='#'>Links here</a></div>** and; #nav-left{ float: left; background-image: url('images/nav-bg-left.gif'); min-width: 11px; height: 24px; } #nav-mid{ margin: 0 11px; background-image: url('images/nav-bg-mid.gif'); height: 24px; line-height: 24px; } #nav-right{ float: right; background-image: url('images/nav-bg-right.gif'); width: 11px; height: 24px; } ** If I swap these 2 lines around (to a more logical order), the right-hand div drops down a line, which is bizzare, but having them that way ^^ around fixed it for some weird reason :\
  5. Thanks for the help, I thought margin: 0 auto; meant that you want 0 margin on the top and bottom, but the left and right to be auto? I set a width in #navigation like you said, and you're right, it did center it. As for the divs stacking on top of each other like that, why doesn't display: inline fix that? Or is that used for something else? I'm not sure how your CSS would work as nothing in the HTML uses the classes link1, link2 etc. Are each of those meant to be for each individual link? They're only text links so would it be better if they were just using one class? Also, where you say CAP1 and CAP2, are they meant to be the images for each side of the navigation (the light blue and the yellow in my picture)?
  6. I'm trying to create a simple horizontal navigation menu where it has a left image, the middle bit (with the links in it) and a right image, like; Where the light blue, green and yellow represent the navigation bar parts. Here's the code I have at the moment; #navigation { margin: 0 auto; } #nav-left{ background-image: url('images/nav-bg-left.gif'); width: 11px; height: 24px; } #nav-mid{ background-image: url('images/nav-bg-mid.gif'); height: 24px; width: 140px; } #nav-right{ background-image: url('images/nav-bg-right.gif'); width: 11px; height: 24px; } And the HTML <div id='navigation'> <div id='nav-left'></div> <div id='nav-mid'> <a href='#'>Links</a> | <a href='#'>will</a> | <a href='#'>go Here</a> </div> <div id='nav-right'></div> </div> Currently it just displays each of the 3 parts below each other, and it doesn't center it either despite having margin: 0 auto; in the #navigation CSS. What am I doing wrong?
  7. That's exactly what I needed. Thanks a lot.
  8. First time I've ever used mod_rewrite, but I would quite like to use it for this website I'm making. I have 1 file that controls the entire website, index.php, it calls on numerous other files to create pages. index.php can be set to different pages like so; index.php?page=home index.php?page=about index.php?page=image etc. If $page=image, then there is another $_GET variable that is used, $id. So this means, the 'image' page is dependant on an extra number like so; index.php?page=image&id=38 What I would like to do is, have www.myurl.com/index/home go to www.myurl.com/index.php?page=home www.myurl.com/index/about go to www.myurl.com/index.php?page=about etc, AND www.myurl.com/index/image/23 go to www.myurl.com/index.php?page=image&id=23 How on earth do you do that with mod_rewrite? I'm assuming that is what you need to do for it to work? It would be even better if you could miss out the /index/ part of the nice URLs altogether if that is possible, so; myurl.com/home would actually be myurl.com/index.php?page=home and myurl.com/image/23 would be myurl.com/index.php?page=image&id=23 If that's possible. Thanks I had a go and came up with; RewriteEngine on RewriteRule ^index/([A-Za-z0-9-]+)/([0-9]+)/?$ index.php?page=$1&id=$2 [L] But that just gave me a "Server error!" error...like I said, this is the first time I've tried mod_rewriting
  9. I have two files, one file (settings.php) that contains all sorts of misc. variables that are to be used by other scripts. The other file contains all the classes that are to be included. //settings.php $db['host'] = "localhost"; $db['username'] = "phil"; $db['password'] = "xxx"; etc. // classes.php include('settings.php'); class database{ function connect(){ mysql_connect($db['host'], $db['username'], $db['password']); } } A simplified example, but it shows the problem I'm having. How can I make it so that the connect method of the database class can access the variables that were included at the top of the file? Eg. the $db array. I've established that moving the include('settings.php'); line to be inside each of the methods that need the data from settings.php will work. But is there a better way so there is only 1 inclusion?
  10. I think you're making things more difficult than they need to be. When I output stuff from a mysql table, I just use regular old HTML tables to do the output, like so, echo "<table><tr><td>Col1</td><td>Col2</td><td>Col3</td></tr>"; //Open the table and display the column titles. $query = mysql_query(" SELECT * FROM whatever WHERE cheese = pie "); while($row = mysql_fetch_assoc($query)){ echo "<tr><td>".$row['col1']."</td><td>".$row['Col2']."</td><td>".$row['Col3']."</td></tr>"; // Output each row each time the loop is looped } echo "</table>"; // Close the table
  11. Instead of; global $inventory; function populate_cart() { Have; function populate_cart() { global $inventory; You'll need to do that for your other functions too.
  12. or, rather than using the die() function, you could write your own function to handle the error. Eg; function error_handler($error){ echo "Formatting, layout etc."; echo $error; die(); } And then just use error_handler("Something bad happened") in your code instead of die() or exit. The whole point of the die() function is to stop executing all code right there and the. If a die() function is executed, the script does just that, it dies. Edit: Forgot to put the die() in the function...without that, it'll output your error and then try to continue executing any code that it hasn't executed yet.
  13. The only way to do that would be to hack the ftp server (or some other server might be able to give you access) or if apache/php wasn't set up correctly. Get him to prove it.
  14. from the shell; locate php.ini then cd to the location of the file then use vim or nano or whatever text editor you want to edit it.
  15. Chances are, you can't. You'd have to speak to your host and ask them to change it.
  16. To me it does sound like apache needs restarting. Contact your host, or, if you have shell access, try running; apache2ctl restart
  17. Try restarting apache (or whatever server it is you use).
  18. No, I did it a totally different way; function show_posts($id){ $query = mysql_query(" SELECT * FROM `posts` WHERE `parent_id` = '$id'") or die(mysql_error()); while($row = mysql_fetch_assoc($query)){ $parent_id = $row['parent_id']; $query2 = mysql_query(" SELECT * FROM `posts` WHERE `post_id` = '$parent_id' ORDER BY `post_id` DESC") or die(mysql_error()); $row2 = mysql_fetch_array($query2); $reply_string = $row2[2] . " at " . date('h:i A \- m\/d\/y', $row2[5]); # # echo formatted output here # get_roots($row['post_id']); } } Apologies if the variable names aren't particularly meaningful, I was just tinkering with stuff and then it suddenly worked so figured I'd just leave it be
  19. It'll be fine, google won't know you've done it because all google can see is the outputted HTML code - which will be the same if you use a php include to put in the information or if you just write it in a html file.
  20. What do you mean? Like include a file that contains all the HTML info of your keywords/favicon etc?
  21. Basically, I have the following structure in a mysql database for a simple "post & reply" type system; +-------+---------+------+----+ |post_id|parent_id|author|post| +-------+---------+------+----+ So, when someone makes a post, it is added to the database, if it's a root post (not a reply to anything) then it's parent_id will be 0. If the post is a reply to another post, the parent_id will correspond with the post_id of the post that it's replying to. I'm a bit stumped as to how to get the posts out though; here's what I've come out with so far, which doesn't work; function get_child($id){ $query = mysql_query(" SELECT * FROM `posts` WHERE `parent_id` = '$id' ") or die(mysql_error()); while($row = mysql_fetch_assoc($query)){ get_child($row['id']); echo $row['author'] ."-". $row['post'] ."<br/>"; } } I'm thinking recursion is the way forward as there would be potentially an unlimited number of child posts coming from each root post. Any ideas?
  22. if($row = db_fetch_result($result) { Should be; if($row = db_fetch_result($result)) { You just missed off a bracket :)
  23. Depends what you  mean by work? With mysql_select_db(), you can chuck it 2 parameters, the database and the connection to use. So with your code, you could do; $db1 = mysql_connect("Host", "username", "password"); $db1_select = mysql_select_db("DatabaseName", $db1); $db2 = mysql_connect("Host", "username", "password"); $db2_select = mysql_select_db("DatabaseName", $db2); Obviously replacing host, username, password and databasename with the actual data.
  24. Well at the moment I'm not really developing anything specific, just making various scripts and seeing if I can get in using a webbrowser to places I shouldn't. Is mysql_real_escape_string a surefire way of preventing all kinds of mysql injections? Thanks for the tips about session_hash and spam keys, I shall have to read up on them as I've never heard of either of them :p *gets googling* Edit: I just realised I do know what a spam key is, didn't realise that's what it was called though. Edit 2: Is session hashing basically, getting the session ID and something unique to the users computer, like IP address, hashing them together, then storing that hash as a session variable, comparing it with a server-stored copy of that hash for that particular user, if the hashes are different then it's been modified?
  25. Ok, thanks for the help. I shall try and incorporate that into what I already have. I'm still questioning the security of sessions though, so if anyone can explain how secure they are, or point me towards an article or something it would be much appriciated.
×
×
  • 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.