Re: [PHP] Getting Array to Display

2010-04-22 Thread Ashley Sheridan
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.ca...@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.ca...@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
> >> >> EnteredCaptionWhere
> >> >> TakenKeywordsDescriptionImage';
> >> >>   while ($row = mysqli_fetch_array($data)) {
> >> >>
> >> >> echo '' . $row['image_id']. '';
> >> >>echo '' . $row['submitted']. '';
> >> >> echo '' . $row['caption']. '';
> >> >> echo '' . $row['where_taken'] . '';
> >> >> echo '' . $row['keyword']. '';
> >> >>echo '' . $row['description'] . '';
> >> >>   if (is_file($row['image_file'])) {
> >> >>   echo ' >> >> height="100px"/>';
> >> >>   }
> >> >>
> >> >> 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.
> >
>

Re: [PHP] Getting Array to Display

2010-04-21 Thread 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: [PHP] Getting Array to Display

2010-04-21 Thread Gary

Yea...not my day for technological domination.


Gary


"David McGlone"  wrote in message 
news:1271880892.24626.11.ca...@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: [PHP] Getting Array to Display

2010-04-21 Thread 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: [PHP] Getting Array to Display

2010-04-21 Thread 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.ca...@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

';
 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.ca...@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
>> EnteredCaptionWhere
>> TakenKeywordsDescriptionImage';
>>   while ($row = mysqli_fetch_array($data)) {
>>
>> echo '' . $row['image_id']. '';
>>echo '' . $row['submitted']. '';
>> echo '' . $row['caption']. '';
>> echo '' . $row['where_taken'] . '';
>> echo '' . $row['keyword']. '';
>>echo '' . $row['description'] . '';
>>   if (is_file($row['image_file'])) {
>>   echo '> height="100px"/>';
>>   }
>>
>> 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: [PHP] Getting Array to Display

2010-04-21 Thread 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

';
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
EnteredCaptionWhere
TakenKeywordsDescriptionImage';
 while ($row = mysqli_fetch_array($data)) {
   // Display the  data
   echo '' . $row['image_id']. '';
  echo '' . $row['submitted']. '';
   echo '' . $row['caption']. '';
   echo '' . $row['where_taken'] . '';
   echo '' . $keyword = unserialize($row['keyword']). '';
  echo '' . $row['description'] . '';
 if (is_file($row['image_file'])) {
 echo '';
 }


Thank you again for your help.

gary

"Richard Quadling"  wrote in message 
news:g2u10845a341004210827nc50b743cia5f0a44f644b4...@mail.gmail.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

';
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.ca...@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
EnteredCaptionWhere
TakenKeywordsDescriptionImage';
while ($row = mysqli_fetch_array($data)) {

echo '' . $row['image_id']. '';
echo '' . $row['submitted']. '';
echo '' . $row['caption']. '';
echo '' . $row['where_taken'] . '';
echo '' . $row['keyword']. '';
echo '' . $row['description'] . '';
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 ar

Re: [PHP] Getting Array to Display

2010-04-21 Thread 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.ca...@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

';
 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.ca...@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
>> EnteredCaptionWhere
>> TakenKeywordsDescriptionImage';
>>   while ($row = mysqli_fetch_array($data)) {
>>
>> echo '' . $row['image_id']. '';
>>echo '' . $row['submitted']. '';
>> echo '' . $row['caption']. '';
>> echo '' . $row['where_taken'] . '';
>> echo '' . $row['keyword']. '';
>>echo '' . $row['description'] . '';
>>   if (is_file($row['image_file'])) {
>>   echo '> height="100px"/>';
>>   }
>>
>> 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: [PHP] Getting Array to Display

2010-04-21 Thread 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 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.ca...@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
>>> EnteredCaptionWhere
>>> TakenKeywordsDescriptionImage';
>>>  while ($row = mysqli_fetch_array($data)) {
>>>
>>>    echo '' . $row['image_id']. '';
>>>   echo '' . $row['submitted']. '';
>>>    echo '' . $row['caption']. '';
>>>    echo '' . $row['where_taken'] . '';
>>>    echo '' . $row['keyword']. '';
>>>       echo '' . $row['description'] . '';
>>>      if (is_file($row['image_file'])) {
>>>      echo '>> height="100px"/>';
>>>      }
>>>
>>> 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.



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']

Re: [PHP] Getting Array to Display

2010-04-21 Thread Ashley Sheridan
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.ca...@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
> >> EnteredCaptionWhere
> >> TakenKeywordsDescriptionImage';
> >>   while ($row = mysqli_fetch_array($data)) {
> >>
> >> echo '' . $row['image_id']. '';
> >>echo '' . $row['submitted']. '';
> >> echo '' . $row['caption']. '';
> >> echo '' . $row['where_taken'] . '';
> >> echo '' . $row['keyword']. '';
> >>echo '' . $row['description'] . '';
> >>   if (is_file($row['image_file'])) {
> >>   echo ' >> height="100px"/>';
> >>   }
> >>
> >> 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




Re: [PHP] Getting Array to Display

2010-04-21 Thread 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

$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.ca...@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
EnteredCaptionWhere
TakenKeywordsDescriptionImage';
  while ($row = mysqli_fetch_array($data)) {

echo '' . $row['image_id']. '';
   echo '' . $row['submitted']. '';
echo '' . $row['caption']. '';
echo '' . $row['where_taken'] . '';
echo '' . $row['keyword']. '';
   echo '' . $row['description'] . '';
  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: [PHP] Getting Array to Display

2010-04-21 Thread Ashley Sheridan
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
> EnteredCaptionWhere
> TakenKeywordsDescriptionImage';
>   while ($row = mysqli_fetch_array($data)) {
> 
> echo '' . $row['image_id']. '';
>echo '' . $row['submitted']. '';
> echo '' . $row['caption']. '';
> echo '' . $row['where_taken'] . '';
> echo '' . $row['keyword']. '';
>echo '' . $row['description'] . '';
>   if (is_file($row['image_file'])) {
>   echo ' height="100px"/>';
>   }
> 
> 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




[PHP] Getting Array to Display

2010-04-21 Thread 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 'Id NumberDate
EnteredCaptionWhere
TakenKeywordsDescriptionImage';
  while ($row = mysqli_fetch_array($data)) {

echo '' . $row['image_id']. '';
   echo '' . $row['submitted']. '';
echo '' . $row['caption']. '';
echo '' . $row['where_taken'] . '';
echo '' . $row['keyword']. '';
   echo '' . $row['description'] . '';
  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