dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: mysql php query problem

  1. #1
    Junior Member
    Join Date
    Feb 2004
    Posts
    24

    mysql php query problem

    I'm working on a database to hold reviews. At the moment I use PHP to make a list of names in a component in flash. When you click on a name it does this:

    stuff.name= c.getSelectedItem().label;
    stuff.sendAndLoad("http://website/retrieve.php",info,"POST");

    I know the name is being sent to PHP but I'm having problems with it sending it back. It's the WHERE argument, I've tried different things but they haven't worked:

    <?PHP

    $link = mysql_connect("localhost","username","password");
    mysql_select_db("table");

    $result = mysql_query("SELECT * FROM things WHERE ??????");
    $line = mysql_fetch_row($result);

    echo "<?xml version=\"1.0\"?>\n";
    echo "<review>\n";

    echo "<name>" . $line["name"] . "</name>\n";
    echo "<review>" . $line["review"] . "</review>\n";
    echo "<reviewer>" . $line["reviewer"] . "</reviewer>\n";
    echo "<rating>" . $line["rating"] . "</rating>\n";

    echo "</review>\n";

    mysql_close($link);
    ?>

    I don't know if this is the right sort of thing to use. I thought doing something like name=$_POST["name"] but it hasn't worked.

    Anybody with any suggestion about anything would be great.
    Thanks in advance.

  2. #2
    Wannabe PHP Wizard
    Join Date
    Nov 2001
    Location
    Leechburg, PA
    Posts
    129
    well, this may be totally unrealted, but the correct way to insert things into WHERE is:

    WHERE `name` = '".$_POST["name"]."'

    Any $_POST variable must be includes using ., ditto on _SESSION, $_GET, etc.

    Also, strings must be surrounded with ' in SQL
    Clinton N Godlesky
    My Stuff:
    http://www.15656.com/clint http://www.statedirt.com
    Personal Development Projects:
    http://www.15656.com/dev

  3. #3
    Junior Member
    Join Date
    Feb 2004
    Posts
    24
    I still get an output of:

    <?xml version="1.0"?><review><name /><review /><reviewer /><rating /></review>

    Can anyone help?

  4. #4
    Junior Member
    Join Date
    Feb 2004
    Posts
    24
    I mean there's no content.

  5. #5
    Wannabe PHP Wizard
    Join Date
    Nov 2001
    Location
    Leechburg, PA
    Posts
    129
    I use this format:

    <?

    echo "<?xml version=\"1.0\"?>\n";

    $sql = "QUERY";
    $query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error());
    while($result = mysql_fetch_array($query)){
    $data1 = $result["COLUMN1"];
    $data2 = stripslashes($result["COLUMN2"]);
    ?>
    <author><?= $author ?></author>
    etc...
    <? } ?>

    Where you would put your xml declaration outside of it.

    What are the column names? do you need help making the query itself?
    Clinton N Godlesky
    My Stuff:
    http://www.15656.com/clint http://www.statedirt.com
    Personal Development Projects:
    http://www.15656.com/dev

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center