Thread: MYSQL Problem
View Single Post
Old 02-10-2008, 03:46 PM   #1 (permalink)
Mike9182
 
Super Techie

Join Date: Sep 2006

Location: Altoona, PA

Posts: 250

Mike9182 is on a distinguished road

Send a message via AIM to Mike9182
Default MYSQL Problem

What do I need to change in this code? It writes successfully to the database but instead of writing the data in the variable it writes the variable name. For example it writes $location in as the url.

Here is the code where the problem most likely is:
PHP Code:
$sql 'INSERT INTO `nuke_downloads_downloads` (`lid`, `cid`, `sid`, `title`, `url`, `description`, `date`, `name`, `email`, `hits`, `submitter`, `downloadratingsummary`, `totalvotes`, `totalcomments`, `filesize`, `version`, `homepage`) VALUES (\'\', \'2\', \'0\', \'$name[$reps]\', \'$location[$reps]\', \'BF2 Demo Recording\', \'$time\', \'\', \'\', \'0\', \'\', \'0.0000\', \'0\', \'0\', \'$size\', \'\', \'\');';
        
mysql_query($sql$con) ; 
Here is all the code:
PHP Code:
<?
//get date and time
$time date("Y-m-d H:i:s") ;

// Gather file information
$file = (scandir("/home/content/c/l/a/clan3rd/html/demos/demos/")) ;
$demo ".bf2demo" ;
$count ;

foreach (
$file as $fname)
{
    if (
strpos($fname,$demo) != FALSE)
        {
        
$count $count ;
        
$dname str_ireplace($demo,"",$fname) ;
        
$name[$count] = $dname ;
        
$location[$count] = "http://demos.1stmercenaries.com/" $fname ;
        
$exactfile[$count] = $fname ;
        }
}


$hostname='removed for security';
$username='removed for security';
$password='removed for security';
$con mysql_connect($hostname,$username$password) OR DIE ('Unable to connect to database! Please try         again later.') ;
mysql_select_db("Poison555_2"$con) ;

$result mysql_query("SELECT * FROM `nuke_downloads_downloads` ");
$result2 mysql_query("SELECT * FROM `nuke_downloads_downloads` ");

while(
$row mysql_fetch_array($result))
    {
    
$id $row['lid'];
    }

$existing mysql_fetch_array($result2) ;

$reps ;    
foreach (
$location as $row2)
    {
    echo 
$location[$reps] ;
    
$size filesize($exact_file[$reps]) ;
    
$search array_search($row2,$existing) ;
    echo 
$search ;
    if(
strlen($search) > 0)
        
$execute "no" ;
    else
        
$execute "yes" ;
    if(
$execute == "yes")
        {
        
$sql 'INSERT INTO `nuke_downloads_downloads` (`lid`, `cid`, `sid`, `title`, `url`, `description`, `date`, `name`, `email`, `hits`, `submitter`, `downloadratingsummary`, `totalvotes`, `totalcomments`, `filesize`, `version`, `homepage`) VALUES (\'\', \'2\', \'0\', \'$name[$reps]\', \'$location[$reps]\', \'BF2 Demo Recording\', \'$time\', \'\', \'\', \'0\', \'\', \'0.0000\', \'0\', \'0\', \'$size\', \'\', \'\');';
        
mysql_query($sql$con) ;
        
$id $id ;
        
// mysql_query(INSERT INTO `nuke_downloads_downloads` ( `lid` , `cid` , `sid` , `title` , `url` , `description` , `date` , `name` , `email` , `hits` , `submitter` , `downloadratingsummary` , `totalvotes` , `totalcomments` , `filesize` , `version` , `homepage` ) VALUES ('$id', '2', '0', '$name[$reps]', '$location[$reps]', 'BF2 Demo Recording', '$time', '', '', '0', '', '0.0000', '0', '0', '$size', '', ''))
        
}
        
$reps $reps ;
    }
mysql_close($con);
echo 
"Demo list refreshed" ;
  
?>

__________________

My Comp:
Antec 900
Gigabyte DS3
EVGA 8800GTS (G92)
Antec TruPower 650 watt psu
Core 2 Duo E6700 @ 3.3Ghz
G.Skill 4GB DDR2-800
2 x Seagate Barracuda 250GB HDD in RAID 0
1 x Seagate Barracuda 500GB HDD
ACER 19" 5ms monitor
ZALMAN CNPS9500 cpu fan/heatsink
Mike9182 is offline