Jump to content

Axeia

Members
  • Posts

    717
  • Joined

  • Last visited

    Never

Everything posted by Axeia

  1. After wasting hours on this I found the cause. The SQLite database I'm using makes use of foreign keys. The host is running version 3.3.7 of SQLite which does not support foreign keys and isn't compatible with databases containing these it seems. Found out by recreating the entire database using PDO statements, downloading the database and then finding out tables with foreign keys aren't created.
  2. Thinking it might be a problem due to different versions of the SQLite library I tried deleting the database both on the host and locally. Similiar result, locally I get a PDOStatement with the original query but on the host this does not happen although the database is created just fine.
  3. Hello, I'm using PDO to connect to a SQLite database. Locally under wamp everything runs fine, on my testserver running openSUSE 11.4 / apache / php5 everything is running fine as well. On my host however it doesn't seem to work at all, and I'm not getting any useful information from PHP either. I'm using the code below in the __construct of my database class. $dbLoc = dirname(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'external_access_denied'.DIRECTORY_SEPARATOR.'ic.db3'; try { $this->db = new PDO('sqlite:'.$dbLoc); echo '<pre>!'.print_r($this->db,true).'</pre>'; $prep = $this->db->query('SELECT name FROM sqlite_master'); echo '<pre>!'.print_r($prep).'</pre>'; echo $prep instanceof PDOStatement.'<br/>'; echo '<pre>!'.print_r($prep->fetchAll()).'</pre>'; } catch( PDOException $e ) { echo 'a----'; Util::logError(__FILE__, __LINE__, $e->getMessage()); } catch( Exception $e ) { echo 'b----'; Util::logError(__FILE__, __LINE__, $e->getMessage()); } The output I get on my host: !PDO Object ( ) !1 Fatal error: Call to a member function fetchAll() on a non-object in*snip*ncludes/classes/Database.class.php on line 42 line 42 is "echo '<pre>!'.print_r($prep->fetchAll()).'</pre>';" from the code example. Locally I get !PDO Object ( ) PDOStatement Object ( [queryString] => SELECT name FROM sqlite_master ) !1 1 followed by a long array with the query results. -- So what is going wrong? I'm not getting PDOStatement object on the host even the PDO object is there. instanceof seems to think it's a PDOStatement, but print_r thinks different. If anyone could shine a light on this I'd be impressed.. rather flabbergasted myself.
  4. Absolute positioning should be avoided where possible, not as big a no-go as using tables for layout but pretty close. Centering content is as simple as doing something like <div style="width: 700px; margin: 0 auto;"></div> So a fixed width, and margin: 0 auto (applied on a block element such as a div). Your labels aren't asociated with the input elements, how to do this can be found on the w3 site (a label has a for attribute pointing to the name/id of an input element). Is the contact form and the image next to it supposed to be behind the border of the site itself (Using Firefox 4.0.1)? Also, the second paragraph on the site fall behind the images. You should wrap those images used as a heading in a heading tag (h1-h6) so Google and screenreaders know it's a heading, good job at giving them an alt tag with more or less the same text though! --- Your google 'speed rating' could have gone down because connections are expensive, every seperate file on the site needs to set up a connection (all images, all external javascript/css files). So one big image (filesize) wise can be faster to load than 3 seperate smaller ones. So indeed CSS sprites would be adviseable. You could do something similar for the javascript, combined everything except for jquery itself in one big file. I see you're including all the javascript in the <head> section while it all seems to be unobtrusive jquery based, try moving it to just before </body> tag so it loads after the rest loads, this way the stuff the browser needs to render the page loads up first and the page will be faster to load. Another thing that's as big a no-go as using tables for layout is using <font> tags, and you're using them. You should use a <span class="x"></span> tag instead and do all coloring/font-family usage etc in the stylesheet. I guess you're working on it atm as none of the javascript is working and my firebug console shows more than one error. Good luck with the site, I do like the looks.
  5. Headings are used properly which is nice to see, some other things could use improvement though. http://www.indigo-self-assessment.co.uk/Who-completes-a-tax-return.html alt="book_image", if the image doesn't convey information but is just there for decoration leave the alt tag blank. http://www.indigo-self-assessment.co.uk/Instant-Quote.html The form relies on javascript, you should never rely on javascript if it can be avoided, poses accesibility problems. Moving the javascript to an external file would also be a good idea. Another thing I noticed is that this form lacks labels, if you something like the code below most browsers will make a click on the label select the radiobutton in it. <label><input type="radio">Yes</label> On the refer a friend page you did use labels for the text inputs, but not in a way that makes sense. You have: <tr> <td height="40" bgcolor="#9F7DCE" class="Quotation" style="padding:2px 6px 2px 6px;">Please provide your Name</td> <td valign="middle" bgcolor="#D5D5D5" align="center"><label> <input type="text" id="name" name="name"> </label></td> </tr> While it should be: <tr> <td height="40" bgcolor="#9F7DCE" class="Quotation" style="padding:2px 6px 2px 6px;"><label for="name">Please provide your Name</label></td> <td valign="middle" bgcolor="#D5D5D5" align="center"> <input type="text" id="name" name="name"> </td> </tr> These tables are pretty bad btw, tons of bgcolor tags and inline styling.. you oughta move that to a stylesheet and redo these tables by hand as the code seems to be spit out by some program that isn't doing a very good job at it. http://www.indigo-self-assessment.co.uk/Our-Process.html You really should use a ordered list here instead of divs, divs don't mean anything while a list means there is a relation. Since there is a order to things it makes sense to use an ordered list. I guess the captcha on the contact page is a placeholder? Static link and no text on it.
  6. Since you're listing Linux alternatives you may want to consider showing for which one of the major desktops the application is intended. For example when I search for "msn" it returns: Pidgin, Empathy, Kopete and aMSN. Chances are that if I'm using the Gnome desktop I'd be interested in both Pidgin and Empathy but wouldn't like Kopete much. It would also be nice if the rating was display directly instead of having to click each application to see which is the most popular. (could be that you're sorting by popularity atm, I don't know and neither would anyone else visiting). Quick and dirty mockup below.. icons are far too large though, but it gets the idea across. [attachment deleted by admin]
  7. Axeia

    money type...

    Just look on the bright side, the documentation for the 'money' type reads: "Note: The money type is deprecated. Use numeric or decimal instead, in combination with the to_char function. " So you are now future proof For presenting the output back to the user PHP comes with a money_format function of its own.
  8. an easier way (that takes way less code) would be to wrap what you want to replace in something like <div id="replaceMyContent"><div id="status"></div></div> and then do a <a href="javascript:document.getElementById('replaceMyContent').innerHTML = '<textarea>Hi, Im new</textarea>';">edit</a>
  9. I think it's possible using variable variables . As you may have guessed from the name, they just add to the confusion and are generally considered bad practice. Stick to using $_GET.
  10. Like javascript, PHP is also able to manipulate a page via the DOM. So there is existing functionality to do the job it does however require well-formed HTML. The documentation page of the removeChild method also has an example of how to load a file. (for HTML use $doc->loadHTML() instead of $doc->load() - XHTML should be loaded as XML)
  11. If you simply want to read out the values, this is the most basic example I can come up with. <?php if( !isset( $_POST['food'] ) ) { echo ' <form action="" method="post"> <label for="food">Which vegatable would you like for dinner?</label> <select name="food[]" MULTIPLE> <option value="carrots">carrots</option> <option value="peas">peas</option> </select> <input type="submit" />'; } else { foreach( $_POST['food'] as $veggy ) { echo $veggy."<br/>"; } } ?> [edit] Forgot to explain The magic part is in the name attribute, it has to end on []. PHP automatically creates an array out of form elements whos name ends on [].
  12. Then pass the parameter to do that to the construct or create a method public function setDatabase($db) { $this->_db = $db; } Although if $this->_db is vital for the blogPost class (which I suspect it is) it belongs in the construct. As a few hopefully constructive tips.. tip #1 PHP(5) supports type hinting so this works as well: __construct(database $db) The more strict you can get the better imo. (Als provides more useful errors when you pass in a parameter of the wrong type) tip #2 You may want to stick to the general PHP (and java and probably other programming languages as well) code convention to start classnames with a capital letter, so Database and BlogPost instead of database/blogPost. (this is gonna be a rather late reply.. left this open in a tab for half a day)
  13. 'non selected' data from elements that give an array are lost when submitted. That would be your <select multiple> but also for example <input type='checkbox' value='cows' name='opt[]' /><input type='checkbox' value='sheeps' name='opt[]' /> There is no way getting around this besides either sticking all options in <input type='hidden' /> as well, or by simply using static code (or a query) to retrieve the information like you did on the original page. I think HTML5 might offer a solution for this, but too early to use and I'm not even sure if it did.
  14. If you have a recent version of PHP there is the following nice filter_var function available (PHP >= 5.2.0) if( filter_var( $email, FILTER_VALIDATE_EMAIL ) !== false ) And this by the way is like saying "Please hack me". $email=$_POST['email']; $query="SELECT * FROM mailing_list WHERE email='$email'"; $query="INSERT INTO mailing_list VALUES ('','$email')"; $_POST = user data = used directly in a query = you're going to get hacked. Please read up on SQL Injection. In short, if you don't get data from a trusted source use mysql_real_escape() .. or be paranoid and always used mysql_real_escape(), as the saying goes, Better safe than sorry!
  15. [Edit] Ignore me, guess you're using some class with the escape method as you're using it in your own example as well. I'd be somewhat amazed if that worked for you. 'escape' isn't a method of the PDO class. (I assume $db = new PDO is somewhere in your code) If you're getting an error about that, use $db->quote instead. Although as stated on the page mentioned above you're probably better off using a prepared statement.
  16. PHP has build in email validating since 5.2.0 filter_var. if(filter_var('bob@example.com', FILTER_VALIDATE_EMAIL) !== false) { //some valid email adress logic }
  17. echo JSON_ENCODE( array('key' => 'value', 'anotherkey' => 'with a value') ); //echos as On the PHP side you don't really need more than JSON_Encode.
  18. Multiple images = Multiple connections = Slower loading page. Don't. Either use CSS sprites or the <map> element .
  19. There is no standard <blink> tag It's not part of any of the HTML standards. try <span style="text-decoration: blink">You might be able to see me.. every now and then</span>
  20. Ladies and gentlemen, we have a winner. Very peculiar, would have never found that, thanks Did move on to PostgreSQL now though due to this and some other reasons.. where it was as simple as ALTER TABLE AnimeSeries ADD CONSTRAINT chk_prevent_incorrect_date_entries_in_series CHECK( air_start_date IS NULL AND air_end_date IS NOT NULL OR air_end_date < air_start_date ) [edit] Perhaps not so strange as it is mentioned in the manual. So basically they're deviating from the standard
  21. The if can't be simplified. It should prevent the insertion of an end date while no begin date is known. And it should prevent the insertion of an end date that begins before a start date. (or disallow start dates that begin after the end date depending on how you look at it). I tried removing the ';' tried adding the thing on different places, tried copy/pasting a working trigger to adept it so it fits my needs but nothing works and I'm not seeing the syntax problem with this one. If only MySQL supported check constraints..
  22. Don't have much time so I'll keep it brief. The "The #1 Award winning domain naming service!" at the topright looks too bland, make #fff and bold so it grabs the attention. Also make it a link as just saying you're number 1 without backing it up adds nothing of value. Use a <ol> for the 1,2, 3 at the bottom. (You might want avoid using profit as the last step as well as you're just the "???" step short of a certain meme, which may leave a wrong impression and actually costs you customers..) NEVER EVER use <center> it's been deprecated for a decade, A DECADE! Use <label>s for forms
  23. Why not send all suggestions at once? <?php //Change the usr_username to reflect you database structure. $query = sprintf( 'SELECT usr_username as usercount FROM core_users WHERE usr_username = "%s" OR usr_username = "%s" OR usr_username "%s" ORDER BY LENGTH( username ) DESC', mysql_real_escape_string( $usr_firstName.'_'.$usr_lastName ), mysql_real_escape_string( $usr_firstName.'_'.$usr_lastName.'2' ), //Add a '2' on the end mysql_real_escape_string( $usr_firstName.'_'.$usr_lastName.date(Y) ), // Add the 4 digit current year on the end mysql_real_escape_string( $usr_firstName.'_'.$usr_lastName.date(U) ) //add the UNIX time code on the end (always will be unique) ); $result = mysql_query($query); if (!$result) echo 'Sorry the username and all generated suggestions are taken.'; $usr_username = mysql_result($result, 0); 1 Query to execute. Next time don't forget the document for mysql_query. This bit in particular is of importance:
  24. Fairly simply question, how to prevent the insertion of a beginning date that starts before its end? CREATE TRIGGER trg_Series_prevent_invalid_end_date BEFORE INSERT ON Series FOR EACH ROW BEGIN IF(NEW.air_end_date < NEW.end_air_start_date OR NEW.air_start_date IS NULL AND NEW.air_end_date IS NOT NULL ) THEN INSERT INTO EpisodeReleaseDate VALUES( 'xxx', 'xxx', 'xxx' ); --RaiseError (MySQL doesn't support raise error) END IF; END$$ #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 6 The EpisodeReleaseDate table consist out of 3 fields, of which the first one is an INT, so inserting a string should throw some error.. which seems to be way how you're supposed to raise an error in MySQL till v6 is out Starting to think it would be the trouble to simply migrate to PostgreSQL.. but was just getting the hang of MySQL workbench
  25. Layout/Design are fine, although you're losing out on data by placing the text on http://www.signworldgroup.com/al/media/images/topnav.png might want to get rid of the text on the image, and place is as some <h2>'s on the site itself. Or I suppose you could try to get creative with an imagemap... but the used font doesn't seem to be too spectacular so I'd go with using actual text, garantueed to reduce the size of the image and enhance accessbility. (and even make changes easier) Why isn't the target (href) of the link on top simply to contact-us.html? That what it works without javascript instead of doing nothing. http://www.signworldgroup.com/al/media/web-design-calculator.html <- that seems like a good place to use the <fieldset> / <legend> combination. On the same page, why state "Note: To email us, please use the enquiry form." but not use the "enquiry form" text to actually link to it? (.com as opposed to a .co.uk domain led me to believe it was intended for an international market)
×
×
  • 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.