Jump to content

Goafer

Members
  • Posts

    45
  • Joined

  • Last visited

    Never

Everything posted by Goafer

  1. I'm trying to declare all my font properties in one declaration, but when I do, the font-variant property stops working. Is this normal? This works: font-variant: small-caps; font-weight: bold; This doesn't: font: bold small-caps; Thanks in advance.
  2. This looks fantastic. I'm a big fan of the 'achievements' list, and I wouldn't worry about the sytling, it all looks brilliant.
  3. Found the problem: so basically, the previous way, wasn't performing the $row query until after the table had been created and the first row had been populated This new way will run the query first, and then populate accordingly: $table = "<table>"; // begin table while ($row = mysql_fetch_array($query) { $table .= "<tr>"; $table .= "<td>".$row['date']."</td><td>".$row['percent']."</td>"; (date/percent) $table .= "<td>".$total = $total*$row['percent']."</td>"; $table .= "</tr>"; } $table .= "</table>"; This should remove the "cluttering" and make things a bit smoother and when you look back at it, it will be easier to read
  4. $sql = "SELECT date, percent FROM table"; // define query $query = mysql_query($sql) or trigger_error("Error Code"); // perform query $table = "<table>"; // begin table do { // fill in table data $table .= "<tr>"; $table .= "<td>".$row['date']."</td><td>".$row['percent']."</td>"; // fills in the row until each field is entered (date/percent) $table .= "<td>".$total = $total*$row['percent']."</td>"; $table .= "</tr>"; } while ($row = mysql_fetch_array($query); // finish filling in table when $row is finished $table .= "</table>"; // close table return $table; This should just about do the trick. A simple while loop to run through each row of the table and for each row, have the details entered into the table. if $total is defined, then each row it will be multiplied by the new percent. This code was stripped from something I have and edited for your specs, so might need a tiny tweek but i'd say thats about right.
  5. If the query hasnt been performed the above response will launch an error about unset variables so make sure you protect it: value="<?php if(isset($row['first_name'])) { echo $row['first_name']; } ?>" or use: if(!$result) { $row = new array(); } or similar
  6. What can I say? Thank you Salathe, that is a very concise answer which answers my question pretty much perfectly. The main thing for me at the moment is getting all my scripts working, so as long as I know that the code is working with the script and $verify->isEmail($string) is working accordingly then I will leave it as it is for now, using the regex method rather than another approach. Hopefully sometime soon I can take a look at becoming more familar with the regex patterns and be less confused by them, and not have to rely on other peoples work. Although I may then be back on here saying "wtf - why doesn't this work" Many thanks again.
  7. Hey guys, sorry if this is too basic, but regex just confuses me. I have a form validation class, with this function to check for valid emails $pattern ="/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/"; if(preg_match($pattern, $value)) { return true; } is the code used in the function. I didn't make the expression myself, I copied it from elsewhere, can anyone tell me: 1) Is this accurate and complete, will this do the job without any problems (it seems to under testing) 2) Apart from being less lines of code, what advantage/disadvantage is there using this method over other methods I have seen to check for emails, such as explode("@", $string) and then analyzing each section of the string seperately. Many thanks
  8. Basically, its not sorting the records, its sorting the data within the records, so if your id is 1,2,4,5 - then that is ASCENDing in order, whereas if you tell it to DESC then it would be 5,4,2,1. Similarly, in the column 'surname' if you had: Azjol, Bertram, Dexter - that would be ascending in its order Ascending is the default, and will be performed unless you specify otherwise
  9. The first that that i'd point out )not having read the FULL code) is that: session_start(); should come before any use of sessions, including if(isset($_SESSION["id"])), As you can't check to see if sessions are open if the sessions haven't been started...
  10. Okay so I get this error: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\web\CMS\scripts\db.php on line 22 when I use: 16 function queryDB($sql) { 17 return mysql_query($sql) 18 or trigger_error("Unable to perform query on database: ".mysql_error()); 19 } If I leave out the OR trigger... so that the query actually executes, and then pass that into: 21 function fetchArray($query) { 22 return mysql_fetch_array($query, MYSQL_ASSOC) 23 or trigger_error("Unable to return data from database: ".mysql_error()); 24 } it breaks my browser for 30 secs (max runtime) then produces an unending loops of: Notice: Unable to return data from database: in C:\web\CMS\scripts\db.php on line 23 If I leave out the OR trig.... in BOTH functions, it seems to work. *confused* Presumably the un-ending loop of errors in the second case is from: while($row = $this->fetchArray($query)) { It's almost as if PHP is choosing not to do the primary task, but jump straight to the OR which is what i'm not understanding, because the query can and does execute perfectly fine in the absence of the OR
  11. yup, tried that combination, returned the same errors, will look into trigger_error now thanks, Like I said (twice) it's been a while so a lot if the stuff I knew i've forgotten and even what I knew then wasn't great lol
  12. <form> </form> Is this required?
  13. Sorry, just to add, the server is: Apache 2.2.11 PHP 5.3.0 MySQL 5.1.36 If that helps at all (any known bugs etc (I couldn't find any))
  14. Hey guys, please bear with me if any of this is obvious/stupid, it's been a while since i've done any coding. I agreed to write a small website for a friend and have been working on a very basic CMS to kick start the project using classes. When I use the following code nothing seems to happen (yes i am connected to the database with no problems) function queryDB($sql) { return mysql_query($sql) or die("Unable to perform query on database: ".mysql_error()); } accessed using $query = $this->queryDB($sql). if I try and parse this query forwards using: mysql_fetch_array($query); It returns an error saying the expected statement for mysql_fetch_array is boolean and cannot be processed. so I spent ages trying to figure out what on earth was going wrong to make it boolean. Turns out that if I remove: or die("Unable to perform query on database: ".mysql_error()) it starts working fine. Can anyone shed any light on why this is happening? Presumably if there is no error with the query the "OR die" shouldn't be doing anything and therefore should not be giving a boolean argument, but the problem seems to be stemming from the OR DIE section of the code. I have the same issue with the mysql_fetch_array argument, if I include an OR DIE, it does naff all, but if I leave it out it returns my array just fine... Any explanations much appreciated. *edit* Furthermore, when I use this: function queryDB($sql) { return mysql_query($sql) or die("Unable to perform query on database: ".mysql_error()); } it works okay, BUT if I use this: function fetchArray($query) { return mysql_fetch_array($query, MYSQL_ASSOC) or die("Unable to return data from database: ".mysql_error()); } it still won't do anything, I have to take out the or die completely for this statement to work. Like I said, it's been a while so maybe i'm missing something obvious but any knowledge shared would be great.
  15. umm, the php has been closed mid-loop, is that really allowed?
  16. Personally I find Notepad++ OK, decent text-editor that can handle various languages ie html/php/javascript and doesn't limit you to 1 undo like Notepad. Also you can carry on undo'ing even once you reach the last save point.
  17. As mentioned above, I always find I end up with one,re-gardeless of whether I start with it or not. They are useful for styling, and even if you decide not to really make anything of it, there's no harm leaving it in.
  18. you can't with HTML, that is PHP or another programming language as pointed out before. Hence i'd suggest taking this question to the PHP help rather than HTML
  19. well depends how many ppl you want to be able to login. If it's just for 1-2 admin users or something you can easily store the correct username/password in a php file: <?php $user = "some"; $pass = md5("thing"); ?> or similar and the access file fopen()/include(). If it's for more people you could store in an xml file maybe and access with AJAX?
  20. it's IE 7. I originally did use ' as I thought that was OK, however Google Chrome didn't recognise the ' and put in it's own little symbol for "what the hell is that" so I started using ' to overcome the situation before finding out that IE doesn't support ' So now i've got &#39; which seems to work in IE & Chrome & Firefox. I think it's just that Google have thrown things off a bit with the new browser. In answer to your question: yes, it's an XHTML document using standard charset iso-8859-1
  21. I take it all back, it works fine after all, very simple typo - feel free to delete mods...
  22. OK so this should be pretty easy but for some reason I can't get it working: The idea is that when the user clicks on a link, it changes the display property of a <div> from 'none' to 'block' and vice versa. <script type="text/javascript"> function toggleDisplay() { if (document.getElementById("test").style.display == "none") { document.getElementById("test").style.display = "block"; } else { document.getElementById("test").style.display = "none"; } } </script> That's the javascript. <span onclick="toggleDisplay()">click here</span> Thats the HTML. The problem is: nothing is happening, at all. In IE it says "error on page" in the bar at the bottom when you click, but other than that, no clues as to why it won't work... Any help appreciated. I've also tried using: <input type="button" onclick="toggleDisplay()" value="Display" /> - stolen from w3schools.com which didn't work, as well as: <a href="javascript:toggleDisplay()">Click Here</a> which I found in some old code, but no luck with those either.
  23. Wouldn't if just be easier to use: echo "<input type="text" name="ausername" maxlength="12" size=30 bgcolor= "#FA1B00" value="<?=$_POST['ausername']?>"; rather than introducing inline styles?
  24. I think this is the problem: Since you've included the scrollbar properties in the body {} section, those properties apply themselves to the browser bars. To change the scrollbars within your content you need to put them in .center #content {}. Also: I'd have thought that instead of using the overflow:hidden property in the .center/.center #content sections, you could use height:auto;
×
×
  • 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.