Jump to content

Goafer

Members
  • Posts

    45
  • Joined

  • Last visited

    Never

About Goafer

  • Birthday 08/10/1987

Profile Information

  • Gender
    Male
  • Location
    Cardiff, UK

Goafer's Achievements

Newbie

Newbie (1/5)

0

Reputation

  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.
×
×
  • 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.