Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. $i=0; while($incomplete_row = mysql_fetch_array($incomplete_results)) { if ($i == 0) { echo "<tr>"; echo "<td>" . $incomplete_row['school'] . "</td>"; echo "</tr>"; echo "<tr>"; echo "<th>Name</th>"; echo "<th>Request</th>"; echo "<th>Classroom</th>"; echo "<th>Date</th>"; echo "<th>Time</th>"; echo "</tr>"; $i++; } //make the date $date = date("d/m/Y", $incomplete_row['date']); //make the time $time = date("h:i:s A", $incomplete_row['date']); echo "<tr>"; echo "<td>" . $incomplete_row['name'] . "</td>"; echo "<td>" . $incomplete_row['request'] . "</td>"; echo "<td>" . $incomplete_row['classroom'] . "</td>"; echo "<td>" . $date . "</td>"; echo "<td>" . $time . "</td>"; echo "<td><a href=\"view.php?id=" . $incomplete_row['id'] . "\">View</a>"; echo "</tr>"; } echo "</table>"; Try that.
  2. How about post some code? It is hard to diagnose without it.
  3. It looks like you have 2 definitions of the function "upd". It has already been defined on line 42 of require.php and you are re-defining it on register.php at line 15...
  4. strip_tags That would get rid of any html, as far as php...let's try not to sit on the "cannot", and go with the "can". It is a lot easier to say this can have this, instead of this cannot have this and this and this or this or this and that or this. A lot easier and less coding.
  5. Umm...to be a bit more explanatory, even if you know the language that will not help. First setup an outline of what you want the script to be able to do. IE: I want the script to take a look at the user's time played and based on the timeplayed give the user a new level. Write out exactly what you want, than one by one code in the pieces. I always start coding with a very descriptive plan that way I stay on track and know what I need to do.
  6. RewriteEngine on RewriteCond %{HTTP_HOST} !^www.your_domain.com$ RewriteRule ^(.*)$ http://www.your_domain.com/$1 [R=301] http://www.google.com/search?hl=en&q=htacces+force+www&btnG=Google+Search First result.
  7. What are the restrictions you want? Be descriptive, no more than x characters must be at least x characters I do not want anything but numbers, -, _ and letters but has to have at least x letters no more than x numbers and can only have 1 - or _....
  8. Validate the username with restrictions you want...?
  9. Error of some type and errors turned off. Try adding this to the top of the code: <?php error_reporting(E_ALL); ini_set('display_errors', 1); If it was a loop you added, make sure it is not doing an infinite loop.
  10. http://www.ragepank.com/articles/26/disable-phpsessid/
  11. Not really a "php" question, but I will help anyhow. <script type="text/javascript"> <!-- function mySubmit() { if (document.getElementyById('subTotal').value < 50) { window.open(); } document.test.submit(); // submit the form. } // --> </script> <form name="test" method="post" action="yourpage.php"> <input type="subTotal" value="" /> <input type="submit" name="submit" onClick="mySubmit();" /> </form>
  12. http://www.chazzuka.com/blog/?p=206 http://code.google.com/p/jqueryselectcombo/ http://www.google.com/search?hl=en&sa=X&oi=spell&resnum=0&ct=result&cd=1&q=jquery+onchange+populate+dropdown&spell=1
  13. http://code.iamcal.com/php/rfc822/ People seem to speak highly of that code. I would suggest that.
  14. Sure you can. If it is numeric, than this would work: <?php function check_input($value, $type=0) { if (get_magic_quotes_gpc()) { $value = stripslashes($value); } switch ($type) { case 0: // string $value = "'" . mysql_real_escape_string($value) . "'"; break; case 1: // int if (!is_numeric($value)) { $value = 0; // or error out whichever. }else { $value = intval($value); } break; } return $value; } $username = check_input($_GET['username']); $siteid = check_input($_GET['siteid'], 1); // check for int That way it is converted to an integer regardless.
  15. You should know what is to be sent to the form. I would add another parameter to your check input "type" <?php function check_input($value, $type=0) { if (get_magic_quotes_gpc()) { $value = stripslashes($value); } switch ($type) { case 0: // string $value = "'" . mysql_real_escape_string($value) . "'"; break; case 1: // int if (!is_numeric($value)) { $value = 0; // or error out whichever. } break; } return $value; } $username = check_input($_GET['username']); $siteid = check_input($_GET['siteid'], 1); // check for int
  16. Honestly, for only 1 javascript statement, you do not need the semicolon, but as pointed out above, it was not the semicolon causing issues. It was the whole echo and not properly escaping certain elements: echo "<div id=\"category\" onclick=\"location.href='default.php?catid".$cats['cat_id']."'\">Content Here</div>"; Should work. But as stated, the semicolon was not causing the issue, just a non-escaped echo statement.
  17. for <?php $cnt = count($array1); for ($i=0; $i<$cnt; $i++) { echo '<a href="' . $array1[$i].'">' . $array2[$i] . '</a>'; } ?> Something like that should work. Edit: Or make it associative array: <?php $arrays = array("lable1"=>"URL1","lable2"=>"URL2", "lable3" => "URL3"); foreach ($arrays as $key => $val) { echo '<a href="' . $val.'">' . $key . '</a>'; } ?>
  18. @ supressor is never good, honestly. That is what display_errors 0 is for easy to change/revert back. I am not saying, do not capture it. I am saying in production, capture it, send yourself an email and alert the user there was an error. That way you have the error, they see a pretty page, and no information is given that could compromise your site =)
  19. <?php /** * Make thumbs from JPEG, PNG, GIF source file * * $tmpname = $_FILES['source']['tmp_name']; * $size - max width size * $save_dir - destination folder * $save_name - tnumb new name * * Author: LEDok - http://www.citadelavto.ru/ */ function img_resize( $tmpname, $size, $save_dir, $save_name ) { $save_dir .= ( substr($save_dir,-1) != "/") ? "/" : ""; $gis = GetImageSize($tmpname); $type = $gis[2]; switch($type) { case "1": $imorig = imagecreatefromgif($tmpname); break; case "2": $imorig = imagecreatefromjpeg($tmpname);break; case "3": $imorig = imagecreatefrompng($tmpname); break; default: $imorig = imagecreatefromjpeg($tmpname); } $x = imageSX($imorig); $y = imageSY($imorig); if($gis[0] <= $size) { $av = $x; $ah = $y; } else { $yc = $y*1.3333333; $d = $x>$yc?$x:$yc; $c = $d>$size ? $size/$d : $size; $av = $x*$c; //высота исходной картинки $ah = $y*$c; //длина исходной картинки } $im = imagecreate($av, $ah); $im = imagecreatetruecolor($av,$ah); if (imagecopyresampled($im,$imorig , 0,0,0,0,$av,$ah,$x,$y)) if (imagejpeg($im, $save_dir.$save_name)) return true; else return false; } ?> Usage: <?php $field = "avatar"; //Use field name for avatar //Check that we have a file if((!empty($_FILES["avatar"])) && ($_FILES['avatar']['error'] == 0)) { //Check if the file is JPEG/GIF and it's size is less than 15Kb $filename = basename($_FILES['avatar']['name']); $ext = substr($filename, strrpos($filename, '.') + 1); if (($ext == "jpg" || $ext == "JPG" || $ext == "jpeg" || $ext == "gif") && ($_FILES["avatar"]["type"] == "image/jpeg") || ($_FILES["avatar"]["type"] == "image/pjpeg") || ($_FILES["avatar"]["type"] == "image/gif") && //the size below this line states it must be smaller than 15Kb ($_FILES["avatar"]["size"] < 15000)) { //the line below this gives the uploaded file a random number name $random_digit=rand(0000,9999); //combine random digit to you file name to create new file name //use dot (.) to combile these two variables $newplus=$random_digit."."; $subavatar=$newplus.$ext; $subavatar = stripslashes($subavatar); //Determine the path to which we want to save this file $dir = dirname(__FILE__).'/userimg/'; $newname = $dir . $subavatar; //Check if the file with the same name is already exists on the server if (!file_exists($newname)) { //Attempt to move the uploaded file to it's new place if (img_resize($filename, 100 ,$dir , $subavatar)) { $database->updateUserField($this->username,"avatar",$subavatar); } else { $form->setError($field, "* Error: A problem occurred during file upload!"); } } else { $form->setError($field, "* Error: File ".$_FILES["avatar"]["name"]." already exists"); } } else { $form->setError($field, "* Error: Only .jpg or .gif images please."); } } else { $form->setError($field, "* Error: Your file was too big. It needs to be less than 15kb."); } ?> Un sure if that will work but that is the basic gist.
  20. You would either need to have all the makes defined in the javascript, then onchange, populate the makes based on the model, or do an AJAX call back and populate the data that way. The ajax is the preferred method and for easy ajax, google jQuery, it makes AJAX 10x easier.
  21. imagecopyresized Is that what you are looking for?
  22. $fetchedDomain = "http://www.website.com/"; if (ereg ("(^http|^https|^/|^)", $value, $regs)){ $value = $fetchedDomain . str_replace("/", "", $value); echo $value; } Something like that would do the trick, you just have to know the domain name you are fetching.
  23. Use session to hold the new review_id. Then once the user logs in, check for this id, if there is an id pending then update the review table where the review_id is equaled to that session id and assign it to that user. When you insert the review, assign it to guest by default, then just change it when that user logs in. This way if they do not login with that session it is just assigned to guest, if they do the code executes and changes it to that user.
  24. Ok there are about 5 different options here. How exactly are you using this script? As I do not feel like writing out all 5 different options and find out it was option 6 all along.
  25. I always force my site to use www. using .htaccess. That way sessions and cookies do not change/stop working. The reason it changes is cause cookies are domain specific so, www.domain.com is different then domain.com.
×
×
  • 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.