Reply
In this query first value is returned as array!
Old 01-11-2009, 11:19 AM In this query first value is returned as array!
Sleeping Troll's Avatar
Ultra Talker

Posts: 266
Name: Butch Begy
Trades: 0
PHP Code:
 $SQL="Select * From ProjectTexts where ProjectID = '$TemplateProjectID'";
  
$ProjectTexts mysql_query($SQL);
  while (
$Texts mysql_fetch_array($ProjectTexts))
   {
    
$TextID $Texts['TextID'];
    
$Text urlencode($Texts['Text']);
    
$SQL="Insert into ProjectTexts (ProjectID, TextID, Text) Values ('$NewProjectID','$TextID','$Text')";
    
mysql_query($SQL);
    } 
$Text is written as "array" for first itteration only!
I have included an echo for $Text and it echoes correctly but is saved as "array"
Why?
$TextID ranges from 0 to n

Last edited by Sleeping Troll; 01-11-2009 at 01:58 PM..
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 01-11-2009, 12:03 PM Re: In this query first value is returned as array!
tripy's Avatar
Do not try this at home!

Posts: 3,438
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
What is the problem, or the question ?
I don't get it....

Of course, mysql_ftch_array() returns you an array, it's no surprise...
An array composed as the column name as a key (in fact, the column number is a key too, you got the value at double if you don't specify what kind of array you want)
http://www.php.net/manual/en/functio...etch-array.php

Code:
array mysql_fetch_array     ( resource $result    [, int $result_type   ] )
result   
    The result resource that is being evaluated. This result comes from a call to  mysql_query().
result_type                        
    The type of array that is to be fetched. It's a constant and can take the following values: MYSQL_ASSOC, MYSQL_NUM, and the default value of MYSQL_BOTH.
PHP Code:
while($row=mysql_fetch_array($result)){
  
//here, $row would be
$row[0]=1;
$row['id']=1;
$row[2]='tripy';
$row['username']='tripy';
//... and so on.

__________________
Only a biker knows why a dog sticks his head out the window.

Last edited by tripy; 01-11-2009 at 12:05 PM..
tripy is online now
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 01-11-2009, 01:30 PM Re: In this query first value is returned as array!
Sleeping Troll's Avatar
Ultra Talker

Posts: 266
Name: Butch Begy
Trades: 0
Only the first iteration of the loop is saving the value as an "undefined array".
I have echoed the value for $text and it echoes correctly, however in the database it is written as "array".
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
Old 01-11-2009, 02:05 PM Re: In this query first value is returned as array!
tripy's Avatar
Do not try this at home!

Posts: 3,438
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Well, technically, a string is an array of characters...
But apart of that, what kind of database is it, and what tells you that this information is correct ?
Where does
Quote:
however in the database it is written as "array".
comes from ?
__________________
Only a biker knows why a dog sticks his head out the window.

Last edited by tripy; 01-11-2009 at 02:23 PM..
tripy is online now
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 01-11-2009, 04:04 PM Re: In this query first value is returned as array!
Sleeping Troll's Avatar
Ultra Talker

Posts: 266
Name: Butch Begy
Trades: 0
I have narrowed it down to this:

PHP Code:
$SQL "Select * From ProjectTexts Where ProjectID = '$ProjectID'";
if (
$ProjectTexts mysql_query($SQL))
{
while (
$Texts mysql_fetch_array($ProjectTexts))
{
$Text $Texts['Text'];
$Text urlencode($Text);
$TextString $TextString.$Text."~";

When this script runs the first $Texts['Text'] is returned as "array".
?!?

Let me add... For the love of God, why aren't javascript and php variables compatible!
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
Old 01-11-2009, 04:22 PM Re: In this query first value is returned as array!
tripy's Avatar
Do not try this at home!

Posts: 3,438
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Quote:
For the love of God, why aren't javascript and php variables compatible!
Because PHP is a server side language, where javascript is a browser side language.
Quote:
When this script runs the first $Texts['Text'] is returned as "array"
Well, for me, it means that the text stored in the db is "array", simply.
Look at your datas with a direct query, from your db client (phpmyadmin, mysql browser or mysql cli) to see if it's not the case.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is online now
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to In this query first value is returned as array!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11862 seconds with 13 queries