Jump to content

brown2005

Members
  • Posts

    942
  • Joined

  • Last visited

Everything posted by brown2005

  1. $sentence = "Title- Here is a sentence."; $words = explode("-", $sentence); echo $words[0]; echo"<br/>"; echo $words[1]; sorry ignore this I have done it. Thanks.
  2. Title- here is a sentence Hi, What I want to do is split the above into two and remove the - so I will have Title here is a sentence Thanks in advance
  3. I want to add a post code address search feature to my website. Does anybody have any recommendations
  4. global $db; $confirmcode = $_GET['code']; $stmt = $db->prepare("SELECT * FROM people_emails WHERE people_emails_valid= :valid"); $stmt->execute(array(':confirm' => $confirmcode)); $rows = $stmt->fetch(PDO::FETCH_ASSOC); return true; what is wrong with the above? it works in one function but not another? yet the function works wihen i remove $stmt = $db->prepare("SELECT * FROM people_emails WHERE people_emails_valid= :valid"); $stmt->execute(array(':confirm' => $confirmcode)); $rows = $stmt->fetch(PDO::FETCH_ASSOC);
  5. class Function1 { function a() { } function c () { $this->a() } } class Function2 { funcation b () { Function1->a(); } } is it possible to get rid of function c and just use b calling in function a?
  6. Ignore that you've gave me a link. Thanks again
  7. Thanks for your help. How do I check SQL errors in pdo?
  8. $username = SanitizeForSQL($username); $pwdmd5 = md5($password); $stmt = $db->query("SELECT * FROM people INNER JOIN people_emails ON people_id=people_emails_person INNER JOIN members ON people_id=members_person WHERE members_username='$username' AND members_password='$pwdmd5' AND people_emails_primary='1' AND people_emails_valid='y'"); $row_count = $stmt->rowCount(); if($row_count <= 0){ $this->HandleError("Error logging in. The username or password does not match"); return false; } function SanitizeForSQL($str) { if( function_exists( "mysql_real_escape_string" ) ) { $ret_str = mysql_real_escape_string( $str ); } else { $ret_str = addslashes( $str ); } return $ret_str; } hi, above is the code I used whilst using the old mysql_ which I have converted to pdo: global $db; $username = $username; $password = md5($password); $stmt = $db->prepare("SELECT * FROM people INNER JOIN people_emails ON people_id=people_emails_person INNER JOIN members ON people_id=members_person WHERE members_username= :username AND members_password= :password AND people_emails_primary='1' AND people_emails_valid='y'"); $stmt->execute(array(':username' => $username,':password' => $password)); $row_count = $stmt->rowCount(); if($row_count <= 0){ $this->HandleError("Error logging in. The username or password does not match"); return false; } while($row = $stmt->fetch(PDO::FETCH_ASSOC)){ $_SESSION['name_of_user'] = $row['people_first']; $_SESSION['email_of_user'] = $row['people_emails_email']; } return true; is this the correct way to prevent sql injections instead of using the function SanitizeForSQL($str)
  9. class Selmgec { function website_url($url){ global $db; $stmt = $db->query("SELECT selmgec_id FROM selmgec INNER JOIN domains ON selmgec_domain=domains_id WHERE domains_url='$url'"); while($row = $stmt->fetchAll(PDO::FETCH_ASSOC)){ return $row['selmgec_id']; } } function website_id($id){ global $db; $stmt = $db->query("SELECT domains_url FROM domains INNER JOIN selmgec ON selmgec_domain=domains_id WHERE selmgec_id='$id'"); while($row = $stmt->fetchAll(PDO::FETCH_ASSOC)){ return $row['domains_url']; } } } $network = $selmgec->website_url('http://www.richardbrown.name'); so why is this not working?
  10. class Selmgec { function myfunction(){ } } I currently do $selmgec->myfunction();, which I was using with the old way of connecting mysql_ but was adivsed to change to pdo connection, so how do I change my code to make the function work, as currently it is not?
  11. function url_strip($url){ return preg_replace('#^https?://www.#', '', $url); } I currently have the above function witch strips say http://www.thiswebsite.co.uk into thiswebsite.co.uk what I want to do is add $remove = array('https://www.','http://www.','https://','http://','www.'); this into the function, I have tried function url_strip($url){ $remove = array('https://www.','http://www.','https://','http://','www.'); foreach($remove as $key => $val){ $array[$key] = preg_replace(''.$val.'','', $url); } return $url; }
  12. ok that prints Hello world, but what I want to do is show all the results from the database within the ol tag <ol id="update" class="timeline">'; $comments_sql = mysql_query("SELECT * FROM domains_comments WHERE domains_comments_selmgec='$selmgec' AND domains_comments_domain='$domains_id' ORDER BY domains_comments_date DESC LIMIT 10"); while($comments_row = mysql_fetch_array($comments_sql)){ echo'<li>'.$comments_row[domains_comments_member].'<br />'.$comments_row[domains_comments_date].'<br />'.$comments_row[domains_comments_comment].'</li>'; } echo' </ol> so how would I refresh this, without actually pressing refresh?
  13. I have the following code, which I have got working with the auto post part, but it is not refreshing the form to allow the items I have posted to the database, but when I refresh the browser they show up. this is my php/html: echo'<ol id="update">'; while($comments_row = mysql_fetch_array($comments_sql)){ echo'<li class="">'.$comments_row[textarea_keywords].' <a href="delete.php?id='.$comments_row[textarea_id].'" title="Remove Keyword">x</a></li>'; } echo'</ol> <div id="flash"></div> <form action="#" method="post"> <textarea rows="7" cols="60" name="comment" id="comment" placeholder="enter your comment here"></textarea> <input type="submit" class="submit" value=" Submit Comment " /> </form> this is my code: $(function() { $(".submit").click(function() { var comment = $("#comment").val(); var dataString = 'comment=' + comment; if(comment==''){ alert('Please Give Valide Details'); }else{ $("#flash").show(); $("#flash").fadeIn(400).html('<img src="ajax-loader.gif" align="absmiddle"> <span class="loading">Loading Comment...</span>'); $.ajax({ type: "POST", url: "commentajax.php", data: dataString, cache: false, success: function(html){ $("ol#update").append(html); $("ol#update li:last").fadeIn("slow"); $("#flash").hide(); } }); } return false; }); });
  14. I am not asking anyone to do this for me at all, but if anyone can tell me what I would search for on google for this, I can look up articles and tutorials!
  15. Hi, I want to have a text area, then when someone enters an email and presses the tab key or space key it will make the email as in the picture attached. I look forward to your replies.
  16. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Linear Calendar</title> <style type="text/css" media="all"> body { font-family:"Calibri"; color:#009; } .currentDay { background:#FFC; color:red; } table { border-collapse:collapse; border:1px #009 solid; } td { height:60px; vertical-align:top; text-align:center; width:30px; } .days:hover { background:#9F0; border-color:#000; } .day6 { background:#ECECFF; } .day7 { background:#ECECFF; } .monthName { text-align:left; vertical-align:middle; } .monthName div { padding-left:10px; } </style> </head> <body> <?php $dDaysOnPage = 37; $dDay = 1; if ($_REQUEST['year'] <> "") { $dYear = $_REQUEST['year']; } else { $dYear = date("Y"); } ?> <table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <th><?php echo $dYear; ?></th> <th>Mo</th> <th>Tu</th> <th>We</th> <th>Th</th> <th>Fr</th> <th>Sa</th> <th>Su</th> <th>Mo</th> <th>Tu</th> <th>We</th> <th>Th</th> <th>Fr</th> <th>Sa</th> <th>Su</th> <th>Mo</th> <th>Tu</th> <th>We</th> <th>Th</th> <th>Fr</th> <th>Sa</th> <th>Su</th> <th>Mo</th> <th>Tu</th> <th>We</th> <th>Th</th> <th>Fr</th> <th>Sa</th> <th>Su</th> <th>Mo</th> <th>Tu</th> <th>We</th> <th>Th</th> <th>Fr</th> <th>Sa</th> <th>Su</th> <th>Mo</th> <th>Tu</th> </tr> <?php function FriendlyDayOfWeek($dayNum) { if ($dayNum == 0){ return 7; } else { return $dayNum; } } for ($mC=1;$mC<=12;$mC++){ $currentDT = mktime(0,0,0,$mC,$dDay,$dYear); echo "<tr><td class='monthName'><div>".date("F",$currentDT)."</div></td>"; $daysInMonth = date("t",$currentDT); echo InsertBlankTd(FriendlyDayOfWeek(date("w",$currentDT))-1); $calendarYear = '2013'; $indexStart = 16; $indexMax = 28; $date = strtotime("1/1/{$calendarYear}"); $year = $calendarYear; $index = $indexStart - 1;# for($i=1;$i<=$daysInMonth;$i++) { $exactDT = mktime(0,0,0,$mC,$i,$dYear); if ($i==date("d")&&date("m",$currentDT)==date("m")) { $class="currentDay"; } else { $class = ""; } $indexNo = $index % $indexMax + 1; $dateStr = date('d', $date); $dowNo = date('D', $date); echo "<td class='".$class." days day".FriendlyDayOfWeek(date("w",$exactDT))."'>".$dateStr."<br />".$indexNo."</td>"; $index++; $date = strtotime("+1 day", $date); $year = date('Y', $date); } echo InsertBlankTd($dDaysOnPage - $daysInMonth - FriendlyDayOfWeek(date("w",$currentDT))+1); echo "</tr>"; } ?> </table> </body> </html> <?php function InsertBlankTd($numberOfTdsToAdd) { for($i=1;$i<=$numberOfTdsToAdd;$i++) { $tdString .= "<td></td>"; } return $tdString; } ?> I have tried incorporating your code into the linear calendar I have and I can not seem to get it to work, it does the calendar, but every month, the first day of that month starts on 16 yet I would like it to continue from where it left off the month before. I look forward to your help.
  17. for($x=16;$x <=28;$x++){ echo "<td class='".$class." days day".FriendlyDayOfWeek(date("w",$exactDT))."'>".$i. "<br />" .$x."</td>"; } i have added this, but it shows 16-28 for every day and not just the corresponding answer, such as: 1/1/13 = 16 2/1/13 = 17 3/1/13 = 18 then when it gets to 28 go back to 1
  18. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Linear Calendar</title> <style type="text/css" media="all"> body { font-family:"Calibri"; color:#009; } .currentDay { background:#FFC; color:red; } table { border-collapse:collapse; border:1px #009 solid; } td { height:60px; vertical-align:top; text-align:center; width:30px; } .days:hover { background:#9F0; border-color:#000; } .day6 { background:#ECECFF; } .day7 { background:#ECECFF; } .monthName { text-align:left; vertical-align:middle; } .monthName div { padding-left:10px; } </style> </head> <body> <?php $dDaysOnPage = 37; $dDay = 1; if ($_REQUEST['year'] <> "") { $dYear = $_REQUEST['year']; } else { $dYear = date("Y"); } ?> <table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <th><?php echo $dYear; ?></th> <th>Mo</th> <th>Tu</th> <th>We</th> <th>Th</th> <th>Fr</th> <th>Sa</th> <th>Su</th> <th>Mo</th> <th>Tu</th> <th>We</th> <th>Th</th> <th>Fr</th> <th>Sa</th> <th>Su</th> <th>Mo</th> <th>Tu</th> <th>We</th> <th>Th</th> <th>Fr</th> <th>Sa</th> <th>Su</th> <th>Mo</th> <th>Tu</th> <th>We</th> <th>Th</th> <th>Fr</th> <th>Sa</th> <th>Su</th> <th>Mo</th> <th>Tu</th> <th>We</th> <th>Th</th> <th>Fr</th> <th>Sa</th> <th>Su</th> <th>Mo</th> <th>Tu</th> </tr> <?php function FriendlyDayOfWeek($dayNum) { if ($dayNum == 0){ return 7; } else { return $dayNum; } } for($mC=1;$mC<=12;$mC++){ $currentDT = mktime(0,0,0,$mC,$dDay,$dYear); echo "<tr><td class='monthName'><div>".date("F",$currentDT)."</div></td>"; $daysInMonth = date("t",$currentDT); echo InsertBlankTd(FriendlyDayOfWeek(date("w",$currentDT))-1); for($i=1;$i<=$daysInMonth;$i++){ $exactDT = mktime(0,0,0,$mC,$i,$dYear); if ($i==date("d")&&date("m",$currentDT)==date("m")){ $class="currentDay"; }else{ $class = ""; } [b] echo "<td class='".$class." days day".FriendlyDayOfWeek(date("w",$exactDT))."'>".$i."</td>"; [/b] } echo InsertBlankTd($dDaysOnPage - $daysInMonth - FriendlyDayOfWeek(date("w",$currentDT))+1); echo "</tr>"; } ?> </table> </body> </html> <?php function InsertBlankTd($numberOfTdsToAdd) { for($i=1;$i<=$numberOfTdsToAdd;$i++) { $tdString .= "<td></td>"; } return $tdString; } ?> i have the above code that is for a yearly calendar, now I want to start at the 1/1/2013 on the number 16 then loop through the till 28, start at 1 again, until the end of the calendar? any help is much appreciated
  19. sorry it has worked. I had the wrong $here in another part of the script.
  20. sorry, did not mean to change that. Changed it back to GET and no it does not do what I want it to do?
  21. $domain = (isset($_POST['domain'])) ? $_POST['domain'] : ""; that what you wanted me to do?
  22. if(isset($domain)) I have tried this? But still does not work?
  23. $domain = $_GET['domain'] ? $_GET['domain'] : ""; if($domain == ""){ $domains_sql = mysql_query("SELECT * FROM domains ORDER BY RAND() LIMIT 1"); }else{ $domains_sql = mysql_query("SELECT * FROM domains WHERE domains_id='$domain' LIMIT 1"); } I was wondering how I get the above code to work?
  24. ill explain it a little bit more. i have a number of tables. domains (main table) domains_comments (sub table - linked dy domains_comments_id=domains_id) domains_ratings (sub table - linked dy domains_ratings_id=domains_id) domains_keywords (sub table - linked dy domains_keywords_id=domains_id) so what I would normally do is $domains_sql = mysql_query(""); while($domains_row = mysql_fetch_array($domains_sql)){ $domains_comments_sql = mysql_query(""); while($domains_comments_row = mysql_fetch_array($domains_comments_sql)){ } $domains_ratings_sql = mysql_query(""); while($domains_ratings_row = mysql_fetch_array($domains_ratings_sql)){ } } I have been told to do just the one query instead of this?
×
×
  • 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.