Getting Array to Display

Getting Array to Display

am 21.04.2010 15:47:30 von gary

I have a form that I have a (ever growing) list of checkboxes, Here is a
sample of the code for it.



It seems to go in, when I say seems to, I get a result of Array in the
table, the code is listed below. I have tried various solutions I found in
searching the issue, but have only been able to so far get Array.

echo '

';
while ($row = mysqli_fetch_array($data)) {

echo '';
echo '';
echo '';
echo '';
echo '';
echo '';
if (is_file($row['image_file'])) {
echo '';
}

As a bonus question, does anyone have any idea why the image would show up
in IE8, and not FF?

Thanks for your help.

Gary



__________ Information from ESET Smart Security, version of virus signature database 5047 (20100421) __________

The message was checked by ESET Smart Security.

http://www.eset.com





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

Re: Getting Array to Display

am 21.04.2010 15:57:25 von Ashley Sheridan

--=-cruDwJGrVYEpVmTmZ+fC
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Wed, 2010-04-21 at 09:47 -0400, Gary wrote:

> I have a form that I have a (ever growing) list of checkboxes, Here is a
> sample of the code for it.
>
>
>
> It seems to go in, when I say seems to, I get a result of Array in the
> table, the code is listed below. I have tried various solutions I found in
> searching the issue, but have only been able to so far get Array.
>
> echo '

Id NumberDate
Entered
CaptionWhere
Taken
KeywordsDescriptionImage
' . $row['image_id']. '' . $row['submitted']. '' . $row['caption']. '' . $row['where_taken'] . '' . $row['keyword']. '' . $row['description'] . ' height="100px"/>
';
> while ($row = mysqli_fetch_array($data)) {
>
> echo '';
> echo '';
> echo '';
> echo '';
> echo '';
> echo '';
> if (is_file($row['image_file'])) {
> echo '';
> }
>
> As a bonus question, does anyone have any idea why the image would show up
> in IE8, and not FF?
>
> Thanks for your help.
>
> Gary
>
>
>
> __________ Information from ESET Smart Security, version of virus signature database 5047 (20100421) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
>
>
>


You say you're getting an entry of Array in your table. Is this after
performing an insert query from the form? If so, we're gonna need to see
the code for that! If it's that you're retrieving from the DB and
getting Array as the output, then it could be that you're using string
functions on an array. However, as you said images are displaying, I
don't think that's the case. Maybe some of the fields in the DB have a
string literal of 'Array' as their value?

As for the images not displaying correctly, have you tried to just open
those images up in a browser using their uri? Just copy and paste it
from the tag. It might give more input on exactly what is
happening with the image.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-cruDwJGrVYEpVmTmZ+fC--

Re: Getting Array to Display

am 21.04.2010 17:01:09 von gary

Ashley

Thank you for your reply.

I was trying to get the structure of the DB into a text form, cant seem to
find that (phpmyadmin).

This is the insert code

$caption=($_POST['caption']);
$keyword=($_POST['keyword']);
$description=($_POST['description']);
$image_file=($_POST['image_file']);
$where_taken=($_POST['where_taken']);

$dbc=mysqli_connect('', '', '', 'images');

$query="INSERT INTO images(caption, where_taken, keyword, description,
image_file) VALUES
('$caption','$where_taken','$keyword','$description','$image _file')";
if (isset($_POST['submit'])) {

$how_many = count($keyword);
echo 'keywords chosen: '.$how_many.'
';
if ($how_many>0) {
echo 'You chose the following keywords:
';
}
for ($i=0; $i<$how_many; $i++) {
echo ($i+1) . '- ' . $keyword[$i] . '
';
}
echo "
";
}
$result = mysqli_query($dbc, $query)
or die('Error querying database.');

if($result == true) {
echo "Successfully Inserted $image_file into database";
} else {
echo "Some Error Occured While Inserting Records";
}

mysqli_close($dbc);
?>

I hope that helps, and again thank you for your reply.

gary


"Ashley Sheridan" wrote in message
news:1271858245.20937.10.camel@localhost...
> On Wed, 2010-04-21 at 09:47 -0400, Gary wrote:
>
>> I have a form that I have a (ever growing) list of checkboxes, Here is a
>> sample of the code for it.
>>
>>
>>
>> It seems to go in, when I say seems to, I get a result of Array in the
>> table, the code is listed below. I have tried various solutions I found
>> in
>> searching the issue, but have only been able to so far get Array.
>>
>> echo '

Id NumberDate
> Entered
CaptionWhere
> Taken
KeywordsDescriptionImage
' . $row['image_id']. '' . $row['submitted']. '' . $row['caption']. '' . $row['where_taken'] . '' . $row['keyword']. '' . $row['description'] . ' > height="100px"/>
';
>> while ($row = mysqli_fetch_array($data)) {
>>
>> echo '';
>> echo '';
>> echo '';
>> echo '';
>> echo '';
>> echo '';
>> if (is_file($row['image_file'])) {
>> echo '';
>> }
>>
>> As a bonus question, does anyone have any idea why the image would show
>> up
>> in IE8, and not FF?
>>
>> Thanks for your help.
>>
>> Gary
>>
>>
>>
>> __________ Information from ESET Smart Security, version of virus
>> signature database 5047 (20100421) __________
>>
>> The message was checked by ESET Smart Security.
>>
>> http://www.eset.com
>>
>>
>>
>>
>>
>
>
> You say you're getting an entry of Array in your table. Is this after
> performing an insert query from the form? If so, we're gonna need to see
> the code for that! If it's that you're retrieving from the DB and
> getting Array as the output, then it could be that you're using string
> functions on an array. However, as you said images are displaying, I
> don't think that's the case. Maybe some of the fields in the DB have a
> string literal of 'Array' as their value?
>
> As for the images not displaying correctly, have you tried to just open
> those images up in a browser using their uri? Just copy and paste it
> from the tag. It might give more input on exactly what is
> happening with the image.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 5047 (20100421) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>


__________ Information from ESET NOD32 Antivirus, version of virus signature database 5047 (20100421) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com




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

Re: Getting Array to Display

am 21.04.2010 17:16:11 von Ashley Sheridan

--=-sva+KbO3TkPBfXKly6lG
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Wed, 2010-04-21 at 11:01 -0400, Gary wrote:

> Ashley
>
> Thank you for your reply.
>
> I was trying to get the structure of the DB into a text form, cant seem to
> find that (phpmyadmin).
>
> This is the insert code
>
> > $caption=($_POST['caption']);
> $keyword=($_POST['keyword']);
> $description=($_POST['description']);
> $image_file=($_POST['image_file']);
> $where_taken=($_POST['where_taken']);
>
> $dbc=mysqli_connect('', '', '', 'images');
>
> $query="INSERT INTO images(caption, where_taken, keyword, description,
> image_file) VALUES
> ('$caption','$where_taken','$keyword','$description','$image _file')";
> if (isset($_POST['submit'])) {
>
> $how_many = count($keyword);
> echo 'keywords chosen: '.$how_many.'
';
> if ($how_many>0) {
> echo 'You chose the following keywords:
';
> }
> for ($i=0; $i<$how_many; $i++) {
> echo ($i+1) . '- ' . $keyword[$i] . '
';
> }
> echo "
";
> }
> $result = mysqli_query($dbc, $query)
> or die('Error querying database.');
>
> if($result == true) {
> echo "Successfully Inserted $image_file into database";
> } else {
> echo "Some Error Occured While Inserting Records";
> }
>
> mysqli_close($dbc);
> ?>
>
> I hope that helps, and again thank you for your reply.
>
> gary
>
>
> "Ashley Sheridan" wrote in message
> news:1271858245.20937.10.camel@localhost...
> > On Wed, 2010-04-21 at 09:47 -0400, Gary wrote:
> >
> >> I have a form that I have a (ever growing) list of checkboxes, Here is a
> >> sample of the code for it.
> >>
> >>
> >>
> >> It seems to go in, when I say seems to, I get a result of Array in the
> >> table, the code is listed below. I have tried various solutions I found
> >> in
> >> searching the issue, but have only been able to so far get Array.
> >>
> >> echo '

Id NumberDate
>> Entered
CaptionWhere
>> Taken
KeywordsDescriptionImage
' . $row['image_id']. '' . $row['submitted']. '' . $row['caption']. '' . $row['where_taken'] . '' . $row['keyword']. '' . $row['description'] . ' >> height="100px"/>
';
> >> while ($row = mysqli_fetch_array($data)) {
> >>
> >> echo '';
> >> echo '';
> >> echo '';
> >> echo '';
> >> echo '';
> >> echo '';
> >> if (is_file($row['image_file'])) {
> >> echo '';
> >> }
> >>
> >> As a bonus question, does anyone have any idea why the image would show
> >> up
> >> in IE8, and not FF?
> >>
> >> Thanks for your help.
> >>
> >> Gary
> >>
> >>
> >>
> >> __________ Information from ESET Smart Security, version of virus
> >> signature database 5047 (20100421) __________
> >>
> >> The message was checked by ESET Smart Security.
> >>
> >> http://www.eset.com
> >>
> >>
> >>
> >>
> >>
> >
> >
> > You say you're getting an entry of Array in your table. Is this after
> > performing an insert query from the form? If so, we're gonna need to see
> > the code for that! If it's that you're retrieving from the DB and
> > getting Array as the output, then it could be that you're using string
> > functions on an array. However, as you said images are displaying, I
> > don't think that's the case. Maybe some of the fields in the DB have a
> > string literal of 'Array' as their value?
> >
> > As for the images not displaying correctly, have you tried to just open
> > those images up in a browser using their uri? Just copy and paste it
> > from the tag. It might give more input on exactly what is
> > happening with the image.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >
> >
> >
> > __________ Information from ESET NOD32 Antivirus, version of virus
> > signature database 5047 (20100421) __________
> >
> > The message was checked by ESET NOD32 Antivirus.
> >
> > http://www.eset.com
> >
> >
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus signature database 5047 (20100421) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>
>


You're inserting the string 'Array' into the DB. The form you have is
sending an actual array, but the insert statement can only insert a
single string. The string of the array is, as you've found out, 'Array'.

Consider normalising the DB and having a keywords table with 3 fields:
id, image_id, keyword.

Then each entry in the keywords table would be a keyword, linked by
image_id. You'll also need to change your images table to include an id
by which you can reference each image individually and index by.

Lastly, be very careful of your insert statements. The way things stand,
it would be easy for someone to maliciously enter their own statements.
Use something like mysql_real_escape_string() to protect against MySQL
attacks.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-sva+KbO3TkPBfXKly6lG--

Re: Getting Array to Display

am 21.04.2010 17:27:21 von Richard Quadling

On 21 April 2010 16:01, Gary wrote:
> Ashley
>
> Thank you for your reply.
>
> I was trying to get the structure of the DB into a text form, cant seem t=
o
> find that (phpmyadmin).
>
> This is the insert code
>
> > $caption=3D($_POST['caption']);
> $keyword=3D($_POST['keyword']);
> $description=3D($_POST['description']);
> $image_file=3D($_POST['image_file']);
> $where_taken=3D($_POST['where_taken']);
>
> $dbc=3Dmysqli_connect('', '', '', 'images');
>
> $query=3D"INSERT INTO images(caption, where_taken, keyword, description,
> image_file) VALUES
> ('$caption','$where_taken','$keyword','$description','$image _file')";
> if (isset($_POST['submit'])) {
>
>    $how_many =3D count($keyword);
>    echo 'keywords chosen: '.$how_many.'
';
>    if ($how_many>0) {
>        echo 'You chose the following keywords:
'=
;
>    }
>    for ($i=3D0; $i<$how_many; $i++) {
>    echo ($i+1) . '- ' . $keyword[$i] . '
';
>  }
>     echo "
";
> }
> $result =3D mysqli_query($dbc, $query)
> or die('Error querying database.');
>
> if($result == true) {
>      echo "Successfully Inserted $image_file into database=
";
>  } else {
>      echo "Some Error Occured While Inserting Records";
>  }
>
> mysqli_close($dbc);
> ?>
>
> I hope that helps, and again thank you for your reply.
>
> gary
>
>
> "Ashley Sheridan" wrote in message
> news:1271858245.20937.10.camel@localhost...
>>
>> On Wed, 2010-04-21 at 09:47 -0400, Gary wrote:
>>
>>> I have a form that I have a (ever growing) list of checkboxes,  He=
re is a
>>> sample of  the code for it.
>>>
>>>  
>>>
>>> It seems to go in, when I say seems to, I get a result of Array in the
>>> table, the code is listed below.  I have tried various solutions I=
found
>>> in
>>> searching the issue, but have only been able to so far get Array.
>>>
>>>  echo '

Id NumberDate
> >> Entered
CaptionWhere
> >> Taken
KeywordsDescriptionImage
' . $row['image_id']. '' . $row['submitted']. '' . $row['caption']. '' . $row['where_taken'] . '' . $row['keyword']. '' . $row['description'] . ' > >> height="100px"/>
';
>>>  while ($row =3D mysqli_fetch_array($data)) {
>>>
>>>    echo '';
>>>   echo '';
>>>    echo '';
>>>    echo '';
>>>    echo '';
>>>       echo '';
>>>      if (is_file($row['image_file'])) {
>>>      echo '';
>>>      }
>>>
>>> As a bonus question, does anyone have any idea why the image would show
>>> up
>>> in IE8, and not FF?
>>>
>>> Thanks for your help.
>>>
>>> Gary
>>>
>>>
>>>
>>> __________ Information from ESET Smart Security, version of virus
>>> signature database 5047 (20100421) __________
>>>
>>> The message was checked by ESET Smart Security.
>>>
>>> http://www.eset.com
>>>
>>>
>>>
>>>
>>>
>>
>>
>> You say you're getting an entry of Array in your table. Is this after
>> performing an insert query from the form? If so, we're gonna need to see
>> the code for that! If it's that you're retrieving from the DB and
>> getting Array as the output, then it could be that you're using string
>> functions on an array. However, as you said images are displaying, I
>> don't think that's the case. Maybe some of the fields in the DB have a
>> string literal of 'Array' as their value?
>>
>> As for the images not displaying correctly, have you tried to just open
>> those images up in a browser using their uri? Just copy and paste it
>> from the tag. It might give more input on exactly what is
>> happening with the image.
>>
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>>
>>
>>
>>
>>
>> __________ Information from ESET NOD32 Antivirus, version of virus
>> signature database 5047 (20100421) __________
>>
>> The message was checked by ESET NOD32 Antivirus.
>>
>> http://www.eset.com
>>
>>
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus signat=
ure
> database 5047 (20100421) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

As you are using />, then you are creating an array called $_POST['keyword'].

So far so good.

When you construct your SQL statement, you are trying to put the array
into a string ...

Unfortunately, an handling an array like that will result in the array
becoming the text ...

Array

e.g.

$a =3D array(1,2,3);
$b =3D "$a $a $a";
echo $b;
?>

outputs ...

Array Array Array


So, either you need to store the keywords in a separate table and link
it to the main table by some sort of ID, or convert the array to a
string.

You could use something like ...

$keywords =3D implode("\t", $_POST['keyword']);

to produce a tab separated list of keywords.

You could use a comma (',') as the separator, but if any keyword
contains a comma (unlikely, but thinking ahead, keywords COULD be
keyphrases), then the comma becomes a separator on the way out.

Or you could serialize the array if you weren't interested in
processing it in the DB.

$keywords =3D serialize($_POST['keyword']);


On the way out of the DB, you would use ...

$keywords =3D explode('\t', $row['keywords']);
or
$keywords =3D unserialize($row['keywords']);



--=20
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213474=
731
ZOPA : http://uk.zopa.com/member/RQuadling

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

Re: Getting Array to Display

am 21.04.2010 19:17:26 von gary

Ashley

Again thank you for your help. I will try your suggestion of child tables if
all else fails.

Gary


"Ashley Sheridan" wrote in message
news:1271862971.20937.19.camel@localhost...
> On Wed, 2010-04-21 at 11:01 -0400, Gary wrote:
>
>> Ashley
>>
>> Thank you for your reply.
>>
>> I was trying to get the structure of the DB into a text form, cant seem
>> to
>> find that (phpmyadmin).
>>
>> This is the insert code
>>
>> >> $caption=($_POST['caption']);
>> $keyword=($_POST['keyword']);
>> $description=($_POST['description']);
>> $image_file=($_POST['image_file']);
>> $where_taken=($_POST['where_taken']);
>>
>> $dbc=mysqli_connect('', '', '', 'images');
>>
>> $query="INSERT INTO images(caption, where_taken, keyword, description,
>> image_file) VALUES
>> ('$caption','$where_taken','$keyword','$description','$image _file')";
>> if (isset($_POST['submit'])) {
>>
>> $how_many = count($keyword);
>> echo 'keywords chosen: '.$how_many.'
';
>> if ($how_many>0) {
>> echo 'You chose the following keywords:
';
>> }
>> for ($i=0; $i<$how_many; $i++) {
>> echo ($i+1) . '- ' . $keyword[$i] . '
';
>> }
>> echo "
";
>> }
>> $result = mysqli_query($dbc, $query)
>> or die('Error querying database.');
>>
>> if($result == true) {
>> echo "Successfully Inserted $image_file into database";
>> } else {
>> echo "Some Error Occured While Inserting Records";
>> }
>>
>> mysqli_close($dbc);
>> ?>
>>
>> I hope that helps, and again thank you for your reply.
>>
>> gary
>>
>>
>> "Ashley Sheridan" wrote in message
>> news:1271858245.20937.10.camel@localhost...
>> > On Wed, 2010-04-21 at 09:47 -0400, Gary wrote:
>> >
>> >> I have a form that I have a (ever growing) list of checkboxes, Here
>> >> is a
>> >> sample of the code for it.
>> >>
>> >>
>> >>
>> >> It seems to go in, when I say seems to, I get a result of Array in the
>> >> table, the code is listed below. I have tried various solutions I
>> >> found
>> >> in
>> >> searching the issue, but have only been able to so far get Array.
>> >>
>> >> echo '

Id NumberDate
>>> Entered
CaptionWhere
>>> Taken
KeywordsDescriptionImage
' . $row['image_id']. '' . $row['submitted']. '' . $row['caption']. '' . $row['where_taken'] . '' . $row['keyword']. '' . $row['description'] . ' =3D"100px"
>>> height=3D"100px"/>
';
>> >> while ($row = mysqli_fetch_array($data)) {
>> >>
>> >> echo '';
>> >> echo '';
>> >> echo '';
>> >> echo '';
>> >> echo '';
>> >> echo '';
>> >> if (is_file($row['image_file'])) {
>> >> echo '';
>> >> }
>> >>
>> >> As a bonus question, does anyone have any idea why the image would
>> >> show
>> >> up
>> >> in IE8, and not FF?
>> >>
>> >> Thanks for your help.
>> >>
>> >> Gary
>> >>
>> >>
>> >>
>> >> __________ Information from ESET Smart Security, version of virus
>> >> signature database 5047 (20100421) __________
>> >>
>> >> The message was checked by ESET Smart Security.
>> >>
>> >> http://www.eset.com
>> >>
>> >>
>> >>
>> >>
>> >>
>> >
>> >
>> > You say you're getting an entry of Array in your table. Is this after
>> > performing an insert query from the form? If so, we're gonna need to
>> > see
>> > the code for that! If it's that you're retrieving from the DB and
>> > getting Array as the output, then it could be that you're using string
>> > functions on an array. However, as you said images are displaying, I
>> > don't think that's the case. Maybe some of the fields in the DB have a
>> > string literal of 'Array' as their value?
>> >
>> > As for the images not displaying correctly, have you tried to just open
>> > those images up in a browser using their uri? Just copy and paste it
>> > from the tag. It might give more input on exactly what is
>> > happening with the image.
>> >
>> > Thanks,
>> > Ash
>> > http://www.ashleysheridan.co.uk
>> >
>> >
>> >
>> >
>> >
>> > __________ Information from ESET NOD32 Antivirus, version of virus
>> > signature database 5047 (20100421) __________
>> >
>> > The message was checked by ESET NOD32 Antivirus.
>> >
>> > http://www.eset.com
>> >
>> >
>>
>>
>> __________ Information from ESET NOD32 Antivirus, version of virus
>> signature database 5047 (20100421) __________
>>
>> The message was checked by ESET NOD32 Antivirus.
>>
>> http://www.eset.com
>>
>>
>>
>>
>
>
> You're inserting the string 'Array' into the DB. The form you have is
> sending an actual array, but the insert statement can only insert a
> single string. The string of the array is, as you've found out, 'Array'.
>
> Consider normalising the DB and having a keywords table with 3 fields:
> id, image_id, keyword.
>
> Then each entry in the keywords table would be a keyword, linked by
> image_id. You'll also need to change your images table to include an id
> by which you can reference each image individually and index by.
>
> Lastly, be very careful of your insert statements. The way things stand,
> it would be easy for someone to maliciously enter their own statements.
> Use something like mysql_real_escape_string() to protect against MySQL
> attacks.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 5047 (20100421) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>


__________ Information from ESET NOD32 Antivirus, version of virus signature database 5048 (20100421) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com




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

Re: Getting Array to Display

am 21.04.2010 19:56:11 von gary

Richard

I'm sorry, it looks like I sent a reply direct to you instead of the board,
a mistake on my part. Here is the message.

Richard

Thank you for your reply.

Something good is happening. When I look into the actual DB, I see in the
keyword column

a:9:{i:0;s:3:"fox";i:1;s:6:"wolves";i:2;s:8:"wildl (this is
truncated),which seems to be the values within the array.

I used your serialized suggestion for this.

However when I bring the table to the screeen of a browser, I still get
Array.

Here is the updated coed of the insert.php

$caption=($_POST['caption']);
$keyword=($_POST['keyword']);
$description=($_POST['description']);
$image_file=($_POST['image_file']);
$where_taken=($_POST['where_taken']);



$dbc=mysqli_connect('localhost', 'root', '', 'images');

$query="INSERT INTO images(caption, where_taken, keyword, description,
image_file) VALUES
('$caption','$where_taken','$keyword','$description','$image _file')";
if (isset($_POST['submit'])) {

$how_many = count($keyword);
echo 'keywords chosen: '.$how_many.'
';
if ($how_many>0) {
echo 'You chose the following keywords:
';
}
for ($i=0; $i<$how_many; $i++) {
echo ($i+1) . '- ' . $keyword[$i] . '
';
}
echo "
";
}
$result = mysqli_query($dbc, $query)
or die('Error querying database.');

if($result == true) {
echo "Successfully Inserted $image_file into database";
} else {
echo "Some Error Occured While Inserting Records";
}
$keyword = serialize($_POST['keyword']);
mysqli_close($dbc);

and the updated display code

$query="SELECT * FROM images";


$data = mysqli_query($dbc, $query);

// Loop through the array of score data, formatting it as HTML
echo 'Image display information from Database';
echo '

Id NumberDate
>> >> Entered
CaptionWhere
>> >> Taken
KeywordsDescriptionImage
' . $row['image_id']. '' . $row['submitted']. '' . $row['caption']. '' . $row['where_taken'] . '' . $row['keyword']. '' . $row['description'] . ' >> >> height="100px"/>
';
while ($row = mysqli_fetch_array($data)) {
// Display the data
echo '';
echo '';
echo '';
echo '';
echo '';
echo '';
if (is_file($row['image_file'])) {
echo '';
}


Thank you again for your help.

gary

"Richard Quadling" wrote in message
news:g2u10845a341004210827nc50b743cia5f0a44f644b4903@mail.gm ail.com...
On 21 April 2010 16:01, Gary wrote:
> Ashley
>
> Thank you for your reply.
>
> I was trying to get the structure of the DB into a text form, cant seem to
> find that (phpmyadmin).
>
> This is the insert code
>
> > $caption=($_POST['caption']);
> $keyword=($_POST['keyword']);
> $description=($_POST['description']);
> $image_file=($_POST['image_file']);
> $where_taken=($_POST['where_taken']);
>
> $dbc=mysqli_connect('', '', '', 'images');
>
> $query="INSERT INTO images(caption, where_taken, keyword, description,
> image_file) VALUES
> ('$caption','$where_taken','$keyword','$description','$image _file')";
> if (isset($_POST['submit'])) {
>
> $how_many = count($keyword);
> echo 'keywords chosen: '.$how_many.'
';
> if ($how_many>0) {
> echo 'You chose the following keywords:
';
> }
> for ($i=0; $i<$how_many; $i++) {
> echo ($i+1) . '- ' . $keyword[$i] . '
';
> }
> echo "
";
> }
> $result = mysqli_query($dbc, $query)
> or die('Error querying database.');
>
> if($result == true) {
> echo "Successfully Inserted $image_file into database";
> } else {
> echo "Some Error Occured While Inserting Records";
> }
>
> mysqli_close($dbc);
> ?>
>
> I hope that helps, and again thank you for your reply.
>
> gary
>
>
> "Ashley Sheridan" wrote in message
> news:1271858245.20937.10.camel@localhost...
>>
>> On Wed, 2010-04-21 at 09:47 -0400, Gary wrote:
>>
>>> I have a form that I have a (ever growing) list of checkboxes, Here is a
>>> sample of the code for it.
>>>
>>>
>>>
>>> It seems to go in, when I say seems to, I get a result of Array in the
>>> table, the code is listed below. I have tried various solutions I found
>>> in
>>> searching the issue, but have only been able to so far get Array.
>>>
>>> echo '
Id NumberDate
Entered
CaptionWhere
Taken
KeywordsDescriptionImage
' . $row['image_id']. '' . $row['submitted']. '' . $row['caption']. '' . $row['where_taken'] . '' . $keyword = unserialize($row['keyword']). '' . $row['description'] . ' height="100px"/>
';
>>> while ($row = mysqli_fetch_array($data)) {
>>>
>>> echo '';
>>> echo '';
>>> echo '';
>>> echo '';
>>> echo '';
>>> echo '';
>>> if (is_file($row['image_file'])) {
>>> echo '';
>>> }
>>>
>>> As a bonus question, does anyone have any idea why the image would show
>>> up
>>> in IE8, and not FF?
>>>
>>> Thanks for your help.
>>>
>>> Gary
>>>
>>>
>>>
>>> __________ Information from ESET Smart Security, version of virus
>>> signature database 5047 (20100421) __________
>>>
>>> The message was checked by ESET Smart Security.
>>>
>>> http://www.eset.com
>>>
>>>
>>>
>>>
>>>
>>
>>
>> You say you're getting an entry of Array in your table. Is this after
>> performing an insert query from the form? If so, we're gonna need to see
>> the code for that! If it's that you're retrieving from the DB and
>> getting Array as the output, then it could be that you're using string
>> functions on an array. However, as you said images are displaying, I
>> don't think that's the case. Maybe some of the fields in the DB have a
>> string literal of 'Array' as their value?
>>
>> As for the images not displaying correctly, have you tried to just open
>> those images up in a browser using their uri? Just copy and paste it
>> from the tag. It might give more input on exactly what is
>> happening with the image.
>>
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>>
>>
>>
>>
>>
>> __________ Information from ESET NOD32 Antivirus, version of virus
>> signature database 5047 (20100421) __________
>>
>> The message was checked by ESET NOD32 Antivirus.
>>
>> http://www.eset.com
>>
>>
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature
> database 5047 (20100421) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

As you are using />, then you are creating an array called $_POST['keyword'].

So far so good.

When you construct your SQL statement, you are trying to put the array
into a string ...

Unfortunately, an handling an array like that will result in the array
becoming the text ...

Array

e.g.

$a = array(1,2,3);
$b = "$a $a $a";
echo $b;
?>

outputs ...

Array Array Array


So, either you need to store the keywords in a separate table and link
it to the main table by some sort of ID, or convert the array to a
string.

You could use something like ...

$keywords = implode("\t", $_POST['keyword']);

to produce a tab separated list of keywords.

You could use a comma (',') as the separator, but if any keyword
contains a comma (unlikely, but thinking ahead, keywords COULD be
keyphrases), then the comma becomes a separator on the way out.

Or you could serialize the array if you weren't interested in
processing it in the DB.

$keywords = serialize($_POST['keyword']);


On the way out of the DB, you would use ...

$keywords = explode('\t', $row['keywords']);
or
$keywords = unserialize($row['keywords']);



--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

__________ Information from ESET NOD32 Antivirus, version of virus signature
database 5047 (20100421) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com




__________ Information from ESET NOD32 Antivirus, version of virus signature database 5048 (20100421) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com




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

Re: Getting Array to Display

am 21.04.2010 20:18:55 von gary

As an addition to the issue, when I do a SELECT FROM and call for a specific
keyword, it does not return any records..


Gary


""Gary"" wrote in message
news:70.50.63467.0020FCB4@pb1.pair.com...
>I have a form that I have a (ever growing) list of checkboxes, Here is a
> sample of the code for it.
>
>
>
> It seems to go in, when I say seems to, I get a result of Array in the
> table, the code is listed below. I have tried various solutions I found
> in
> searching the issue, but have only been able to so far get Array.
>
> echo '

Id NumberDate
>>> Entered
CaptionWhere
>>> Taken
KeywordsDescriptionImage
' . $row['image_id']. '' . $row['submitted']. '' . $row['caption']. '' . $row['where_taken'] . '' . $row['keyword']. '' . $row['description'] . ' >>> height="100px"/>
';
> while ($row = mysqli_fetch_array($data)) {
>
> echo '';
> echo '';
> echo '';
> echo '';
> echo '';
> echo '';
> if (is_file($row['image_file'])) {
> echo '';
> }
>
> As a bonus question, does anyone have any idea why the image would show up
> in IE8, and not FF?
>
> Thanks for your help.
>
> Gary
>
>
>
> __________ Information from ESET Smart Security, version of virus
> signature database 5047 (20100421) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
>
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 5048 (20100421) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>


__________ Information from ESET NOD32 Antivirus, version of virus signature database 5048 (20100421) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com




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

Re: Getting Array to Display

am 21.04.2010 20:31:21 von gary

Ashley

If I were to create a child table, would the Type be a Bool?

Gary


"Ashley Sheridan" wrote in message
news:1271862971.20937.19.camel@localhost...
> On Wed, 2010-04-21 at 11:01 -0400, Gary wrote:
>
>> Ashley
>>
>> Thank you for your reply.
>>
>> I was trying to get the structure of the DB into a text form, cant seem
>> to
>> find that (phpmyadmin).
>>
>> This is the insert code
>>
>> >> $caption=($_POST['caption']);
>> $keyword=($_POST['keyword']);
>> $description=($_POST['description']);
>> $image_file=($_POST['image_file']);
>> $where_taken=($_POST['where_taken']);
>>
>> $dbc=mysqli_connect('', '', '', 'images');
>>
>> $query="INSERT INTO images(caption, where_taken, keyword, description,
>> image_file) VALUES
>> ('$caption','$where_taken','$keyword','$description','$image _file')";
>> if (isset($_POST['submit'])) {
>>
>> $how_many = count($keyword);
>> echo 'keywords chosen: '.$how_many.'
';
>> if ($how_many>0) {
>> echo 'You chose the following keywords:
';
>> }
>> for ($i=0; $i<$how_many; $i++) {
>> echo ($i+1) . '- ' . $keyword[$i] . '
';
>> }
>> echo "
";
>> }
>> $result = mysqli_query($dbc, $query)
>> or die('Error querying database.');
>>
>> if($result == true) {
>> echo "Successfully Inserted $image_file into database";
>> } else {
>> echo "Some Error Occured While Inserting Records";
>> }
>>
>> mysqli_close($dbc);
>> ?>
>>
>> I hope that helps, and again thank you for your reply.
>>
>> gary
>>
>>
>> "Ashley Sheridan" wrote in message
>> news:1271858245.20937.10.camel@localhost...
>> > On Wed, 2010-04-21 at 09:47 -0400, Gary wrote:
>> >
>> >> I have a form that I have a (ever growing) list of checkboxes, Here
>> >> is a
>> >> sample of the code for it.
>> >>
>> >>
>> >>
>> >> It seems to go in, when I say seems to, I get a result of Array in the
>> >> table, the code is listed below. I have tried various solutions I
>> >> found
>> >> in
>> >> searching the issue, but have only been able to so far get Array.
>> >>
>> >> echo '

Id NumberDate
> Entered
CaptionWhere
> Taken
KeywordsDescriptionImage
' . $row['image_id']. '' . $row['submitted']. '' . $row['caption']. '' . $row['where_taken'] . '' . $row['keyword']. '' . $row['description'] . ' > height="100px"/>
';
>> >> while ($row = mysqli_fetch_array($data)) {
>> >>
>> >> echo '';
>> >> echo '';
>> >> echo '';
>> >> echo '';
>> >> echo '';
>> >> echo '';
>> >> if (is_file($row['image_file'])) {
>> >> echo '';
>> >> }
>> >>
>> >> As a bonus question, does anyone have any idea why the image would
>> >> show
>> >> up
>> >> in IE8, and not FF?
>> >>
>> >> Thanks for your help.
>> >>
>> >> Gary
>> >>
>> >>
>> >>
>> >> __________ Information from ESET Smart Security, version of virus
>> >> signature database 5047 (20100421) __________
>> >>
>> >> The message was checked by ESET Smart Security.
>> >>
>> >> http://www.eset.com
>> >>
>> >>
>> >>
>> >>
>> >>
>> >
>> >
>> > You say you're getting an entry of Array in your table. Is this after
>> > performing an insert query from the form? If so, we're gonna need to
>> > see
>> > the code for that! If it's that you're retrieving from the DB and
>> > getting Array as the output, then it could be that you're using string
>> > functions on an array. However, as you said images are displaying, I
>> > don't think that's the case. Maybe some of the fields in the DB have a
>> > string literal of 'Array' as their value?
>> >
>> > As for the images not displaying correctly, have you tried to just open
>> > those images up in a browser using their uri? Just copy and paste it
>> > from the tag. It might give more input on exactly what is
>> > happening with the image.
>> >
>> > Thanks,
>> > Ash
>> > http://www.ashleysheridan.co.uk
>> >
>> >
>> >
>> >
>> >
>> > __________ Information from ESET NOD32 Antivirus, version of virus
>> > signature database 5047 (20100421) __________
>> >
>> > The message was checked by ESET NOD32 Antivirus.
>> >
>> > http://www.eset.com
>> >
>> >
>>
>>
>> __________ Information from ESET NOD32 Antivirus, version of virus
>> signature database 5047 (20100421) __________
>>
>> The message was checked by ESET NOD32 Antivirus.
>>
>> http://www.eset.com
>>
>>
>>
>>
>
>
> You're inserting the string 'Array' into the DB. The form you have is
> sending an actual array, but the insert statement can only insert a
> single string. The string of the array is, as you've found out, 'Array'.
>
> Consider normalising the DB and having a keywords table with 3 fields:
> id, image_id, keyword.
>
> Then each entry in the keywords table would be a keyword, linked by
> image_id. You'll also need to change your images table to include an id
> by which you can reference each image individually and index by.
>
> Lastly, be very careful of your insert statements. The way things stand,
> it would be easy for someone to maliciously enter their own statements.
> Use something like mysql_real_escape_string() to protect against MySQL
> attacks.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 5047 (20100421) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>


__________ Information from ESET NOD32 Antivirus, version of virus signature database 5048 (20100421) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com




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

Re: Getting Array to Display

am 21.04.2010 22:14:52 von David McGlone

On Wed, 2010-04-21 at 13:56 -0400, Gary wrote:
> Richard
>
> I'm sorry, it looks like I sent a reply direct to you instead of the board,
> a mistake on my part. Here is the message.

LOL Must have hit the wrong reply button.

--
Blessings,
David M.


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

Re: Getting Array to Display

am 21.04.2010 22:51:20 von gary

Yea...not my day for technological domination.....


Gary


"David McGlone" wrote in message
news:1271880892.24626.11.camel@buddy...
> On Wed, 2010-04-21 at 13:56 -0400, Gary wrote:
>> Richard
>>
>> I'm sorry, it looks like I sent a reply direct to you instead of the
>> board,
>> a mistake on my part. Here is the message.
>
> LOL Must have hit the wrong reply button.
>
> --
> Blessings,
> David M.
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 5048 (20100421) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>


__________ Information from ESET NOD32 Antivirus, version of virus signature database 5048 (20100421) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com




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

Re: Getting Array to Display

am 21.04.2010 22:54:21 von Karl DeSaulniers

lol
Yeah, not your fault Gary.

On Apr 21, 2010, at 3:51 PM, Gary wrote:

>>> I'm sorry, it looks like I sent a reply direct to you instead of
>>> the board,
>>> a mistake on my part.

Karl DeSaulniers
Design Drumm
http://designdrumm.com


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

Re: Re: Getting Array to Display

am 22.04.2010 11:51:12 von Ashley Sheridan

--=-As12WNhF1zXOP008dcAs
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Wed, 2010-04-21 at 14:18 -0400, Gary wrote:

> As an addition to the issue, when I do a SELECT FROM and call for a specific
> keyword, it does not return any records..
>
>
> Gary
>
>
> ""Gary"" wrote in message
> news:70.50.63467.0020FCB4@pb1.pair.com...
> >I have a form that I have a (ever growing) list of checkboxes, Here is a
> > sample of the code for it.
> >
> >
> >
> > It seems to go in, when I say seems to, I get a result of Array in the
> > table, the code is listed below. I have tried various solutions I found
> > in
> > searching the issue, but have only been able to so far get Array.
> >
> > echo '

Id NumberDate
>> >> Entered
CaptionWhere
>> >> Taken
KeywordsDescriptionImage
' . $row['image_id']. '' . $row['submitted']. '' . $row['caption']. '' . $row['where_taken'] . '' . $row['keyword']. '' . $row['description'] . ' >> >> height="100px"/>
';
> > while ($row = mysqli_fetch_array($data)) {
> >
> > echo '';
> > echo '';
> > echo '';
> > echo '';
> > echo '';
> > echo '';
> > if (is_file($row['image_file'])) {
> > echo '';
> > }
> >
> > As a bonus question, does anyone have any idea why the image would show up
> > in IE8, and not FF?
> >
> > Thanks for your help.
> >
> > Gary
> >
> >
> >
> > __________ Information from ESET Smart Security, version of virus
> > signature database 5047 (20100421) __________
> >
> > The message was checked by ESET Smart Security.
> >
> > http://www.eset.com
> >
> >
> >
> >
> >
> > __________ Information from ESET NOD32 Antivirus, version of virus
> > signature database 5048 (20100421) __________
> >
> > The message was checked by ESET NOD32 Antivirus.
> >
> > http://www.eset.com
> >
> >
> >
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus signature database 5048 (20100421) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>
>


That's because you havn't stored any keywords in the DB! You've stored
the word 'Array'. Have you actually looked at the data with phpMyAdmin
at all?

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-As12WNhF1zXOP008dcAs--

Re: Getting Array to Display

am 22.04.2010 11:57:22 von Ashley Sheridan

--=-V7rsx/DMd1usaq4/EVF7
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Wed, 2010-04-21 at 14:31 -0400, Gary wrote:

> Ashley
>
> If I were to create a child table, would the Type be a Bool?
>
> Gary
>
>
> "Ashley Sheridan" wrote in message
> news:1271862971.20937.19.camel@localhost...
> > On Wed, 2010-04-21 at 11:01 -0400, Gary wrote:
> >
> >> Ashley
> >>
> >> Thank you for your reply.
> >>
> >> I was trying to get the structure of the DB into a text form, cant seem
> >> to
> >> find that (phpmyadmin).
> >>
> >> This is the insert code
> >>
> >> > >> $caption=($_POST['caption']);
> >> $keyword=($_POST['keyword']);
> >> $description=($_POST['description']);
> >> $image_file=($_POST['image_file']);
> >> $where_taken=($_POST['where_taken']);
> >>
> >> $dbc=mysqli_connect('', '', '', 'images');
> >>
> >> $query="INSERT INTO images(caption, where_taken, keyword, description,
> >> image_file) VALUES
> >> ('$caption','$where_taken','$keyword','$description','$image _file')";
> >> if (isset($_POST['submit'])) {
> >>
> >> $how_many = count($keyword);
> >> echo 'keywords chosen: '.$how_many.'
';
> >> if ($how_many>0) {
> >> echo 'You chose the following keywords:
';
> >> }
> >> for ($i=0; $i<$how_many; $i++) {
> >> echo ($i+1) . '- ' . $keyword[$i] . '
';
> >> }
> >> echo "
";
> >> }
> >> $result = mysqli_query($dbc, $query)
> >> or die('Error querying database.');
> >>
> >> if($result == true) {
> >> echo "Successfully Inserted $image_file into database";
> >> } else {
> >> echo "Some Error Occured While Inserting Records";
> >> }
> >>
> >> mysqli_close($dbc);
> >> ?>
> >>
> >> I hope that helps, and again thank you for your reply.
> >>
> >> gary
> >>
> >>
> >> "Ashley Sheridan" wrote in message
> >> news:1271858245.20937.10.camel@localhost...
> >> > On Wed, 2010-04-21 at 09:47 -0400, Gary wrote:
> >> >
> >> >> I have a form that I have a (ever growing) list of checkboxes, Here
> >> >> is a
> >> >> sample of the code for it.
> >> >>
> >> >>
> >> >>
> >> >> It seems to go in, when I say seems to, I get a result of Array in the
> >> >> table, the code is listed below. I have tried various solutions I
> >> >> found
> >> >> in
> >> >> searching the issue, but have only been able to so far get Array.
> >> >>
> >> >> echo '

Id NumberDate
> > Entered
CaptionWhere
> > Taken
KeywordsDescriptionImage
' . $row['image_id']. '' . $row['submitted']. '' . $row['caption']. '' . $row['where_taken'] . '' . $row['keyword']. '' . $row['description'] . ' > > height="100px"/>
';
> >> >> while ($row = mysqli_fetch_array($data)) {
> >> >>
> >> >> echo '';
> >> >> echo '';
> >> >> echo '';
> >> >> echo '';
> >> >> echo '';
> >> >> echo '';
> >> >> if (is_file($row['image_file'])) {
> >> >> echo '';
> >> >> }
> >> >>
> >> >> As a bonus question, does anyone have any idea why the image would
> >> >> show
> >> >> up
> >> >> in IE8, and not FF?
> >> >>
> >> >> Thanks for your help.
> >> >>
> >> >> Gary
> >> >>
> >> >>
> >> >>
> >> >> __________ Information from ESET Smart Security, version of virus
> >> >> signature database 5047 (20100421) __________
> >> >>
> >> >> The message was checked by ESET Smart Security.
> >> >>
> >> >> http://www.eset.com
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >
> >> >
> >> > You say you're getting an entry of Array in your table. Is this after
> >> > performing an insert query from the form? If so, we're gonna need to
> >> > see
> >> > the code for that! If it's that you're retrieving from the DB and
> >> > getting Array as the output, then it could be that you're using string
> >> > functions on an array. However, as you said images are displaying, I
> >> > don't think that's the case. Maybe some of the fields in the DB have a
> >> > string literal of 'Array' as their value?
> >> >
> >> > As for the images not displaying correctly, have you tried to just open
> >> > those images up in a browser using their uri? Just copy and paste it
> >> > from the tag. It might give more input on exactly what is
> >> > happening with the image.
> >> >
> >> > Thanks,
> >> > Ash
> >> > http://www.ashleysheridan.co.uk
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > __________ Information from ESET NOD32 Antivirus, version of virus
> >> > signature database 5047 (20100421) __________
> >> >
> >> > The message was checked by ESET NOD32 Antivirus.
> >> >
> >> > http://www.eset.com
> >> >
> >> >
> >>
> >>
> >> __________ Information from ESET NOD32 Antivirus, version of virus
> >> signature database 5047 (20100421) __________
> >>
> >> The message was checked by ESET NOD32 Antivirus.
> >>
> >> http://www.eset.com
> >>
> >>
> >>
> >>
> >
> >
> > You're inserting the string 'Array' into the DB. The form you have is
> > sending an actual array, but the insert statement can only insert a
> > single string. The string of the array is, as you've found out, 'Array'.
> >
> > Consider normalising the DB and having a keywords table with 3 fields:
> > id, image_id, keyword.
> >
> > Then each entry in the keywords table would be a keyword, linked by
> > image_id. You'll also need to change your images table to include an id
> > by which you can reference each image individually and index by.
> >
> > Lastly, be very careful of your insert statements. The way things stand,
> > it would be easy for someone to maliciously enter their own statements.
> > Use something like mysql_real_escape_string() to protect against MySQL
> > attacks.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >
> >
> >
> > __________ Information from ESET NOD32 Antivirus, version of virus
> > signature database 5047 (20100421) __________
> >
> > The message was checked by ESET NOD32 Antivirus.
> >
> > http://www.eset.com
> >
> >
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus signature database 5048 (20100421) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>
>


The table won't have a type, it will just be another regular table.

The second table has 3 fields, id, image_id, keyword. The image_id field
will match up against the image_id row in the first table, so you can
have multiple rows in the keywords table that match up to just one row
in the images table. This is called a one-to-many relationship.

Then, you would do a typical SQL join to retrieve the data:

SELECT images.image_id, images.submitted, images.caption,
images.where_taken, images.description, images.file, keywords.keyword
FROM images
LEFT JOIN keywords ON (keywords.image_id = images.image_id)
WHERE images.image_id = x

and change x to whatever identifier you are using. This will retrieve a
bunch of rows for the keywords for each image.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-V7rsx/DMd1usaq4/EVF7--

Id NumberDate
> >> >> Entered
CaptionWhere
> >> >> Taken
KeywordsDescriptionImage
' . $row['image_id']. '' . $row['submitted']. '' . $row['caption']. '' . $row['where_taken'] . '' . $row['keyword']. '' . $row['description'] . ' > >> >> height="100px"/>