RE: Array problem (NEVERMIND)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I forgot the break; for the switch :(

Thanks,

John Ellingsworth
http://mail.med.upenn.edu/~jellings/




-----Original Message-----
From: John Ellingsworth [mailto:jellings@mail.med.upenn.edu]
Sent: Thursday, September 11, 2003 2:37 PM
To: php-windows@lists.php.net
Subject:  Array problem


Hi.

In the code below, I always get an error from the sql statement due to some
problem in the array result.

The goal is to add as many keywords to as many thumbnails selected from a
form.
The thumbnails have this checkbox:

<input type=checkbox name=thumb[] value=3267>

And the keyword this:
<select MULTIPLE SIZE=5 name=keyword[] class=select>
<option value="Animals">Animals
etc ...
</option>

The error info is this, with the actual thumb array results output from
print_r():

Array ( [0] => 3266 [1] => 3267 [2] => 3268 [3] => 3269 [4] => 3270 [5] =>
3271 [6] => 3272 [7] => 3273 [8] => 3274 [9] => 3275 [10] => 3276 [11] =>
3277 )

Error: Unable to perform query: SELECT Path.name AS path, Thumbnail.name AS
filename, Thumbnail.idThumb FROM Thumbnail INNER JOIN Path ON
Thumbnail.idPath = Path.idPath WHERE (Thumbnail.idThumb = 'Array') :

Anyone have any suggestions?  I have tried is_array, foreach($thumbarray as
$key => $value), and can't tell why I am getting this problem.
Thanks,

John Ellingsworth
http://mail.med.upenn.edu/~jellings/


Code:


<?

require("constant.php");

if (isset($_POST["thumbAction"])) {
        $thumbAction = $_POST["thumbAction"];
} else {
        $thumbAction = "default";
        }

switch ($thumbAction) {
        case "multipleThumbs":

                if(isset($_POST["pathid"]))
                        {
                        $pathid = $_POST["pathid"] ;
                        $relative_url = "search.php?idpath=".$pathid;
                        }

                if (isset($_POST["thumb"])) { $thumbarray =
$_POST["thumb"]; }

print_r($_POST["thumb"]);

                foreach($thumbarray as $key => $value)
                                  {
                                $query = "SELECT Path.name AS path,
Thumbnail.name AS filename, Thumbnail.idThumb FROM Thumbnail INNER JOIN Path
ON Thumbnail.idPath = Path.idPath WHERE (Thumbnail.idThumb = '$value') ";

                                        // EXECUTE THE QUERY
                                                $sql->QueryItem($query);
                                                $getResults = $sql->data;

                                                $path = $sql->data["path"];
                                                $file =
$sql->data["filename"];

                                        // CLEAN UP THE PATH INFO
                                                $origpath = "\\". $path
."\\" . $file;

                                                if
(isset($_POST["keyword"]))
                                                        {
                                                        $keyword =
$_POST["keyword"] ;

if(is_array($keyword))
                                                                        {

for($k=0; $k<count($keyword); $k++)

{

$cmd = "tpcmd.exe Keyword(\"+$keyword[$k];|d:$origpath\")";

passthru($cmd);

      }
                                                                        }
                                                        }

                                                if
(isset($_POST["thumbFTxt"]))
                                                        {
                                                        $thumbFTxt =
ucwords($_POST["thumbFTxt"]);
                                                        $cmd = "tpcmd.exe
Keyword(\"+$thumbFTxt;|d:$origpath\")";
                                                        passthru($cmd);

                                                        // DEBUGGER
                                                        //echo $cmd;
                                                        }
                                }

        default:

                $thumbid = $_POST["thumb"];
                $relative_url = "showdetail.php?thumb=".$thumbid;

                $query = "SELECT Path.name AS path, Thumbnail.name AS
filename, Thumbnail.idThumb FROM Thumbnail INNER JOIN Path ON
Thumbnail.idPath = Path.idPath WHERE (Thumbnail.idThumb = '$thumbid') ";

                // EXECUTE THE QUERY
                        $sql->QueryItem($query);
                        $getResults = $sql->data;

                        $path = $sql->data["path"];
                        $file = $sql->data["filename"];

                // CLEAN UP THE PATH INFO
                        $origpath = "\\". $path ."\\" . $file;

                if (isset($_POST["keyword"])) {

                        $keyword = $_POST["keyword"] ;

                        if(is_array($keyword))
                                        {
                                                  for($i=0;
$i<count($keyword); $i++)
                                                  {
                                                        $cmd = "tpcmd.exe
Keyword(\"+$keyword[$i];|d:$origpath\")";
                                                        passthru($cmd);
                                                  }
                                        }
                                }


                if (isset($_POST["thumbFTxt"])) {
                        $thumbFTxt = ucwords($_POST["thumbFTxt"]);
                        $cmd = "tpcmd.exe
Keyword(\"+$thumbFTxt;|d:$origpath\")";
                        passthru($cmd);

                        // DEBUGGER
                        //echo $cmd;
                        }

        }

header("Location:
http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/".$relative_u
rl);

?>

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux