Web Analytics Made Easy -
StatCounter php - CodingForum

Announcement

Collapse
No announcement yet.

php

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • php

    why does this not work?

    PHP Code:
    function call(){
    global 
    $getdata,$data;
    $getdata="";
        
    $sql="select guide,current_price,qty_left,p_and_p from current_drops";
        
    $result=mysql_query($sql);
        while (
    $data=mysql_fetch_array($result)){
            
    $getdata="guide=".$data[0]."&pricedrop=".$data[1]."&qtyleft=".$data[2]."&pandp=".$data[3];
        }
        return 
    $getdata;
    }

    $rose=call();
    print_r($rose); 
    pete

  • #2
    difficult to say.

    A few ideas:
    1- Why did you declare $getdata and $data as global?
    2- It looks like you want to change your getdata= line to:

    PHP Code:
    $getdata.="guide=".$data[0]."&pricedrop=".$data[1]."&qtyleft=".$data[2]."&pandp=".$data[3]; 
    3. Why use 'print_r' instead of just 'print' ?

    4. I assume above your code you've already successfully connected to the database/server ?

    5 - when in doubt, insert debugging code, like this:

    PHP Code:
    function call(){
    $getdata="";
        
    $sql="select guide,current_price,qty_left,p_and_p from current_drops";
        
    $result=mysql_query($sql) or Die (mysql_error());
        if (
    $mysql_num_rows($result) != {
        while (
    $data=mysql_fetch_array($result)){
            
    $getdata.="guide=".$data[0]."&pricedrop=".$data[1]."&qtyleft=".$data[2]."&pandp=".$data[3];
        }
    } else {
        print 
    "No records returned";
    }
        return 
    $getdata;
    }

    $rose=call();
    print_r($rose); 

    HTH,
    -Celt

    Comment


    • #3
      Re: php

      Originally posted by ygrouk
      why does this not work?

      PHP Code:
      function call(){
      global 
      $getdata,$data;
      $getdata="";
          
      $sql="select guide,current_price,qty_left,p_and_p from current_drops";
          
      $result=mysql_query($sql);
          while (
      $data=mysql_fetch_array($result)){
              
      $getdata="guide=".$data[0]."&pricedrop=".$data[1]."&qtyleft=".$data[2]."&pandp=".$data[3];
          }
          return 
      $getdata;
      }

      $rose=call();
      print_r($rose); 
      pete
      You need to read our posting guidelines before creating anymore topics
      Spookster
      CodingForum Supreme Overlord
      All Hail Spookster

      Comment


      • #4
        Thanks

        Thanks guys for the replies, i realised why when looking at the database, a field was missing

        sorry
        pete

        Comment


        • #5
          2) Type in a subject that summarizes your question- A great way to turn off other members wanting to help you is to type an incomplete or silly subject for your post. Examples of poor subject titles include:

          - "Help!"
          - "I'm a newbie...be gentle"
          - "How can I..."
          - "Urgent...deadline tomorrow!"
          ~Designer's Toolz~

          Comment


          • #6
            Re: Thanks

            Thanks guys for the replies, i realised why when looking at the database, a field was missing
            Fatal Error: You have to create an instance of class clBrain::think before starting clForum::ask.

            *scnr*

            sorry
            pete
            Don't worry ;-)
            piz
            www.united-scripts.com
            www.codebattles.org

            Comment

            Working...
            X