kiwis-are-cool Posted August 14, 2013 Share Posted August 14, 2013 When I run this script on my Localhost it generates the text fine, but it can't upload to the ftp. When I run the script on my web server (Shared hosting) it doesn't generate the text it stops after maybe three lines and can't upload either. They are not blocking Fwrite or uploading the file. I think i chmodded the folders and files correctly but i'm not sure. <?php include('db.php'); include('switch.php'); $query = "SELECT * FROM weapons ORDER BY steamid"; if ($stmt = $mysqli->prepare($query)) { $stmt->execute(); $stmt->bind_result($id, $steamid, $wepid, $weplvl, $weprare, $attr1, $attr2, $attr3, $attr4, $attr5, $attr6, $attr7, $attr8, $attr9, $attr10, $attr11, $attr12, $attr13, $attr14, $attr15, $attr16, $val1, $val2, $val3, $val4, $val5, $val6, $val7, $val8, $val9, $val10, $val11, $val12, $val13, $val14, $val15, $val16); while ($row = $stmt->fetch()) { $wep = $wepid; $wep = wepname($wep); $steamids[] = array( 'steamid' => $steamid ); $data[] = array( 'steam' => $steamid, 'wepid' => $wepid, 'weplvl' => $weplvl, 'wepname' => $wep, 'weprare' => $weprare, 'attr1' => $attr1, 'attr2' => $attr2, 'attr3' => $attr3, 'attr4' => $attr4, 'attr5' => $attr5, 'attr6' => $attr6, 'attr7' => $attr7, 'attr8' => $attr8, 'attr9' => $attr9, 'attr10' => $attr10, 'attr11' => $attr11, 'attr12' => $attr12, 'attr13' => $attr13, 'attr14' => $attr14, 'attr15' => $attr15, 'attr16' => $attr16, 'val1' => $val1, 'val2' => $val2, 'val3' => $val3, 'val4' => $val4, 'val5' => $val5, 'val6' => $val6, 'val7' => $val7, 'val8' => $val8, 'val9' => $val9, 'val10' => $val10, 'val11' => $val11, 'val12' => $val12, 'val13' => $val13, 'val14' => $val14, 'val15' => $val15, 'val16' => $val16, ); } $stmt->close(); } $arr = array_unique($steamids, SORT_REGULAR); $myFile = "weapons/tf2items.weapons.txt"; $fh = fopen($myFile, 'w+') or die("can't open file"); chmod("weapons/tf2items.weapons.txt", 0777); fwrite($fh, '"' . 'custom_weapons_v3' . '"' . "\r\n"); fwrite($fh, ' {' . "\r\n"); foreach($arr as $key => $a){ fwrite($fh, "\r\n"); $check = $a['steamid']; fwrite($fh, " $check"); fwrite($fh, "\r\n"); fwrite($fh, " {"); fwrite($fh, "\r\n"); foreach($data as $key => $r){ $check2 = $r['steam']; if($check == $check2){ fwrite($fh, ' "' . $r['wepid'] .'"' . " " . '//' . $r['wepname'] . "\r\n" ); fwrite($fh, " {" . "\r\n"); fwrite($fh, ' "level"' . ' "' . $r['weplvl'] . '"' . "\r\n"); fwrite($fh, ' "quality"' . ' ' . '"' . $r['weprare'] . '"' . "\r\n"); if($r['attr1'] === 0 || $r['attr1'] === ''){ fwrite($fh, ''); }else{ fwrite($fh, ' "1"' . ' "' . $r['attr1'] . ' ; ' . $r['val1'] . '"' . "\r\n"); } if($r['attr2'] === 0 || $r['attr2'] === ''){ fwrite($fh, ''); }else{ fwrite($fh, ' "2"' . ' "' . $r['attr2'] . ' ; ' . $r['val2'] . '"' . "\r\n"); } if($r['attr3'] === 0 || $r['attr3'] === ''){ fwrite($fh, ''); }else{ fwrite($fh, ' "3"' . ' "' . $r['attr3'] . ' ; ' . $r['val4'] . '"' . "\r\n"); } if($r['attr4'] === 0 || $r['attr4'] === ''){ fwrite($fh, ''); }else{ fwrite($fh, ' "4"' . ' "' . $r['attr4'] . ' ; ' . $r['val4'] . '"' . "\r\n"); } if($r['attr5'] === 0 || $r['attr5'] === ''){ fwrite($fh, ''); }else{ fwrite($fh, ' "5"' . ' "' . $r['attr5'] . ' ; ' . $r['val5'] . '"' . "\r\n"); } if($r['attr6'] === 0 || $r['attr6'] === ''){ fwrite($fh, ''); }else{ fwrite($fh, ' "6"' . ' "' . $r['attr6'] . ' ; ' . $r['val6'] . '"' . "\r\n"); } if($r['attr7'] === 0 || $r['attr7'] === ''){ fwrite($fh, ''); }else{ fwrite($fh, ' "7"' . ' "' . $r['attr7'] . ' ; ' . $r['val7'] . '"' . "\r\n"); } if($r['attr8'] === 0 || $r['attr8'] === ''){ fwrite($fh, ''); }else{ fwrite($fh, ' "8"' . ' "' . $r['attr8'] . ' ; ' . $r['val8'] . '"' . "\r\n"); } if($r['attr9'] === 0 || $r['attr9'] === ''){ fwrite($fh, ''); }else{ fwrite($fh, ' "9"' . ' "' . $r['attr9'] . ' ; ' . $r['val9'] . '"' . "\r\n"); } if($r['attr10'] === 0 || $r['attr10'] === ''){ fwrite($fh, ''); }else{ fwrite($fh, ' "10"' . ' "' . $r['attr10'] . ' ; ' . $r['val10'] . '"' . "\r\n"); } if($r['attr11'] === 0 || $r['attr11'] === ''){ fwrite($fh, ''); }else{ fwrite($fh, ' "11"' . ' "' . $r['attr10'] . ' ; ' . $r['val10'] . '"' . "\r\n"); } if($r['attr12'] === 0 || $r['attr12'] === ''){ fwrite($fh, ''); }else{ fwrite($fh, ' "12"' . ' "' . $r['attr12'] . ' ; ' . $r['val12'] . '"' . "\r\n"); } if($r['attr13'] === 0 || $r['attr13'] === ''){ fwrite($fh, ''); }else{ fwrite($fh, ' "13"' . ' "' . $r['attr13'] . ' ; ' . $r['val13'] . '"' . "\r\n"); } if($r['attr14'] === 0 || $r['attr14'] === ''){ fwrite($fh, ''); }else{ fwrite($fh, ' "14"' . ' "' . $r['attr14'] . ' ; ' . $r['val14'] . '"' . "\r\n"); } if($r['attr15'] === 0 || $r['attr15'] === ''){ fwrite($fh, ''); }else{ fwrite($fh, ' "15"' . ' "' . $r['attr15'] . ' ; ' . $r['val15'] . '"' . "\r\n"); } if($r['attr16'] === 0 || $r['attr16'] === ''){ fwrite($fh, ''); }else{ fwrite($fh, ' "16"' . ' "' . $r['attr16'] . ' ; ' . $r['val16'] . '"' . "\r\n"); } fwrite($fh, " }" . "\r\n"); fwrite($fh, "\r\n"); } } fwrite($fh, " }" . "\r\n"); fwrite($fh, "\r\n"); } fwrite($fh, "}"); fclose($fh); $ftp_server="ip"; $ftp_user_name="user"; $ftp_user_pass="pass"; $file = "weapons/tf2items.weapons.txt"; $remote_file = "tf/addons/sourcemod/configs/tf2items.weapons.txt"; $conn_id = ftp_connect($ftp_server); if(ftp_login($conn_id, $ftp_user_name, $ftp_user_pass)) { if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) { echo "<p hidden>" . "success" . "<p>"; echo "<p style='color: green;'>" . "Successfully Updated" . "<p>"; exit; } else { echo "There was a problem while uploading $file\n"; exit; } } else { echo "Couldn't connect as $ftp_user_name\n"; } ftp_close($conn_id); ?> Link to comment https://forums.phpfreaks.com/topic/281182-fwrite-not-displaying-all-the-data/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.