FlashVacuum Forum Index
FlashVacuum Forum IndexForum Index    FAQFAQ    SearchSearch    StatisticsStatistics    ShouBboxShoutBox    RegisterRegister    Log inLog in       
FlashVacuum Forum Index >> Server Side Languages >> problem loading mySQL into flash, plz help!
Post new topic   Reply to topic Users browsing this topic: 0 Registered, 0 Hidden and 0 Guests
Registered Users: None
View previous topicEmail this thread to a friendPrinter-friendly versionLog in to check your private messagesView next topic
Author Message
Syntax-Error

No Avatar


Joined: 05 Nov 2005
Posts: 1

blank.gif
Local Time: 5:46 am

Status: Offline

PostPosted: 11/5/2005, 6:26 pm    Post subject: problem loading mySQL into flash, plz help! Reply with quote

I have a dynamic textbox in my flash movie that loads data from a php file, which retrives data from a mySQL database. When the movie loads, I am presented with strange data.

The php file follows:

PHP:
<?php
&text=TEST
<?

mysql_connect("-------","------","---------");

mysql_select_db("mydb");

$test = "I'm a test.";

echo
$test;

$dtest = mysql_query("SELECT author FROM sor_tb where ID = 1");

echo
$dtest;

?>

Test
?>


The expected output would be:


TEST
I'm a test.
John Doe (name of author from mySQL table)
Test


But instead I get:


TEST
I'm a test.
Resource id #3
Test


The swf can be viewed HERE

The table was set up correctly, and only has one row, which has an ID of 1. So, I have no idea where "Resource id #3" comes from and why the data isn't showing up. What am I doing wrong? Thanks.
Back to top
View user's profile Send private message
[ IP : Logged ]   
CyanBlue
FV Staff


Joined: 24 Jul 2003
Posts: 2012
Location: Chantilly, VA
usa.gif
Local Time: 7:46 am

Status: Offline

PostPosted: 11/5/2005, 7:03 pm    Post subject: Reply with quote

Howdy and Welcome... Smile

Well... If I remember correctly(it's been a while for me not to use PHP), the mysql_query() function returns a reference to the result not the result itself... That's why you are seeing that 'Resource id #3' instead of the actual data...

But since you know that you are only getting one record set, you could try this...
PHP:
<?php
$dtest
= mysql_query("SELECT author FROM sor_tb where ID = 1 LIMIT 1");

_________________
Back to top
View user's profile Send private message Send e-mail
[ IP : Logged ]   
aurelius
Site Admin


Joined: 24 Jul 2003
Posts: 1769
Location: somewhere in thomistic metaphysics...
uk.gif
Local Time: 1:46 pm

Status: Offline

PostPosted: 11/6/2005, 8:57 am    Post subject: Reply with quote

Yep. You need to access the data in the query with some other functions. For example:

PHP:
<?php
// run the query
$result = mysql_query ( $myQuery );

// all records returned by the query are counted by rows,
// so that the first returned record is row 0, the next
// returned record is row 1, and so on. If there is only
// one returned record, then that is row 0.

// get the value of a field name by row
$row = 0;
$fieldname = "author";
$record = mysql_result ( $result, $row, $fieldname );

// display the value in the table's "author" field at returned record row 0
echo $record;

_________________

www.absconditus.com // experiments in actionscripted graphic design

"There's no point in doing decorative design...
it would just interfere with what I had to say..."
// Scott King
Back to top
View user's profile Send private message Send e-mail Visit poster's website
[ IP : Logged ]   
aurelius
Site Admin


Joined: 24 Jul 2003
Posts: 1769
Location: somewhere in thomistic metaphysics...
uk.gif
Local Time: 1:46 pm

Status: Offline

PostPosted: 11/6/2005, 9:04 am    Post subject: Reply with quote

Also, if you're going to be using mysql a lot, it is useful to build yourself a class (or set of functions)which performs all of the above steps. As you can see, just getting the value of a MySQL record takes a few steps, and you don't want to type all of that each time you need a record. It's easier to build a class (or set of functions) which does all those steps for you. Then you can just call the function that does all of that.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
[ IP : Logged ]   
D7



Joined: 05 Mar 2006
Posts: 3

blank.gif
Local Time: 7:46 am

Status: Offline

PostPosted: 3/5/2006, 2:47 pm    Post subject: Reply with quote

Syntax-Error wrote:

The table was set up correctly, and only has one row, which has an ID of 1. So, I have no idea where "Resource id #3" comes from and why the data isn't showing up. What am I doing wrong? Thanks.


http://www.issociate.de/board/post/211853/Error:_%22Resource_id_

Wink
Back to top
View user's profile Send private message Send e-mail
[ IP : Logged ]   
Display posts from previous:   
View previous topic :: View next topic  
FlashVacuum Forum Index >> Server Side Languages >> problem loading mySQL into flash, plz help!
Post new topic   Reply to topic
View previous topicEmail this thread to a friendPrinter-friendly versionLog in to check your private messagesView next topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum
Jump to:  



Page generation time : 2.0955s  (PHP : 98%  -  SQL : 2%)   -   SQL queries : 23   -   GZIP : Disabled   -   Debug : On   -   Server Load : 16 pages served in past 5 minutes.