1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need quick help because I am stupid.

Discussion in 'PHP' started by aaron_nimocks, Oct 15, 2005.

  1. #1
    I can connect to the database, figured that out.

    Now I need to grab out of the products table the field pName and assign it a variable so I can use it.

    Could someone help me out with this code real quick pls? :)

    I tried this but I guess I am way off

    $rs_query=mysql_query($q_query);
    $title=$rs_query["pName"];
     
    aaron_nimocks, Oct 15, 2005 IP
  2. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try this:

    $rs_query = mysql_query($q_query);
    if(!$rs_query) {
    $err=mysql_error();
    print $err;
    exit();
    }
    if(mysql_affected_rows()==0){
    print "no record found.";
    }
    else {
    $row=mysql_fetch_array($rs_query);
    $title=$row["pName"];
    }
     
    daboss, Oct 15, 2005 IP
  3. aaron_nimocks

    aaron_nimocks Im kind of a big deal Staff

    Messages:
    5,563
    Likes Received:
    627
    Best Answers:
    0
    Trophy Points:
    420
    #3
    Hmmm got a Query was empty
     
    aaron_nimocks, Oct 15, 2005 IP
  4. HeadBuilder

    HeadBuilder Peon

    Messages:
    68
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yes, I believe you're missing the mysql_fetch_array part...
     
    HeadBuilder, Oct 15, 2005 IP
  5. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #5
    well, is the criteria you're specifying in your query correct? :)

    go to phpmyadmin and key that query in to see if you get any results...
     
    daboss, Oct 16, 2005 IP
  6. DavidAusman

    DavidAusman Peon

    Messages:
    399
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #6
    $rs_query = mysql_query($q_query);
    while($result = mysql_fetch_array($rs_query)) {
    $title=$result["pName"];
    }

    This should work fine
     
    DavidAusman, Oct 16, 2005 IP
  7. aaron_nimocks

    aaron_nimocks Im kind of a big deal Staff

    Messages:
    5,563
    Likes Received:
    627
    Best Answers:
    0
    Trophy Points:
    420
    #7
    Still getting :

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/u3/rsessler/html/proddetail.php on line 16

    About ready to pay someone!
     
    aaron_nimocks, Oct 16, 2005 IP
  8. sarahk

    sarahk iTamer Staff

    Messages:
    28,494
    Likes Received:
    4,457
    Best Answers:
    123
    Trophy Points:
    665
    #8
    change it to

    $rs_query = mysql_query($q_query) or die(mysql_error() . '<br />'.$q_query);
    while($result = mysql_fetch_array($rs_query)) {
    $title=$result["pName"];
    }
    Code (markup):
    and let us know what it spits back...
     
    sarahk, Oct 16, 2005 IP
  9. aaron_nimocks

    aaron_nimocks Im kind of a big deal Staff

    Messages:
    5,563
    Likes Received:
    627
    Best Answers:
    0
    Trophy Points:
    420
    #9
    Blank page with Query was empty on it.

    I give up thanks for the help though. I did get it to pull off a name using basic stuff but it doesnt pull off the name with the correct ID from the page I am on.

    This is way above me so I am going to outsource this. May post in services soon.
     
    aaron_nimocks, Oct 16, 2005 IP
  10. sarahk

    sarahk iTamer Staff

    Messages:
    28,494
    Likes Received:
    4,457
    Best Answers:
    123
    Trophy Points:
    665
    #10
    Before you give up...

    If you have phpMyAdmin (which you should) run the query in there and see what happens. You may just have a typo or something...
     
    sarahk, Oct 16, 2005 IP