Jump to content

ToonMariner

Members
  • Posts

    3,342
  • Joined

  • Last visited

Everything posted by ToonMariner

  1. $_GET['keyword'] is an empty string - that is the only ionstance where the if statement will not error and give the deasfult value of cool jewelry
  2. try using cdata tags around each string of content...
  3. No. The visibility of your methods between classes is nothing to do with security.
  4. it could also relate to the register globals setting - which is probably ON on your old server and OFF (like it should be) on you new server... check the short open tag thing first and if no joy have a look at register globals. try putting $mname = $_GET['mname']; // or $_POST['mname'] or where ever you are getting it from. above that code you posted.. If it then works the register globals is you 'problem' Rather than turn it ON you should go and initialize your variables in EVERY script you have that requires it.
  5. abstract classes cannot be instantiated. The design pattern you are looking for is the registry pattern - simply make all your methods static so they can be called without an instance of the class being created - although this will achieve the same as having a bunch of helper functions but may incur a little more overhead.
  6. printing from a browser will always ignore background images... If you think about it - printing a page out you are getting a hard copy of the information; that doesn't require any design aspect to it. Use a print sty;le sheet to layout a page so its more easily read on printing but don't try and print out a hi fidelity copy of your design - thats not what you need when reading something... The alternative as roopert says is to create a pdf which, if you MUST have the design aspect, will be the better option.
  7. there is the nastyness of eval(); if you are storing this string in a text file then perhaps consider using json_encode and json_decode to help you out.
  8. save your self a query!!!! check the format 1st - if its OK THEN do the query... If you are using the php >= 5.2 the you could do this... ?php // This is a sample code in case you wish to check the userID from a mysql db table include('library/login.php'); login(); mysql_select_db('test'); $email = isset($_POST['email']) ? $_POST['email'] : NULL; if ( !is_null ( $email ) ) { if (!filter_var($email, FILTER_VALIDATE_EMAIL))) { echo "<font color=red> Invalid email</font> \n"; } else { $sql_check = mysql_query("select email from user where email='".$email."'") or die(mysql_error()); if (mysql_num_rows($sql_check)) { echo "<font color='red'>The e-mail ".$email." is already in use.</font> \n"; } else { echo "OK"; } } } ?>
  9. search your code for it - it could be set in code that is included - so search you entire project for that array and see what it throws out.
  10. its the class assignment operator... in this case you have an instance of a class $params and you are setting a property 'Data' though these things should not be publically available for setting... it would be better to have $params->setData($texttofax . $finalitems); - this way you have control wiithin the object itself over the setting of that parameter by only allowing this publioc method to set what should be a private paramater
  11. Hi there... I am using the DOM to create forms from a form template... I simply load the markup I have and use the do to repeat things like checkboxes etc etc. all is well apart from the fact that once I use $dom->saveHTML() (or saveXML() for that matter) and remove the doctype and html and body tags it auto inserts I am left with input elements that are not closed... I SHOULD get <input type="xxx" /> but get <input type="xxx"> any help much appreciated...
  12. The singleton can be a very useful design pattern... In terms of databases and where you may need a second database connection yes it will not be what you want... To get round that you can use an array in the class that stores the connection string (host,username,passord,database) and when called again see if the current connection string already exists - if so return that connection if not open a new one and return that.
  13. you need a singleton or helper function... helper function getDB () { if(!isset($conn)) { $conn = new mysqli("localhost", "username", "password", "database"); } return $conn; } //// then anywhre in your code where you need database just: $db = getDB(); $db->query("SELECT * FROM `foo`"); ?> singleton class... <?php class DBConn { static $instance; private $_conn; private function __construct() { $this->conn = new mysqli("localhost", "username", "password", "database"); } public static function getInstance() { if ( !isset (self::$instance) } { self::$instance = new DBConn ( ); } return self::$_instance } } ///// then anywhere in your code: $db = DBConn::getInstance; $db->query("SELECT * FROM `bar`); ?> there is an over head so in most cases you would probably lean toward the helper function method...
  14. MYSQL is perectly happy performing calculations - and why bother storing such trivial data as post count? $qry = "select DISTINCT(`table2`.`username`) AS `username`, COUNT(`table1`,`userid`) AS `postcount` FROM `table2` LEFT JOIN `table1` ON `table1`.`userid` = `table2`.`userid` GROUP BY `table2`.`userid` ORDER BY `postcount` DESC LIMIT 0,10"; Something like that should do the trick...
  15. I suspect that you are constantly increasing the email_message string rather than resetting it for each email to be sent...
  16. Try this... <?php //Now we export to CSV $file = "../../logs/backups/users.csv"; $fh = fopen($file, 'w') or die("can't open file"); $data = "user_id,username,password,surname,first_name,email,mobile,dob,address1,address2,address3,post_code,parents_title,parents_initial,parents_name,parents_surname,nat_h_no,doctors_name,doctors_address,tetanus_data,medical,paying,allowed,allowed_notes,night,bronze,silver,gold,moderator,admin,s_admin,webmail,over18,date_joined,leaving_date,home_phone,parents_mobile,y_leader_location,dofe_id,notes,crb_id,crb_expiry" . PHP_EOL; fwrite($fh, $data); //Now write all lines to the csv $query = "SELECT * FROM users"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_assoc($result)){ $data = implode(',',$row) . PHP_EOL; fwrite($fh, $data); } fclose($fh); ?>
  17. you have assigned a value to output_url before you 'update' image. this won't work - once something is assigned thats it until you re-assign it. Instaed use: <img src="<?php $image = "/photo.jpg"; print $domain . $image; ?>" />
  18. clearly using up lots of memory... check your script to see if there are any cyclic calls (ie anything that will act as recursion), if you are opening files make sure you clear the cache once you have closed them (suspect this is the culprit). let us know how you get on.
  19. ooops my bad - did read that properly - thought he wanted to call a php script...
  20. you would be looking at ajax... suggest you look at using jquery to help you here - its easy to learn and very powerful - puts the fun in javascript development. jquery
  21. <?php $incr = 3; while ($r = mysql_fetch_array($result)) { $incr = ($incr == 3) ? 1 : $incr + 1; if($incr == 1) echo '<tr align="center">'; $db_id = $r['id']; $db_name = $r['name']; echo '<td valign="top" align="left"><center><div class="gamecontain"><a href="index.php?id=games&game_id='.$db_id.'"><img src="games/images/'.stripslashes($db_name).'.jpg" border="0" /></a><br><a href="index.php?id=games&game_id='.$db_id.'" class="boldlink">'.$db_name.'</a></div></center></td>'; if($incr == 3) echo "</tr>"; } if($incr == 1) echo '<td></td><td></td></tr>'; if($incr == 2) echo '<td></td></tr>'; ?> vs. <?php while ($r = mysql_fetch_array($result)) { echo '<li><a href="index.php?id=games&game_id='.$r['id'].'"><img src="games/images/'.stripslashes($r['name']).'.jpg" border="0" /></a><br><a href="index.php?id=games&game_id='.$r['id'].'" class="boldlink">'.$r['name'].'</a></li>'; } ?> I know which one I'd rather have to maintain...
  22. alternatively - instead of using tables us a <ul> put each picture in an <li> and float the li left. that way once they hit the end of a line the next picture will move onto the next.... don't have to do any math to work out when to start/end a row and its easier to manage clientside with css.
  23. I have a table of journeys.. journey_id sender_id recipient_id received distance I need one query to select count of journeys, count of journeys where received is null and the sum of the distance... this is what I have at the mo. SELECT COUNT(`journey`.`journey_id`) AS `sentNo` , COUNT(`t`.`journey_id`) AS `travelling` , SUM(`journey`.`distance`) AS `distance` FROM `journey` LEFT JOIN `users` ON `users`.`user_id` = `card_journey`.`sender` LEFT JOIN (SELECT * FROM `card_journey` WHERE `received` IS NULL) AS `t` ON `t`.`sender` = `users`.`user_id` WHERE `users`.`username` = :username problem being of course that the sum of journeys sums up all values of the joins rather than teh distinct journeys themselves hence when the user has 2 journeys i get double the difference. 3 jurneys triple and so on... Any pointers much appreciated first to
  24. concatenate mp3 files - basically you stick the mp3's of your code together and dish out just one mp3 that has the entire captcha code init.
×
×
  • 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.