Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> MySQL
Author Message
contest
New Member
New Member



Joined: Mar 24, 2006
Posts: 4

PostPosted: Wed Apr 05, 2006 11:16 am Reply with quote

I have one code here, it should upload data from *.dbf file to database, but unfortunately it does not work, something is wrong here. Here's the code:


Code:
include("../mysql.php"); 


function UpdatePlayerRosters($rosterFileName, $oldtablename) {
include("../config.php");

if ( !$fp = dbase_open($rosterFileName,0) ) {
echo "Cannot open $dbname\n";
exit;
}

$db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, false);

if ($oldtablename == "") {
$oldtablename = date('YmdHi',mktime());
}

$sql = "CREATE TABLE players_" . $oldtablename . " LIKE players";
if ( !($result = $db->sql_query($sql)) ) {
echo "<br>create new table failed";
exit;
}


$sql = "insert into players_" . $oldtablename . " select * from players";
if ( !($result = $db->sql_query($sql)) ) {
echo "<br>update new table failed";
exit;
}

$sql = "TRUNCATE players";
if ( !($result = $db->sql_query($sql)) ) {
echo "<br>Truncate failed";
exit;
}

$sql = "LOCK TABLES players WRITE";
if ( !($result = $db->sql_query($sql)) ) {
echo "<br>Truncate failed";
exit;
}

echo "<TABLE border=0 cellpadding=0 cellspacing=0>";

$nr = dbase_numrecords($fp); // Number of records.
for ($i=1; $i <= $nr; $i++) { // From 1 to $nr as you know.
$dbfRecord = dbase_get_record($fp,$i);
// echo "<pre>";
// print_r($dbfRecord);

$teamID = $dbfRecord[97];
$deleted = $dbfRecord["deleted"];


$NAME = trim($dbfRecord[1]);
$FNAME = trim($dbfRecord[2]);
$PLAYERID = $dbfRecord [4];
$NUMBER = $dbfRecord [5];
if ($NUMBER == -1) {
$NUMBER = "00";
}
$POSITION = $dbfRecord [6];
$POSITION2 = $dbfRecord [7];
$HEIGHT = $dbfRecord [8];
$WEIGHT = $dbfRecord [9];
$YEARSEXP = $dbfRecord [10];
$SCHOOLNUM = $dbfRecord [11];
$OVERALLRTG = $dbfRecord [68];
$PLAYRVALUE = $dbfRecord [69];
$FGPBASE = $dbfRecord [70];
$THREEPTBAS = $dbfRecord [71];
$FTPBASE = $dbfRecord [72];
$DNKABILITY = $dbfRecord [73];
$STLABILITY = $dbfRecord [74];
$BLKABILITY = $dbfRecord [75];
$OREABILITY = $dbfRecord [76];
$DREABILITY = $dbfRecord [77];
$BALABILITY = $dbfRecord [78];
$OFFABILITY = $dbfRecord [79];
$DEFABILITY = $dbfRecord [80];
$SPEED = $dbfRecord [81];
$QUICK = $dbfRecord [82];
$JUMP = $dbfRecord [83];
$DRIBBLE = $dbfRecord [84];
$DSTRENGTH = $dbfRecord [85];
$DHARDY = $dbfRecord [86];
$DSHOOTRANG = $dbfRecord [87];
$FATIGUE = $dbfRecord [88];
$INSIDESC = $dbfRecord [89];
$PRIMACY = $dbfRecord [90];
$SCOREAREA = $dbfRecord [91];
$ORIGTEAM = $dbfRecord [96];
$TEAM = $dbfRecord [97];
$ROSTERPOS = $dbfRecord [98];
$BIRTHDATE = substr($dbfRecord [99],0,4) . "-" . substr($dbfRecord [99],4,2) . "-" . substr($dbfRecord [99],6,2) ;
$DPLACE = $dbfRecord [101];
$DROUND = $dbfRecord [102];
$DOVERALL = $dbfRecord [103];
$DRAFTYEAR = $dbfRecord [104];
$DRAFTEDBY = trim($dbfRecord [105]);
$SALARY = $dbfRecord [136];
$YRSSIGNED = $dbfRecord [138];
$YRSREMAIN = $dbfRecord [139];

$currentPlayer = $FNAME . " " . $NAME . " " . $SALARY . " " . $YRSREMAIN . "/" . $YRSSIGNED ;

// echo "$currentPlayer<BR>";

if (($teamID <= 29 or $teamID == 40) AND $deleted == 0) {

$playerIDFormatted = sprintf("%04d", $PLAYERID);
$playerImageName = "player_" . $playerIDFormatted;
echo "<tr>";
echo "<td><img width=65 height=90 src=\"../images/players/" . $playerImageName . ".jpg\" ></img></td>";
echo "<td>$PLAYERID. $FNAME $NAME ($TEAM)</td>";
echo "<td>$SALARY</td>";
echo "<td>$YRSREMAIN / $YRSSIGNED</td>";
echo "<td>$OVERALLRTG</td>";
echo "</tr>";


$sql = "insert into players values(
\"$NAME\",
\"$FNAME\",
\"$PLAYERID\",
\"$NUMBER\",
\"$POSITION\",
\"$POSITION2\",
\"$HEIGHT\",
\"$WEIGHT\",
\"$YEARSEXP\",
\"$SCHOOLNUM\",
\"$OVERALLRTG\",
\"$PLAYRVALUE\",
\"$FGPBASE\",
\"$THREEPTBAS\",
\"$FTPBASE\",
\"$DNKABILITY\",
\"$STLABILITY\",
\"$BLKABILITY\",
\"$OREABILITY\",
\"$DREABILITY\",
\"$BALABILITY\",
\"$OFFABILITY\",
\"$DEFABILITY\",
\"$SPEED\",
\"$QUICK\",
\"$JUMP\",
\"$DRIBBLE\",
\"$DSTRENGTH\",
\"$DHARDY\",
\"$DSHOOTRANG\",
\"$FATIGUE\",
\"$INSIDESC\",
\"$PRIMACY\",
\"$SCOREAREA\",
\"$ORIGTEAM\",
\"$TEAM\",
\"$ROSTERPOS\",
\"$BIRTHDATE\",
\"$DPLACE\",
\"$DROUND\",
\"$DOVERALL\",
\"$DRAFTYEAR\",
\"$DRAFTEDBY\",
\"$SALARY\",
\"$YRSSIGNED\",
\"$YRSREMAIN\"
); ";

$result = $db->sql_query($sql);

} else {
$playerIDFormatted = sprintf("%04d", $PLAYERID);
$playerImageName = "player_" . $playerIDFormatted;
echo "<tr>";
echo "<td><img width=65 height=90 src=\"../images/players/" . $playerImageName . ".jpg\" ></img></font></td>";
echo "<td><font color=red>$PLAYERID. $FNAME $NAME ($TEAM)</font></td>";
echo "<td><font color=red>$SALARY</font></td>";
echo "<td><font color=red>$YRSREMAIN / $YRSSIGNED</font></td>";
echo "<td><font color=red>$OVERALLRTG</font></td>";
echo "</tr>";

}
}
echo "</TABLE>";

