Front Office Football Central

Front Office Football Central (https://forums.operationsports.com/fofc//index.php)
-   FOF9, FOF8, and TCY Discussion (https://forums.operationsports.com/fofc//forumdisplay.php?f=33)
-   -   MP Draft Utility (https://forums.operationsports.com/fofc//showthread.php?t=63428)

3ric 01-17-2008 12:22 PM

Basic draft utility (originally by VPI, modified by Lonnie):
http://www.hfl-football.net/draft.zip
http://www.hfl-football.net/draft_database.zip
Installation instructions:
http://www.hfl-football.net/Draft%20Setup.doc

Ben E Lou 01-24-2008 03:58 AM

Bump. Giving this its own thread and linking in the new reference thread.

danimal 02-21-2008 12:14 PM

Is there anyone who'd be willing to help me set up this draft utility for my office league?

I think I am 80% of the way there, but I can't seem to figure out the last bit. The mysql database and the web pages are set up, but whenever I try to do something through the draft board web page (e.g., trade a pick, change my preference list, etc.), my action doesn't get updated in the mysql database.

I'd be happy to send you the php files. I'm very very new to php, so I could be missing something obvious. Any help you're willing to offer would be much appreciated.

Thanks!
Dan

3ric 02-21-2008 12:51 PM

Have you updated the index.php file with your login info and the mysql server your database is on?

danimal 02-21-2008 12:56 PM

Yes, I am able to log in with my phpBB username and password, and the draftboard.php and other informational pages are pulling data from the mysql database.

http://www.frontofficenfl.com/draft/draftboard.php

The problem seems to be when I try doing something on the index.php page. Whatever action I take doesn't seem to getting updated on the database.

I actually had to make some adjustments to the login portion of the index.php file to get that to work. The biggest change I made was initializing the $uid and $pwd variables using $_POST[]. That seemed to do the trick.

But I don't know how to get the rest of index.php to work.

3ric 02-21-2008 02:44 PM

Maybe there's a variable you've missed to initialize?
I have this section in my code:
$current_url = $_SERVER['PHP_SELF'];
$uid = $_POST['uid'];
$pwd = $_POST['pwd'];
$edittype = $_POST['edittype'];
$spick = $_POST['spick'];
$tradeteam = $_POST['tradeteam'];
$playerselection = $_POST['playerselection'];
$ptrade = $_POST['ptrade'];
$pref = $_POST['pref'];
$tid = $_POST['tid'];
$usage = $_POST['usage'];
$sortopt = $_POST['sortopt'];

gottimd 02-21-2008 02:54 PM

Isn't there somewhere to "Start" the clock?

danimal 02-21-2008 02:56 PM

Wow, there were definitely a few variables in that list I hadn't initialized.

That seems to have fixed part of the problem - I can now trade picks to other teams.

Any changes to the preference list, however, don't seem to be working. Are there other variables I'm missing? Perhaps it's the java script that's not working? I know nothing about java scripts, so I'm screwed if that's the case.

Here is the code I used to initialize the variables.

$uid = !isset($_POST['uid'])? "" : $_POST['uid'];
$pwd = !isset($_POST['pwd'])? "" : $_POST['pwd'];
$edittype = !isset($_POST['edittype'])? "" : $_POST['edittype'];
$spick = !isset($_POST['spick'])? NULL : $_POST['spick'];
$tradeteam = !isset($_POST['tradeteam'])? NULL : $_POST['tradeteam'];
$playerselection = !isset($_POST['playerselection'])? NULL : $_POST['playerselection'];
$ptrade = !isset($_POST['ptrade'])? NULL : $_POST['ptrade'];
$pref = !isset($_POST['pref'])? NULL : $_POST['pref'];
$tid = !isset($_POST['tid'])? NULL : $_POST['tid'];
$usage = !isset($_POST['usage'])? NULL : $_POST['usage'];
$sortopt = !isset($_POST['sortopt'])? NULL : $_POST['sortopt'];
$url = $_SERVER['PHP_SELF'];

marcmoustache 02-21-2008 03:11 PM

Have you made sure that the selectbox.js file is in the draft directory? You need that to update the pref lists.

danimal 02-21-2008 03:12 PM

Yup, selectbox.js is in the draft directory.

3ric 02-21-2008 03:21 PM

Quote:

Originally Posted by gottimd (Post 1665096)
Isn't there somewhere to "Start" the clock?


// Set $draftstatus to live or standby
$draftstatus = "live";

Not sure if that's what you mean?

danimal 02-21-2008 03:23 PM

Quote:

Originally Posted by 3ric (Post 1665126)
// Set $draftstatus to live or standby
$draftstatus = "live";

Not sure if that's what you mean?


Yes, but the preference list should work even if the draft is on standby, right?

3ric 02-21-2008 03:27 PM

Quote:

Originally Posted by danimal (Post 1665098)
Any changes to the preference list, however, don't seem to be working.


Have you double-checked all update queries and they are using the correct database tables?
for example:
$sql = "Update hfl_dutil_list set dclassid = $p where teamid = $tid and listorder = $cnt";

updates the preference list, but there are several more such lines

danimal 02-21-2008 03:47 PM

Quote:

Originally Posted by 3ric (Post 1665133)
Have you double-checked all update queries and they are using the correct database tables?
for example:
$sql = "Update hfl_dutil_list set dclassid = $p where teamid = $tid and listorder = $cnt";

updates the preference list, but there are several more such lines


It looks like all update queries are using the correct database tables:

$sql = "Update hfl_dutil_list set dclassid = $p where teamid = $tid and 'order' = $cnt";
$sql = "Update hfl_dutil_list set dclassid = '-1' where teamid = $tid and 'order' = $cnt";
$sql = "Update hfl_dutil_list set dclassid = '-1' where teamid = $tid and 'order' = $cnt";
$sql = "Update hfl_dutil_list set apply = 1 where teamid = $tid";
$sql = "Update hfl_dutil_list set apply = 2 where teamid = $tid";
$sql = "Update hfl_dutil_list set apply = 0 where teamid = $tid";
$sql = "Update hfl_dutil_list set sortvar = 1 where teamid = $tid";
$sql = "Update hfl_dutil_list set sortvar = 0 where teamid = $tid";

danimal 02-21-2008 03:56 PM

Just to be clear, I am able to change the way I sort through players (position vs. rating), and I am able to turn the preference list to on, off, or once.

The part that doesn't seem to be working is adding or removing players from the preference list. I'm looking through the code right now, but given my inexperience with php I could be missing something.

Would one of you be willing to take a look at my index.php file?

danimal 02-21-2008 04:06 PM

This seems to be the piece that should be taking preference list changes on index.php and putting them into the hfl_dutil_list database table.

Is there something wrong with the code here?


case "3":
$cnt = 0;
if( isset($pref) ){
foreach($pref as $p) {
$cnt++;
if ( $cnt <= 32 ) {
$sql = "Update hfl_dutil_list set dclassid = $p where teamid = $tid and 'order' = $cnt";
$result = mysql_query($sql,$db)or die("Bad query: ".mysql_error());
}
}
while ( $cnt <= 31 ) {
$cnt++;
$sql = "Update hfl_dutil_list set dclassid = '-1' where teamid = $tid and 'order' = $cnt";
$result = mysql_query($sql,$db)or die("Bad query: ".mysql_error());
}
}
else {
// If there are 0 players in the list, loop through slots 0-32 and put -1 in the slot.
while ( $cnt <= 31 ) {
$cnt++;
$sql = "Update hfl_dutil_list set dclassid = '-1' where teamid = $tid and 'order' = $cnt";
$result = mysql_query($sql,$db)or die("Bad query: ".mysql_error());
}
}

danimal 02-21-2008 06:02 PM

Ugh, I'm stumped.

I ran a quick test and it looks like the pref array is properly storing player id numbers. So the problem seems to be that the script isn't properly updating the database table with the player id numbers stored in the pref array.

I tried playing with the mysql query syntax, but that doesn't seem to be doing anything either.

$sql = "UPDATE hfl_dutil_list SET dclassid = $p WHERE ((teamid = $tid) AND ('order' = $cnt))";

Anyone have ideas about why this isn't working?

danimal 02-21-2008 06:36 PM

I tried to run the sql query directly through phpMyAdmin, and it's not working.

UPDATE hfl_dutil_list SET dclassid='84' WHERE ((teamid='2') AND ('order'='1'))
Affected rows: 0 (Query took 0.0004 sec)


By the way, why doesn't that query work if you don't have the quotes around 'order'? If i remove the quotes, I get the following error:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order='1'))' at line 1

So I'm guessing this is a syntax error? The query isn't doing what I want it to do.

Skolleck 02-21-2008 06:49 PM

send me an AIM message at swkolleck and I will help you.

danimal 02-21-2008 09:05 PM

Ok, I am an idiot. I figured it out. It's so obvious now in hindsight.

I had to change the database table field name "order" to "listorder" because ORDER BY is a mysql clause.

Thanks guys for your help and your patience.

Lonnie 02-23-2008 12:13 AM

Sorry so late in seeing this, but yep order is a reserved word in MySQL. If you use the single quotes it works fine. If you look at your error message, you see that you missed the trailing ' after order. I should have changed the field name when I first converted it, but at that time I didn't think it would get as widespread as it is now. I was just trying to get something to work.

If you have any other problems, PM me.


All times are GMT -5. The time now is 11:28 PM.

Powered by vBulletin Version 3.6.0
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.