The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 6 of 6

Thread: Flash & PHP news system: query error

  1. #1

    Flash & PHP news system: query error

    Hello, I have been following this tutorial:
    http://sephiroth.it/tutorials/flashPHP/news/index.php

    I keep recieving a query error everytime i try to test it. I am a PHP beginner. I do not know for sure how i should be connecting to my server/host. I have been trying to do this kind of thing for about 6 months and i can't work out how to connect etc. I really would be grateful of some help.

    Here's my code: (NB. My database is called "freemojo_news", my table "news" and my fields "id", "news" and "date")

    PHP Code:
    <?      
        $database 
    "freemojo_news";

        
    $connection mysql_connect ("localhost","","") or die ("Sorry, server error!");
        
        
    mysql_select_db($database);
        
        
    $query "SELECT * FROM news ORDER BY date ASC";
        
        
    $result mysql_query($query) or die ("Sorry, query error!");
        
    $num_rows mysql_num_rows($result);
        
        for(
    $i=0;$i<$num_rows;$i++){
        
    $row mysql_fetch_array($result);
        
        
    $news "news$i";
        
    $news $row['news'];
        
        
    $date "date$i";
        
    $date $row['date'];
        
        print(
    "&news$i=$news");
        print(
    "&date$i=$date");

    }
        
    mysql_close($connection);

    ?>
    If anyone can help i would appreciate it.
    I am using phpmyadmin to create the database.

    Thanks!
    Andrew

  2. #2
    $connection = mysql_connect ("localhost","","") or die ("Sorry, server error!");

    No UserName or Password for the database?

  3. #3
    your going to need that username and password.
    got pwnt?

  4. #4
    he may have not added them in here for security issues? ah who knows

    PHP Code:
     $query "SELECT * FROM news ORDER BY date ASC"
         
        
    $result mysql_query($query)
        while(
    $row mysql_fetch_array($result)) {
         
        
    $news "news$i"
        
    $news $row['news']; 
         
        
    $date "date$i"
        
    $date $row['date']; 
         
        print(
    "&news$i=$news"); 
        print(
    "&date$i=$date"); 



  5. #5
    I'd do this first just to make sure...
    Go to the phpMyAdmin site and do the query there to see if you are getting the data...
    CyanBlue / Jason Je / Flash Developer
    http://CyanBlue.FlashVacuum.com
    http://www.FlashVacuum.com

  6. #6
    I've resolved it now. Using this code with help from another forum too:

    PHP Code:
    <?  
        $database 
    "freemojo_news";
        
    $connection mysql_connect ("localhost","username","password") or die ("Sorry, connection to server failed!");

        
    mysql_select_db($database$connection);


        
    $query "SELECT * FROM `news` ORDER BY date ASC";
        
    $result mysql_query($query) or die ("Sorry, query error!");


        while(
    $row mysql_fetch_array($result)){


        
    $news "news".$i;
        
    $news $row['news'];

        
    $date "date".$i;
        
    $date $row['date'];

        print(
    "&news".$i."=".$news);
        print(
    "&date".$i."=".$date);
    }
        
    mysql_close($connection);

    ?>
    The really annoying problem now is that i can't get the flash side right. Data from the database is loading into my textfield fine but i want it to display the different fields in a certain order all in the same text field.

    e.g There are 3 fields in my database:
    id (auto-increment) , news, date

    I want each news article to be displayed in order of the newest 10, displayed with data from the date field above the data from the news field, then the second newest news article displayed in the same format below that and so on.

    If anyone can help me to achieve that i would be very greatful. It's very frustrating but probably really simple. My AS code looks like this:

    Code:
    stop();
    _root.scrollBar.target = news;
    news.htmlText = "Loading php";
    newsData = new LoadVars();
    newsData.load("php/getdata.php");
    newsData.onLoad = function(done) {
       if (done) {
          news.htmlText = this.news;
       }
    };
    I have some other plans that all depend on how the data loads in too for the working and updating of the gig listings. If anyone has any idea how this would be done please say so.

    Andrew

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012