Jump to content

mrdamien

Members
  • Posts

    186
  • Joined

  • Last visited

Everything posted by mrdamien

  1. Not a PHP problem. Try changing your css: From this: <style type="text/css"> .progressbar { border: #333333 1px solid; height: 2px; margin: 0 2px; padding: 1px; width: 72px; } .bar { background-color: #ff7700; height: 2px; float: left; } </style> to this: <style type="text/css"> .progressbar { border: #333333 1px solid; height: 2px; margin: 0 2px; font-size: 0px; padding: 1px; width: 72px; } .bar { background-color: #ff7700; height: 2px; line-height: 2px; font-size: 0px; float: left; } </style>
  2. The starting number would be: max($this->currentPage-5, 0); The ending page number would be: min($this->currentPage+5, $this->totalPages) so you can change your loop: $start = max($this->currentPage-5, 0); $end = min($this->currentPage+5, $this->totalPages); for ($i=$min; $i < $max; $i++) { if($i != $this->currentPage) { ... }else{ ... } }
  3. If you have multiple number-signs in the url, then all but the last segment following the number sign, would be part of the GET variables ( I think ). As far as I know, that is controlled by the web-server (i.e. apache). But I've never heard of apache having this problem... What web server are you using ?
  4. Edit: Since I'm not that great with regular expressions, and don't want to spend very long testing... heres a less-regex idea. Untested: preg_match( '/([.]{1,255}@([.]{1,255})/', $text, $matches); foreach($matches as $match) { if(filter_var($match, FILTER_VALIDATE_EMAIL)){ $text = str_replace($match, "<a href=\"mailto:$match\">$match</a>", $text); }else{ $text = str_replace($match, @<a href=\"http://twitter.com/$match\" target=\"_blank\">$match</a>", $text); } } Find all strings resembling "@(characters)". Use PHPs function to determine if its an email. If not an email, its a twitter account. I don't know if twitter has username restrictions (Like not symbols) if so, you'll probably want to test for those again, in the else clause.
  5. I haven't checked in a while but I'm guessing the answer is still "no".
  6. You need to install ffmpeg to convert your videos, however if you're on a shared hosting plan, they will most likely not install if for you. http://ffmpeg.org/ If installed, its rather easy to convert IE: exec("ffmpeg -i input.avi output.flv");
  7. You have to run in on a server with php, browsers don't parse the PHP. I see you have cpanel open, so I'm assuming you have a shared hosting somewhere, upload it there to test.
  8. mysql_num_rows wants the result-resource as a paramater, not the query Therefore: $result=mysql_query($sql); if(mysql_num_rows($result) > 0){ // <- change $sql to $result. $sql = "DELETE FROM horsedata WHERE id = '".(int)$horseid."'"; // (int) for safety $result=mysql_query($sql); echo "You have Euthanized this horse."; }
  9. Can you post the whole script? There's nothing I see that could be the culprit.
  10. Your script works for me. Minus the 2 missing curly-braces, your script works. What version of PHP/GD are you using? <?php $file = 'test.jpg'; // Get the dimensions list($width, $height) = getimagesize($file); // Define our source image $source = imagecreatefromjpeg($file); // Creating the Canvas $bwimage= imagecreate($width, $height); //Create our 2 colours $white = imagecolorallocate($bwimage, 255, 255, 255); $black = imagecolorallocate($bwimage, 0, 0, 0); //Reads the origonal colors pixel by pixel for ($y=0;$y<$height;$y++) { for ($x=0;$x<$width;$x++) { $rgb = imagecolorat($source,$x,$y); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> & 0xFF; $b = $rgb & 0xFF; //if red is 255 and green is over 197 then colour in black, else colour in white if($r=255 and $g>197) { imagesetpixel($bwimage,$x,$y,$black); } else { imagesetpixel($bwimage,$x,$y,$white); } } // This was missing } // This was missing ?>
  11. Exceptions are difficult to know when to use. Both of your examples are not good examples of where to use exceptions. For form validation, either the form is valid, or it isn't. If it isn't you should simply show the form again, and ask that it be properly filled. For SQL queries, again, either the query is valid, or it isn't. All the queries you place in your site should be valid 100% of the time, so there is little need to validate them again. Exceptions should more-or-less be used when the script cannot continue past a point, because some external mechanism is not working. This is just my opinion of course. You could of course use exceptions for form-validation, but they won't add any functionality compared to <? if(!isset($_POST['email'])){ $error_message .= "An email is required"; } ?>
  12. $totalchall=mysql_query("SELECT COUNT(*) FROM challenges WHERE challgrid='$compare' OR challgdid='$compare'"); // $compare is still an array at this point so, $compare=mysql_query("SELECT teamid FROM membersteam WHERE memberid='{$_COOKIE['user']}'"); $compare=mysql_fetch_array($compare); $compare=$compare[0]; // now $compare is the teamid field $totalchall=mysql_query("SELECT COUNT(*) FROM challenges WHERE challgrid='$compare' OR challgdid='$compare'"); $totalchall=mysql_fetch_array($totalchall); $totalchall=$totalchall[0];
  13. In my opinion, the easy way is to use htmlentities, and make sure your data is properly inserted with mysql_real_escape_string
  14. Because float's are not actually precise numbers to the computer. http://ca2.php.net/int#language.types.integer.casting.from-float
  15. <?php //Organization Name $mail_from="$organization"; //Organization Telephone $message.="$organization_phone"; //Organization Mail $message.="$organization_mail"; //General Inquiries $message.="$general_inquires"; // From $header="From: $organization <$mail_from>\n". "Content-type: text/html"; // Enter your email address $to ='dealers@countrydelights.ca'; // Variables $message.=$var1.'<p>organization phone number</p><br>'.$var2.'<p>organization email</p><br>'.$var3.'<p>general inquiries</p><br>'; // Send Form $send_contact=mail($to,$subject,$message,$header); // Check, if message sent to your email // display message "We've recived your information" if($send_contact){ echo "We've recived your contact information"; } else { echo "ERROR"; } ?> You gotta specify Content-type in the headers.
  16. Not using file_get_contents will help. Instead try using curl with the CURLOPT_FILE option.
  17. while ($row = mysql_fetch_array($result)) { $start = $row["start"]; $end = $row["end"]; $date = $row["date"]; if($previous_date === 0){ $previous_date = $date; }else if($date != $previous_date){ include ("header.php"); } echo "<TABLE WIDTH='100%' BORDER='0' CELLSPACING='0' CELLPADDING='4'><TR> <TD WIDTH='25%' NOWRAP>$date</TD> <TD WIDTH='20%'>$start</TD> <TD WIDTH='15%'>$end</TD> </TR></TABLE>"; if($date != $previous_date){ $previous_date = $date; include ("footer.php"); } } I think this is what you want...
  18. $sql = "SELECT * from XXX where start_search BETWEEN '$nowq_date' AND '$nowq5_date' ORDER BY start_search ASC"; $result = mysql_query($sql,$connection) or die("Invalid query: " . mysql_error()); $previous_date = 0; while ($row = mysql_fetch_array($result)) { $start = $row["start"]; $end = $row["end"]; $date = $row["date"]; if($previous_date === 0){ $previous_date = $date; }else if($date != $previous_date){ $previous_date = $date; echo "<br>"; // extra space } echo "<TABLE WIDTH='100%' BORDER='0' CELLSPACING='0' CELLPADDING='4'><TR> <TD WIDTH='25%' NOWRAP>$date</TD> <TD WIDTH='20%'>$start</TD> <TD WIDTH='15%'>$end</TD> </TR></TABLE>"; }
  19. This is just to initialize variables. It could also be done like this: $images = array(); $prices = array(); $titles = array(); or not at all. $array[] = is equivalent to array_push. Implode takes an array, and gives you a string of all the values, seperated by the first paramaters value. EX: Implode array(1,2,3) with '#' gives "1#2#3"
  20. include "db.php"; $query = mysql_query("SELECT price, title FROM listings") or die(mysql_error()); $images = $prices = $titles = array(); while($fetch = mysql_fetch_array($query)) { $images[] = "<td>test1</td>"; $prices[] = "<td>test2</td>"; $titles[] = "<td>test3</td>"; } echo "<table>"; echo "<tr>" . implode("", $images) . "</tr>"; echo "<tr>" . implode("", $prices) . "</tr>"; echo "<tr>" . implode("", $titles) . "</tr>"; echo "</table>";
  21. <?php function get($url){ $context = stream_context_create( array( 'http' => array( 'method'=>"GET" ) ) ); return file_get_contents($url, null, $context); } $page = get('http://www.nws.noaa.gov/view/validProds.php?prod=SVR&node=KBUF'); // Strip stuff before <pre> $page = substr($page, strpos($page, "<pre>") + 5); // and after $$ $page = substr($page, 0, strpos($page, "$$")); // At this point, $page is equal to everything inbetween the <pre> tags // Find the date like: 1028 AM EST MON DEC 15 2008 $success = preg_match('([0-9]{3,4} [A-Z]{2} [A-Z]{3,4} [A-Z]{3} [A-Z]{3} [0-9]{1,2} [0-9]{4})', $page, $matches); if($success){ $page = substr($page, strpos($page, $matches[0]) + strlen($matches[0])); } echo $page; ?> For me this gave: If they ever drastically change the page though, it would need to be modified.
  22. Sounds like you should use a database instead, but here you go: http://ca3.php.net/manual/en/function.flock.php
  23. Yes that is the problem. PHP files need to be parsed, otherwise your page will show your source code.
  24. <?php if(get_magic_quotes_gpc()) { //clean XSS/SQL injection function clean_post(&$var) { $var=strip_tags(trim(mysqli_real_escape_string($var))); $var=htmlspecialchars($var,ENT_QUOTES); } array_walk_recursive($_POST,'clean_post'); } ?> Also, make sure get_magic_quotes_gpc() is not returning false.
  25. <?php if ($_POST['Submit']=='Buy this badge'){ if ($_SESSION['Money'] >= 15)&& $_SESSION['badge1'] = 0){ $sql = "UPDATE users SET "$_SESSION['Money']" = "$_SESSION['Money']" - 15 AND UPDATE users SET "$_SESSION['badge1']" = 1"; $result = mysql_query($sql) or die (mysql_error()); echo "<h3>You have received your badge!</h3><br><a href=myaccount.php>Click here to go to your account</a>"; } else { echo "<h3>You either own this badge or do not have enough ARO$.</h3><br><p>Please click the back button to go back a page.</p>"; } } ?> UPDATE users SET ".$_SESSION['Money']." = "$_SESSION['Money']... should probably be UPDATE users SET money = ".$_SESSION['Money']... $_SESSION['badge1'] should be equal to the field for badge1 I'm guessing. Since your current code makes the query eval to "SET 0 = 1" which is wrong.
×
×
  • 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.