taquitosensei
Members-
Posts
676 -
Joined
-
Last visited
-
Days Won
2
Everything posted by taquitosensei
-
[SOLVED] resize a thumbnail from a panorama
taquitosensei replied to brooksh's topic in PHP Coding Help
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; } -
fgetcsv - Import CSV into database - file CHARSET issue
taquitosensei replied to AndieB's topic in PHP Coding Help
you can try setting the locale setlocale(LC_ALL, 'en_US.UTF-8'); -
[SOLVED] Pulling out Categories from a db... please help
taquitosensei replied to alco19357's topic in PHP Coding Help
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. -
[SOLVED] Pulling out Categories from a db... please help
taquitosensei replied to alco19357's topic in PHP Coding Help
Take a look here. I think this is what you're after. http://dev.mysql.com/tech-resources/articles/hierarchical-data.html -
[SOLVED] Php inserting into a linker table
taquitosensei replied to deansaddigh's topic in PHP Coding Help
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 -
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>';
-
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]; }
-
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.
-
[SOLVED] String seperation and assignment
taquitosensei replied to EchoFool's topic in PHP Coding Help
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 -
Not according to this
-
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 [
-
You have a comma that doesn't belong here `admin_db` = `$admin_db`,
-
starting at zero. The first character.
-
[SOLVED] $_SESSION not working with included pages
taquitosensei replied to tpl41803's topic in PHP Coding Help
more like if(isset($_POST['user_name']) && $_POST['user_name']!='') { $_SESSION['user_name']=$_POST['user_name']; } -
[SOLVED] Including a list of records in an email
taquitosensei replied to 86Stang's topic in PHP Coding Help
It concatenates $member.="whatever"; is the same thing as $member=$member."whatever"; -
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.
-
[SOLVED] Including a list of records in an email
taquitosensei replied to 86Stang's topic in PHP Coding Help
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"; -
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); ?>
-
$field = next(array) misses the first (0) value as null
taquitosensei replied to makoshark's topic in PHP Coding Help
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 -
[SOLVED] Find out when a variable's value has changed
taquitosensei replied to joshgarrod's topic in PHP Coding Help
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; } -
$field = next(array) misses the first (0) value as null
taquitosensei replied to makoshark's topic in PHP Coding Help
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>'; -
No problem. Just mark this as solved if you would.
-
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(); }
-
$field = next(array) misses the first (0) value as null
taquitosensei replied to makoshark's topic in PHP Coding Help
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.