Welcome, Guest
  • Author Topic: Can I Do It Like This?  (Read 4226 times)

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re: Can I Do It Like This?
    « Reply #15 on: 02/06/07, 02:28 »
    the result variable only contains a pointer to the result.
    You have to read the result with

    mysql_fetch_row, or mysql_fetch_array

    I usualy use this:
    Code: [Select]
    $row=mysql_fetch_array($rs,MYSQL_ASSOC);
    then you can access every single field by using the fieldname:

    Code: [Select]
    $owner=$row['ownersname'];
    etc..
    happy flashing
    8)
    Ronald

    B-L-A-D-E

    • Seasoned Programmer
    • ***
    • Posts: 221
    • Intermediate Flash Designer/Novice-Programmer
      • MSN Messenger - millerstephen@hotmail.com
      • AOL Instant Messenger - WICKIDxCLOWNxBOY
      • View Profile
      • SWJuggalos
      • Email
    Re: Can I Do It Like This?
    « Reply #16 on: 02/06/07, 11:19 »
    should i call the variable out?

    "/Clients/Search1.php?ownersname="+ownersname


    somthing like that?
    [shadow=Blue,left,300]Stephen Miller[/shadow]
    Aim:WICKIDxCLOWNxBOY
    E-Mail: MillerStephen@Hotmail.com

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re: Can I Do It Like This?
    « Reply #17 on: 02/06/07, 14:02 »
    I sugest you to do the read and write tutorial from jorge to get the basics about communicating between flash and scripting.
    Then you will see how flash sends the data to php, and how it is returned.

    There is even a example showing you database communication.
    happy flashing
    8)
    Ronald

    B-L-A-D-E

    • Seasoned Programmer
    • ***
    • Posts: 221
    • Intermediate Flash Designer/Novice-Programmer
      • MSN Messenger - millerstephen@hotmail.com
      • AOL Instant Messenger - WICKIDxCLOWNxBOY
      • View Profile
      • SWJuggalos
      • Email
    Re: Can I Do It Like This?
    « Reply #18 on: 02/06/07, 16:52 »
    This Is The Php Code I Use... Is It Written Right, So The Var:ownersname gets taken from flash and searchs the database for any ownersname that was typed, and print them to flash?




    <?php
    include("Connect.php");

    $ownersname = stripslashes(ownersname);


    $result = mysql_query("SELECT * FROM Registration
     WHERE ownersname = '$ownersname' OR cellnum = '$ownersname' OR homenum = '$ownersname'") or die(mysql_error());
     

    // get the first (and hopefully only) entry from the result
    $row=mysql_fetch_array($result,MYSQL_ASSOC);



     
    // Print out the contents



    echo $ownersname=$row['ownersname'];
    echo $address=$row['address'];
    echo $row['city'];
    echo $row['state'];
    echo $row['zip'];
    echo $row['homenum'];
    echo $row['cellnum'];
    echo $row['emergencynum'];
    echo $row['typeone'];
    echo $row['typetwo'];
    echo $row['typethree'];
    echo $row['petone'];
    echo $row['pettwo'];
    echo $row['petthree'];
    echo $row['breedone'];
    echo $row['breedtwo'];
    echo $row['breedthree'];
    echo $row['bornone'];
    echo $row['borntwo'];
    echo $row['bornthree'];
    echo $row['sexone'];
    echo $row['sextwo'];
    echo $row['sexthree'];
    echo $row['sizeone'];
    echo $row['sizetwo'];
    echo $row['sizethree'];
    echo $row['barkerone'];
    echo $row['barkertwo'];
    echo $row['barkerthree'];
    echo $row['codeone'];
    echo $row['codetwo'];
    echo $row['codethree'];
    echo $row['descriptions'];
    echo $row['instructions'];
    echo $vetname=$row['vetname'];
    echo $row['vetnum'];
    echo "vetexpenselimit=$vetexpenselimit";
    echo "medone=$medone";
    echo "medtwo=$medtwo";
    echo "medthree=$medthree";
    echo "dograbiesone=$dograbiesone";
    echo "dograbiestwo=$dograbiestwo";
    echo "dograbiesthree=$dograbiesthree";
    echo "dhlppone=$dhlppone";
    echo "dhlpptwo=$dhlpptwo";
    echo "dhlppthree=$dhlppthree";
    echo "catrabiesone=$catrabiesone";
    echo "catrabiestwo=$catrabiestwo";
    echo "catrabiesthree=$catrabiesthree";
    echo "fvrcpone=$fvrcpone";
    echo "fvrcptwo=$fvrcptwo";
    echo "fvrcpthree=$fvrcpthree";
    echo "leukone=$leukone";
    echo "leuktwo=$leuktwo";
    echo "leukthree=$leukthree";
    echo "feedone=$feedone";
    echo "feedtwo=$feedtwo";
    echo "feedthree=$feedthree";
    echo "groomedone=$groomedone";
    echo "groomedtwo=$groomedtwo";
    echo "groomedthree=$groomedthree";
    echo "dateone=$dateone";
    echo "datetwo=$datetwo";
    echo "datethree=$datethree";
    echo "priceone=$priceone";
    echo "pricetwo=$pricetwo";
    echo "pricethree=$pricethree";
    echo "infoone=$infoone";
    echo "infotwo=$infotwo";
    echo "infothree=$infothree";
    echo "nightsone=$nightsone";
    echo "nightstwo=$nightstwo";
    echo "nightsthree=$nightsthree";
    echo "rateone=$rateone";
    echo "ratetwo=$ratetwo";
    echo "ratethree=$ratethree";
    echo "groomone=$groomone";
    echo "groomtwo=$groomtwo";
    echo "groomthree=$groomthree";
    echo "miscone=$miscone";
    echo "misctwo=$misctwo";
    echo "miscthree=$miscthree";
    echo "totalone=$totalone";
    echo "totaltwo=$totaltwo";
    echo "totalthree=$totalthree";
    echo "totalfour=$totalfour";
    echo "depositone=$depositone";
    echo "deposittwo=$deposittwo";
    echo "depositthree=depositthree";



    ?>

    and the reason i have it written both ways just so i can see which one works?

    echo $ownersname=$row['ownersname'];
    echo $address=$row['address'];
    echo $row['city'];
    echo $row['state'];



    « Last Edit: 02/06/07, 18:45 by B-L-A-D-E »
    [shadow=Blue,left,300]Stephen Miller[/shadow]
    Aim:WICKIDxCLOWNxBOY
    E-Mail: MillerStephen@Hotmail.com

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re: Can I Do It Like This?
    « Reply #19 on: 02/07/07, 02:33 »
    after $row is an array of records (even though you hope to fetch only one record).

    so form it this way:

    Code: [Select]
    $ownersname=$row[0]['ownersname'];if you received more than one record, you can walk through this array by counting the first value up until you reach the number of records read.
    happy flashing
    8)
    Ronald

    B-L-A-D-E

    • Seasoned Programmer
    • ***
    • Posts: 221
    • Intermediate Flash Designer/Novice-Programmer
      • MSN Messenger - millerstephen@hotmail.com
      • AOL Instant Messenger - WICKIDxCLOWNxBOY
      • View Profile
      • SWJuggalos
      • Email
    Re: Can I Do It Like This?
    « Reply #20 on: 02/19/07, 16:27 »
    Hey ,
    For Some reason i get an error

    heres the code that works

    my search
    PHP
    [code<?php

       $Server="Blah";           
       $DBuser="Blah";               
       $DBpass="Blah";
       $Database ="theojm_Clients";
       $Table="user_auth";
          $viewusername = stripslashes($_POST[$username]);
       $DBconnect = mysql_connect($Server, $DBuser, $DBpass);
       
       mysql_select_db($Database,$DBconnect);
       
       $Result = mysql_query("SELECT username, password, name, password, email, location, websitetitle,  websiteurl, personaltext, pic, ownpic, ownpiccheck FROM $Table WHERE username = '$username'");
       if (!mysql_num_rows($Result))
          die ("&Status=Error Reading Data.");
       
       $Break = mysql_fetch_array($Result);
       $name = $Break[name];
       $password = $Break[password];
       $email = $Break[email];
       $location = $Break[location];
       $websitetitle = $Break[websitetitle];
       $websiteurl = $Break[websiteurl];
       $personaltext = $Break[personaltext];
       $pic = $Break[pic];
       $ownpic = $Break[ownpic];
       $ownpiccheck = $Break[ownpiccheck];

       $Data = "&name=" . $name . "&password=" . $password . "&repassword=" . $password . "&email=" . $email . "&location=" . $location . "&websitetitle=" . $websitetitle . "&websiteurl=" . $websiteurl . "&personaltext=" . $personaltext . "&pic=" . $pic . "&ownpic=" . $ownpic . "&ownpiccheck=" . $ownpiccheck . "&Loaded=True";


          echo ($Data);

    ?>[/code]

     and all i did was I added more fields.. its the same script but more fields

    Same PHP but More Fields
    [code]<?php
            
          $Server="Blah";           
       $DBuser="Blah";               
       $DBpass="Blah";
       $Database ="theojm_Clients";
       $Table="Registration";
          $viewusername = stripslashes($_POST[$ownersname]);
       $DBconnect = mysql_connect($Server, $DBuser, $DBpass);
       
       mysql_select_db($Database,$DBconnect);
       
       $Result = mysql_query("SELECT ownersname, address, city, state, zip, phonenum, cellnum, emergencynum, typeone, typetwo, typethree, petone, pettwo, petthree, breedone, breedtwo, breedthree, bornone, borntwo, bornthree, sexone, sextwo, sexthree, barkerone, barkertwo, barkerthree, codeone, codetwo, codethree, descriptions, instructions FROM $Table WHERE ownersname = '$ownersname'");
       if (!mysql_num_rows($Result))
          die ("&Status=Error Reading Data.");
       
          $Break = mysql_fetch_array($Result);
          $ownersname = $Break[ownersname];
       $address = $Break[address];
       $state = $Break[state];
       $zip = $Break[zip];
          $phonenum = $Break[phonenum];
       $cellnum = $Break[cellnum];
       $emergencynum = $Break[emergencynum];
       $typeone = $Break[typeone];
       $typetwo = $Break[typetwo];
       $typethree = $Break[typethree];
       $petone = $Break[petone];
       $pettwo = $Break[pettwo];
       $petthree = $Break[petthree];
       $breedone = $Break[breedone];
       $breedtwo = $Break[breedtwo];
       $breedthree = $Break[breedthree];
          $bornone = $Break[bornone];
       $borntwo = $Break[borntwo];
       $bornthree = $Break[bornthree];
       $sexone = $Break[sexone];
       $sextwo = $Break[sextwo];
       $sexthree = $Break[sexthree];
       $sizeone = $Break[sizeone];
       $sizetwo = $Break[sizetwo];
       $sizethree = $Break[sizethree];
       $barkerone = $Break[barkerone];
       $barkertwo = $Break[barkertwo];
       $barkerthree = $Break[barkerthree];
       $codeone = $Break[codeone];
       $codetwo = $Break[codetwo];
       $codethree = $Break[codethree];
          $instructions = $Break[instructions];
       $descriptions = $Break[descriptions];

       $Data = "&ownersname=" . $ownersname . "&address=" . $address . "&city=" . $city . "&state=" . $state . "&zip=" . $zip . "&phonenum=" . $phonenum . "&cellnum=" . $cellnum . "&emergencynum=" . $emergencynum . "&typeone=" . $typeone . "&typetwo=" . $typetwo . "&typethree=" . $typethree ."&petone=" . $petone . "&pettwo=" . $pettwo . "&petthree=" . $petthree ."&breedone=" . $breedone . "&breedtwo=" . $breedtwo . "&breedthree=" . $breedthree ."&bornone=" . $bornone . "&borntwo=" . $borntwo . "&bornthree=" . $bornthree ."&sexone=" . $sexone . "&sextwo=" . $sextwo . "&sexthree=" . $sexthree ."&sizeone=" . $sizeone . "&sizetwo=" . $sizetwo . "&sizethree=" . $sizethree . "&barkerone=" . $barkerone . "&barkertwo=" . $barkertwo . "&barkerthree=" . $barkerthree ."&codeone=" . $codeone . "&codetwo=" . $codetwo . "&codethree=" . $codethree . "&descriptions=" . $descriptions . "&instructions=" . $instructions . "&Loaded=True";

          echo ($Data);

    ?>code]

    And This Is The error i get now

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /Clients/ViewEdit.php on line 14

    What could i do?
    « Last Edit: 02/20/07, 00:19 by B-L-A-D-E »
    [shadow=Blue,left,300]Stephen Miller[/shadow]
    Aim:WICKIDxCLOWNxBOY
    E-Mail: MillerStephen@Hotmail.com

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re: Can I Do It Like This?
    « Reply #21 on: 02/24/07, 11:46 »
    access the data this way

    $Break['name'] ;)
    happy flashing
    8)
    Ronald