|
-
Jun 30th, 2002, 03:25 PM
#1
Thread Starter
Fanatic Member
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'";
$result= mysql_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?
-
Jun 30th, 2002, 03:51 PM
#2
for one, what is line 49, and 2 you can't str_replace for those. you have to use ereg_replace
-
Jun 30th, 2002, 04:47 PM
#3
Thread Starter
Fanatic Member
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?
-
Jun 30th, 2002, 05:40 PM
#4
Fanatic Member
$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 )
-
Jul 1st, 2002, 12:03 PM
#5
Fanatic Member
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'";
$result= mysql_query($sql);
}
-
Jul 1st, 2002, 10:16 PM
#6
Junior Member
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'";
$result= mysql_query($sql);
}
}
-
Jul 1st, 2002, 10:22 PM
#7
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|