2011-11-08 5 views
0

私のサイトのユーザーが登録するフォームに記入すると、この情報がデータベースに追加されます。私は情報もCSVファイルに書き込まれるようにしようとしています。私がこれまでに持っていたコードでは、このエラーが表示されます:CSVへの書き込みエラー - fopen()[function.fopen]:ファイル名が空ではない

警告:fopen()[function.fopen]:/home/content/m/a/t/matronryan/html/sendmail3.phpのファイル名は空にできませんline 122

Line 122:$ fp = fopen($ filename、 "w");

問題の内容を解決できません。コードは次のとおりです。

$first_name = $_POST['first_name']; // required 
$last_name = $_POST['last_name']; // required 
$email_from = $_POST['email']; // required 
$stilldonate = $_POST['stilldonate']; // not required 
$phone = $_POST['phone']; 
$bid = $_POST['bid']; // required 
$item = $_POST['item']; 
$address1 = $_POST['address1']; // required 
$address2 = $_POST['address2']; 
$city = $_POST['city']; 
$county = $_POST['county']; // required 
$postcode = $_POST['postcode']; // required 
$updated = $_POST['updated']; 

include('db_functions.php'); 
    connect_to_db(); 
    $query="insert into auctionusers (firstname, lastname, address1, address2, city, county, postcode, email, phone, bid, stilldonate, item, updated) values ('$first_name', '$last_name', '$address1', '$address2', '$city', '$county', '$postcode', '$email_from', '$phone', '$bid', '$stilldonate', '$item', '$updated')"; 
    $result=mysql_query($query); 


$filename == 'auctionusers.csv'; 
$fp = fopen($filename, "w"); 

$res = mysql_query("SELECT * FROM auctionusers"); 

// fetch a row and write the column names out to the file 
$row = mysql_fetch_assoc($res); 
$line = ""; 
$comma = ""; 
foreach($row as $name => $value) { 
    $line .= $comma . '"' . str_replace('"', '""', $name) . '"'; 
    $comma = ","; 
} 
$line .= "\n"; 
fputs($fp, $line); 

// remove the result pointer back to the start 
mysql_data_seek($res, 0); 

// and loop through the actual data 
while($row = mysql_fetch_assoc($res)) { 

    $line = ""; 
    $comma = ""; 
    foreach($row as $value) { 
     $line .= $comma . '"' . str_replace('"', '""', $value) . '"'; 
     $comma = ","; 
    } 
    $line .= "\n"; 
    fputs($fp, $line); 

} 

fclose($fp); 

mysql_close(); 


header('location: index2.php?op=Thank You&id=bid'); 

} 
?> 

誰でも何が間違っていますか?

答えて

1

変更:

$filename == 'auctionusers.csv'; 

:を

$filename = 'auctionusers.csv'; 

ダブル等しい変数時ブール演算を行います。誤って余分な等号を追加したのでしょうか?

+0

あなたはスターです。私が一文字間違いを犯して問題を突き止めるのに1時間を費やす時間は信じられないほどです。私のためにこれをクリアしてくれてありがとう! – nutman

関連する問題