$sql = "UNLOCK TABLES";
if ( !($result = $db->sql_query($sql)) ) {
echo "<br>Truncate failed";
exit;
}

}


function CreateRosterUploadBox () {
echo "<form action=\"rosteradmin.php\" method=\"POST\" enctype=\"multipart/form-data\">
Send these files:<br>";
echo "Roster: <input name=\"rosterfile[]\" type=\"file\"><br>\n";
echo "Old Roster Table Name (default is todays date): <input name=\"oldtablename\" type=\"text\"><br>\n";
echo "<input type=submit value=\"Send files\">\n";

echo "</form>\n";
}


//UpdatePlayerRosters("players.dbf");

switch ($rosterfile[0]) {
case '':
CreateRosterUploadBox();
break;

default:
UpdatePlayerRosters($rosterfile[0], $oldtablename);

}




?>
</TABLE>


What is wrong..? Why it does not work..?
 
View user's profile Send private message
hitwalker
Sells PC To Pay For Divorce



Joined:
Posts: 5661

PostPosted: Wed Apr 05, 2006 3:47 pm Reply with quote

thats nice,you expect people to know whats wrong ?
Any info please?
any errors?
have you set display errors on?
Uploading a file is simple said dependable on a few things...
Like having the right to upload and an existing directory to upload to..and folder must be set to 777
 
View user's profile Send private message
contest







PostPosted: Thu Apr 06, 2006 11:59 am Reply with quote

hitwalker wrote:
thats nice,you expect people to know whats wrong ?
Any info please?
any errors?
have you set display errors on?
Uploading a file is simple said dependable on a few things...
Like having the right to upload and an existing directory to upload to..and folder must be set to 777


Actually, it doesn't have to send a particular file into the server. It just should read the data from *.dbf file and insert it into the databases' table. Here's what I've got in the instructions:

3. Browse to the “players.dbf” of the rosters you wish to load
4. Hit the “Send” button to upload the rosters
5. You will now see the names of all the players being loaded
6. You can check all the players were loaded by using the “Player List” under the “Player” section.

But when I choose the file and hit send, browser loads a few seconds and goes back to default and nothing is loaded... As instructions says I should see the names of all the players being loaded, but unfortunately I don't. I can't find what's wrong anywhere and why it does not load data into the database...
 
hitwalker







PostPosted: Thu Apr 06, 2006 12:19 pm Reply with quote

well as it goes back to default indicates that the action itself isnt working.
if it wasnt allowed you would get a error somehow.
But the players.dbf is the file that holds the info right...?
try changing rights on that file,the script has to read in the file...
im just guessing here...
 
contest







PostPosted: Thu Apr 06, 2006 1:09 pm Reply with quote

hitwalker wrote:
well as it goes back to default indicates that the action itself isnt working.
if it wasnt allowed you would get a error somehow.
But the players.dbf is the file that holds the info right...?
try changing rights on that file,the script has to read in the file...
im just guessing here...


yes, players.dbf holds all the info. This file is in my hard drive so I can't change any attributes.. Here's the script: http://www.detonator.sutartis.net/contesttt3/admin/rosteradmin.php
and here's the file: http://www.detonator.sutartis.net/contesttt3/players.dbf
you can try upload it yourself to see what it looks like... Forum is my last hope, because I have no ideas anymore..
 
hitwalker







PostPosted: Thu Apr 06, 2006 1:14 pm Reply with quote

well are you hosting that upload script?
Indeed it doesnt show much..
why it fails could be a thousand reasons..
 
contest







PostPosted: Thu Apr 06, 2006 1:31 pm Reply with quote

hitwalker wrote:
well are you hosting that upload script?
Indeed it doesnt show much..
why it fails could be a thousand reasons..


yes it's in my server.. Exactly, there could be a thousand reasons and therefore I don't even know where to look for an error.. Maybe this script can't run on Linux server.. But it's very slim chance.. Here's all documentation of this project: http://www.detonator.sutartis.net/nball_documentation.txt
It looks very simple but script doesn't work as it should..
 
hitwalker







PostPosted: Thu Apr 06, 2006 1:54 pm Reply with quote

well unfortunately im not into the gaming stuff..
what about other website?
any help from them that runs the same script?
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> MySQL

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©