Results 1 to 7 of 7

Thread: any ideas?

  1. #1

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919

    any ideas?

    hey
    im working on a download thingy for my site, and people can submit downloads, and mirrors for that download

    this is the code for the submit download, i have 2 tables, i "downloads" which stores the main download stuff, then "mirrors" where the urls are stored. in mirrors theres a column called "did", which holds the download id from "downloads", which that number is autoincrement.

    im trying to get that number after i insert it into the DB, and it isn't working..any ideas?

    thanks


    PHP Code:
    $db mysql_connect("localhost""fragblast""");
                
    mysql_select_db("fragblast",$db);
                
                
    $review=str_replace("\n","<br>",$describ);
                    
                
    $sql "INSERT INTO download (title, auth_id, auth_name, describ, size, cat) VALUES ('$title', '$userid', '$username', '$describ', '$size', '$cat')";
                
    $result mysql_query($sql);


                
    $sql="SELECT * FROM download WHERE title='$title' AND auth_id='$userid' AND auth_name='$username' AND describ='$describ' AND size='$size' AND cat='$cat')";
                
    $result=mysql_query($sql);

                while (
    $row mysql_fetch_array($result)) { //LINE 49
                    
    echo $row['id'];    //debug
                    
    $id=$row['id'];

                    
    $sql "INSERT INTO mirrors (did,site,name) VALUES ('$id', '$mirrorname', '$url')";
                    
    $result mysql_query($sql);

                    
    $sql "UPDATE stats SET count = count + 1 WHERE name='$cat'";
                    
    $resultmysql_query($sql);
                } 

    the error is:
    Warning: Supplied argument is not a valid MySQL result resource in C:\Inetpub\wwwroot\downloads\add.php on line 49
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  2. #2
    scoutt
    Guest
    for one, what is line 49, and 2 you can't str_replace for those. you have to use ereg_replace

  3. #3

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    line 49 is
    while ($row = mysql_fetch_array($result)) { //LINE 49


    and str_replace works, ive used it before. i can take that line out anyway
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  4. #4
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    $sql="SELECT * FROM download WHERE title='$title' AND auth_id='$userid' AND auth_name='$username' AND describ='$describ' AND size='$size' AND cat='$cat')";

    Take out that )
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  5. #5
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    Try this:
    PHP Code:
    $db mysql_connect("localhost""fragblast""");
                
    mysql_select_db("fragblast",$db);
                
                
    $review=str_replace("\n","<br>",$describ);
                    
                
    $sql "INSERT INTO download (title, auth_id, auth_name, describ, size, cat) VALUES ('$title', '$userid', '$username', '$describ', '$size', '$cat')";
                
    $result mysql_query($sql);

                
    $selectId mysql_insert_id($result);

                
    $sql="SELECT * FROM download WHERE id='$selectId')";
                
    $result=mysql_query($sql);

                while (
    $row mysql_fetch_array($result)) { //LINE 49
                    
    echo $row['id'];    //debug
                    
    $id=$row['id'];

                    
    $sql "INSERT INTO mirrors (did,site,name) VALUES ('$id', '$mirrorname', '$url')";
                    
    $result mysql_query($sql);

                    
    $sql "UPDATE stats SET count = count + 1 WHERE name='$cat'";
                    
    $resultmysql_query($sql);
                } 
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  6. #6
    Junior Member
    Join Date
    Jul 2002
    Location
    San Diego, CA, U.S.A
    Posts
    30
    wouldn't it be better to double check your queries:

    PHP Code:
    $db mysql_connect("localhost""fragblast""");
                
    mysql_select_db("fragblast",$db);
                
                
    $review=str_replace("\n","<br>",$describ);
                    
                
    $sql "INSERT INTO download (title, auth_id, auth_name, describ, size, cat) VALUES ('$title', '$userid', '$username', '$describ', '$size', '$cat')";
    if(
    mysql_query($sql))
    {
                
    $selectId mysql_insert_id($result);

                
    $sql="SELECT * FROM download WHERE id='$selectId')";
                
    $result=mysql_query($sql);

                while (
    $row mysql_fetch_array($result)) { //LINE 49
                    
    echo $row['id'];    //debug
                    
    $id=$row['id'];

                    
    $sql "INSERT INTO mirrors (did,site,name) VALUES ('$id', '$mirrorname', '$url')";
                    
    $result mysql_query($sql);

                    
    $sql "UPDATE stats SET count = count + 1 WHERE name='$cat'";
                    
    $resultmysql_query($sql);
                }


  7. #7

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    i had stuff in there for debugging purposes, but i took them out since it works now

    cpradio: your idea didn't work, but i got mine working. thanks tho
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

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