Jump to content

taquitosensei

Members
  • Posts

    676
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by taquitosensei

  1. this should work where $x and $y are the originals and obviously $newx and $newy is the new dimensions. This resizes without losing the image ratio. $ratio1 = $x/$newX; $ratio2 = $y/$newY; if($ratio1 > $ratio2) { $nx = $newX; $ny = $y / $ratio1; } else { $nx = $x / $ratio2; $ny = $newY; }
  2. you can try setting the locale setlocale(LC_ALL, 'en_US.UTF-8');
  3. The benefit to the way listed in the article I linked is it's not recursive and you're only doing one query to the database.
  4. Take a look here. I think this is what you're after. http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
  5. insert into your post table then use last_insert_id(); http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_last-insert-id
  6. You don't need to use $GLOBALS here. Just use a variable in your function then assign the result to a variable. And you function is findSmallest not findSmall. $array1 = array(4,8,2,7,1); $smallest; //find smallest value in array function findSmallest($array){ $size = count($array); $smallest = $array[0]; for($i = 0; $i < $size; $i++) { if($smallest > $array[$i+1]){ $smallest = $array[$i+1]; } //echo $GLOBALS['smallest'] . "<br>"; } return $smallest; } $smallest=findSmallest($array1); // or if you need to use $GLOBALS $GLOBALS['smallest']=findSmallest($array1); echo '<pre>'; var_dump($smalles) // or var_dump($GLOBALS['smallest']); echo '</pre>';
  7. if the same index number is used in each array couldn't you do for($a=0;$a<count($imagearray);$a++) { $image=$imagearray[$a]; $text=$textarray[$a]; }
  8. you could do a print_r on $result make sure it's an object. I'm not sure what mysqli->query would return if there was an error in your sql.
  9. This should do it. $string = '12,14,37,124,5,77,35,74'; $array=explode(",", $string); $day=3; $number=$string($day-1); // arrays start at 0 so day 1 would be 0, day 2 would be 1, etc
  10. Not according to this
  11. Don't do this <?php $q = mysql_query("SELECT id FROM table ORDER BY id DESC LIMIT 1"); $id = mysql_fetch_object($q); $id = $id->id; ?> it's bad practice. If someone else adds a record in between you adding a record and retrieving the id you now have the wrong id. you can use last_insert_id() like this select last_insert_id() as lastid from table limit 1 [
  12. You have a comma that doesn't belong here `admin_db` = `$admin_db`,
  13. starting at zero. The first character.
  14. more like if(isset($_POST['user_name']) && $_POST['user_name']!='') { $_SESSION['user_name']=$_POST['user_name']; }
  15. use sprintf $num="3.5"; echo sprintf("%.2f", $num);
  16. It concatenates $member.="whatever"; is the same thing as $member=$member."whatever";
  17. try print_r($_SESSION); instead of echo $_SESSION['admin']; it sounds like $_SESSION['admin'] isn't set to anything which evaluates to False, same thing as 0. If 'admin' is empty then that's why and you'll need to troubleshoot your database/login section.
  18. try this while($row = mysql_fetch_array($query)) { $members.=$row['username']. "\r\n"; } then this $to = "manager@managersemail.com"; $subject = "Automated removal of pending members"; $message = "This is an automated message letting you know that the server has removed $number pending members that are 72 hours old or older that never activated their account."\r\n".$member; $from = "noreply@server.com"; $headers = "From: $from";
  19. echo $_SESSION['admin'] just before the if/else if to make sure that it's the value you're expecting. <?php session_start(); echo $_SESSION['admin'];die(); // this is so it quits here and doesn't redirect you before you have a chance to see what the value is. if ($_SESSION["admin"] == 0) { header("Location: sponser.php"); } else if ($_SESSION["admin"] == 1) { // Redirect to Guest area header("Location: admin.php"); exit(); } ?> <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); ?>
  20. your query should be closer to this INSERT INTO $table(date,question) values(now(),1) you're combining an update query with an insert query and that won't work. If you were updating it would this update $table set date=now(), question=1 where YOURIDFIELD=ANID
  21. something along these lines at the end of your loop set $oldvariable $variable=3; for($a=0;$a<=20;$a++) { $variable=$a; if($variable!=$oldvariable) { // do whatever here } $oldvariable=$variable; }
  22. change this mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database"); to this $conn=mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database"); and you're not actually running the sql. $sql="INSERT INTO exit_reason ($value) VALUES('1')"; $result=mysql_query($conn,$sql); // $query=mysql_query ("INSERT INTO ($table) SET date = NOW(), (question) VALUE('1')"); SET date = NOW(), echo $sql . '<br>'; should be $sql="INSERT INTO exit_reason ($value) VALUES('1')"; mysql_query($conn, $sql); // $query=mysql_query ("INSERT INTO ($table) SET date = NOW(), (question) VALUE('1')"); SET date = NOW(), echo $sql . '<br>';
  23. No problem. Just mark this as solved if you would.
  24. use double equals if ($_SESSION["admin"] == 0) { Header("Location: sponser.php"); } else if ($_SESSION["admin"] == 1) { //redirect to Guest area Header("Location: admin.php"); exit(); }
  25. you don't need to use next. just do this mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database"); @mysql_select_db("$DBName") or die("Unable to select database $DBName"); // echo 'Please select only 3 or less' foreach ($_POST['question'] as $value) { $sql="INSERT INTO exit_reason ($value) VALUES('1')"; echo $sql . '<br>'; } } else { echo 'Your Vote is Very Important to us.Please select 1 reason'; } the for each is looping through the $_POST['question'] array already.
×
×
  • 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.