Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Supporting Technologies > Server-Side Scripting

Reply
 
Thread Tools Rate Thread Display Modes
Old 01-18-2009, 10:48 AM   #1
launcher
Registered User
 
Join Date: Nov 2008
Posts: 17
Default mysql_fetch_array(): supplied argument is not a valid MySQL result resource

Here it is...
The Flash give me this.

error
Code:
<root>
  <br/>
  <b>Warning</b>
  :  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in
  <b>C:\wamp\www\Flash\PHP\general.php</b>
  on line
  <b>26</b>
  <br/>
</root>
Here's my code.

ActionScript
Code:
var xml:XML; 
var xmlLoader:URLLoader = new URLLoader; 
		
xmlLoader.load(new URLRequest("http://localhost/Flash/PHP/general.php")); 
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded); 
function xmlLoaded(event:Event):void 
{ 
	xml = new XML(event.target.data); 
	trace(xml); 
}
general.php
PHP Code:
<?php
    $sadarjanie 
$_GET['vic'];
    
$nomer $_GET['number'];
    
$iden $_GET['id'];
    
    
$content $sadarjanie;
    
$number $nomer;
    
$id $iden;

    if(
$id == 1){$prom "grafiti";}
    else if(
$id == 2){$prom "blondinki";}
    else if(
$id == 3){$prom "bigbrother";}
    else if(
$id == 4){$prom "znaeteli4e";}
    else if(
$id == 5){$prom "razni";}
    else if(
$id == 6){$prom "laforizmi";}
    else if(
$id == 7){$prom "pc";}
    else if(
$id == 8){$prom "ivan4o";}
    else if(
$id == 9){$prom "borci";}
    echo 
$prom;
                
    
//the XML
    
echo "<?xml version=\"1.0\" ?>\n";
    echo 
"<root>\n";
    include(
"C:\wamp\www\Flash\PHP\Includes\conn.php");
    
$query mysql_query("select * from $prom");
    while(
$array mysql_fetch_array($query))
    {
    echo 
"<vic id=" $array['0'] . ">" $array['1'] . "</vic>\n";
    }
    echo 
"</root>\n";
                
                
    
$number 0;
    if(
$number 0)
    {
                         if(
$number == 1){$var "grafiti";}
        else if(
$number == 2){$var "blondinki";}
        else if(
$number == 3){$var "bigbrother";}
        else if(
$number == 4){$var "znaeteli4e";}
        else if(
$number == 5){$var "razni";}
        else if(
$number == 6){$var "laforizmi";}
        else if(
$number == 7){$var "pc";}
        else if(
$number == 8){$var "ivan4o";}
        else if(
$number == 9){$var "borci";}
    
    include(
"C:/wamp/www/Flash/PHP/Includes/conn.php");
    
mysql_query("SET NAMES CP1251");
                     
$query "INSERT INTO `vicove`.`$var` (`id` ,`vic` )VALUES   (NULL , '$content')";
    
$row mysql_query($query);
    
mysql_close($conn);
    if(
$row){echo "Вица ви беше оспешно добавен";}
    else{echo 
"Вица ви не беше добавен";}
    }
?>
conn.php
PHP Code:
<?php
    $host 
"localhost";
    
$user "root";
    
$pass "";
    
$db "vicove";
    
$conn mysql_connect($host$user$pass);
    
$select_db mysql_select_db($db$conn);
?>
launcher is offline   Reply With Quote
Old 01-18-2009, 11:36 AM   #2
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 4,301
Send a message via ICQ to wvxvw
Default

This is because $prom == "". For working with XMLs in PHP use DOMDocument, and use classes instead includes. Also, you need to close the connection to the database after the script finishes (for security reasons). Use switch...case construction instead of if ... else if. Don't use SET NAMES CP1251, set everything to UTF-8 encoding, including database.
__________________
The .NET open source editor for Flash and web developers
*This would be my contribution to the project*
couchsurfing if you need it
wvxvw is offline   Reply With Quote
Old 01-18-2009, 02:06 PM   #3
launcher
Registered User
 
Join Date: Nov 2008
Posts: 17
Default

Quote:
Originally Posted by wvxvw View Post
This is because $prom == "".
I don't know what do you meen by this.

Quote:
Originally Posted by wvxvw View Post
For working with XMLs in PHP use DOMDocument.
Whay?

Quote:
Originally Posted by wvxvw View Post
and use classes instead includes.
What's the difference. Except they can be used for another scripts.

Quote:
Originally Posted by wvxvw View Post
Use switch...case construction instead of if ... else if.
ok now my php look's like this..

PHP Code:

<?php
    $id 
0;
    
$sadarjanie $_GET['vic'];
    
$nomer $_GET['number'];
    
$iden $_GET['id'];
    
    
$content $sadarjanie;
    
$number $nomer;
    
$id $iden;
                
    include(
"C:\wamp\www\Flash\PHP\Includes\conn.php");
                
    switch(
$id 0)
    {
                  case 
$id == 1:
               
$prom "grafiti";
               break;
        case 
$id == 2:
               
$prom "blondinki";
               break;
        case 
$id == 3:
               
$prom "bigbrother";
               break;
        case 
$id == 4:
               
$prom "znaeteli4e";
               break;
        case 
$id == 5:
               
$prom "razni";
               break;
        case 
$id == 6:
               
$prom "laforizmi";
               break;
        case 
$id == 7:
               
$prom "pc";
               break;
                 case 
$id == 8:
               
$prom "ivan4o";
               break;
        case 
$id == 9:
               
$prom "borci";
               break;
                        
        default:
               print 
"Изберете категория";
               break;
        }
                
//the XML
echo "<?xml version=\"1.0\" ?>\n";
echo 
"<root>\n";
$query mysql_query("Select * from $prom");
while(
$array mysql_fetch_array($query))
{
         echo 
"<vic id='" $array['0'] . "'>" $array['1'] . "</vic>\n";
}
echo 
"</root>\n";
mysql_close($conn);

........
                
?>
But now it doesn't trace anything.

Last edited by launcher; 01-18-2009 at 02:10 PM.
launcher is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MYSQL Connector Component, V1.0 mmm..pi..3.14.. Server-Side Scripting 24 10-17-2007 01:30 PM
How to declare valid strings for the type argument in e.g. foo(type:String) Pelle ActionScript 3.0 17 07-06-2007 05:36 PM
Pre-fetched data vs MySql query resource id (RecordSet Class) FFighter Flash Remoting 4 05-05-2006 01:53 AM
communicating with loaded swf usa_hodson ActionScript 2.0 2 03-20-2005 03:25 PM
AMFPHP Error: Invalid argument supplied for foreach() line 255 MicahM Flash Remoting 1 06-04-2004 04:48 PM


All times are GMT. The time now is 11:20 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.