Jump to content

Trouble FETCHING ARRAY'S?


law

Recommended Posts

well im real confused.. it seems logical based on all of your suggestions.. but unfortunately i am getting a similar result

"MySQL ERROR: UPDATE competitions SET competitionname = '', favorite = '', underdog = '', pointspread = '', day = '', month = '', year = '' WHERE competitionid = '1'

Incorrect integer value: '' for column 'day' at row 1"

 

I modified your code and replaced all of the null values with 0's and apparently the code did not like that bc it timed out my querys after 30 seconds.. lol soo i really honestly have no idea what to do now..

Link to comment
Share on other sites

am i right in thinking youve only given part of the script? i am having a lot of trouble just getting it to work. i will keep trying but if i dont reply soon enough could you send the entire script that works on its own as soon as you give it to me and ill fix the logic errors.

 

cheers,

Link to comment
Share on other sites

you are one lucky man today!

 

ive sorted it out and added a delete functionality.

 

for all to see ill post it here rather than upload it to a rar.

 

this better work:

 

(btw ive renamed admin.inc to admin.php, there is no adminconfig.php either here are the files.)

 

admin.php

<div id="stuff">
<?php


session_start();
if(isset($_SESSION['admin_user'])){
$tmp=$_SESSION['admin_user'];

include_once("./dbconfig.php");
dbConn();

// So this is the update for the pool configuration? ok.
if(@$_POST['submit'] && is_numeric($_POST['month']) && is_numeric($_POST['day']) && is_numeric($_POST['year']) && is_numeric($_POST['events']) && ($_POST['entryprice']) > ($_POST['potamount']) && ($_POST['refreward']) <= '1.00' && ($_POST['firstplace']) + ($_POST['secondplace']) + ($_POST['thirdplace']) < '101' && ($_POST['firstplace']) + ($_POST['secondplace']) + ($_POST['thirdplace']) > '99') {
	$var1 = mysql_escape_string($_POST['entryprice']);
	$var2 = mysql_escape_string($_POST['potamount']);
	$var3a = mysql_escape_string($_POST['month']);
	$var3b = mysql_escape_string($_POST['day']);
	$var3c = mysql_escape_string($_POST['year']);
	$var4 = mysql_escape_string($_POST['refreward']);
	$var5 = mysql_escape_string($_POST['firstplace']);
	$var6 = mysql_escape_string($_POST['secondplace']);
	$var7 = mysql_escape_string($_POST['thirdplace']);
	$var8 = mysql_escape_string($_POST['events']);
	$update= mysql_query("UPDATE config SET poolamount = $var1, poolcharge = $var2, lastmonth = $var3a, lastday = $var3b, lastyear = $var3c, refferralreward = $var4, 1stplace = $var5, 2ndplace = $var6, 3rdplace = $var7, events = $var8 WHERE configid = 1")
		 or die(mysql_error());
	echo "<font color=orange><b>The pool was successfully configured</b></font>";
        } // TODO: ELSE { tell the user what went wrong and exit(); }

$data= mysql_query("SELECT * FROM config WHERE configid = 1 ") or die(mysql_error());
$datarow= mysql_fetch_array($data);
$poolamount=$datarow['poolamount'];
$poolcharge=$datarow['poolcharge'];
$lastmonth=$datarow['lastmonth'];
$lastday=$datarow['lastday'];
$lastyear=$datarow['lastyear'];
$refreward=$datarow['refferralreward'];
$firstplace=$datarow['1stplace'];
$secondplace=$datarow['2ndplace'];
$thirdplace=$datarow['3rdplace'];
$events=$datarow['events'];

include("./Includes/tablea.php");
include("./Includes/reconfigtable.php");
include("./Includes/text.php");
echo "<hr />";

// So this is the update/Insert for the row data
if(isset($_POST['eventsubmit'])){
	$i=0;
	while($i<=$events){
		$varname10 = 'eventname'.$i;
		$varname11 = 'eventfav'.$i;
		$varname12 = 'eventpts'.$i;
		$varname13 = 'eventund'.$i;
		$varname14 = 'eventmonth'.$i;
		$varname15 = 'eventday'.$i;
		$varname16 = 'eventyear'.$i;
		$varname17 = 'eventid'.$i;
		$varname18 = 'md5_string'.$i; // used to tell if the data has been changed or not. (to skip unneccessary update queries)
		$varname19 = 'eventdel'.$i;

		$ename = mysql_escape_string(@$_POST[$varname10]);
		$efav = mysql_escape_string(@$_POST[$varname11]);
		$epts = mysql_escape_string(@$_POST[$varname12]);
		$eund = mysql_escape_string(@$_POST[$varname13]);
		$emm = mysql_escape_string(@$_POST[$varname14]);
		$edd = mysql_escape_string(@$_POST[$varname15]);
		$eyyyy = mysql_escape_string(@$_POST[$varname16]);
		$eid = mysql_escape_string(@$_POST[$varname17]);
		$md5str = mysql_escape_string(@$_POST[$varname18]);
		$deleterow = mysql_escape_string(@$_POST[$varname19]);
		$newmd5str = md5($ename.$efav.$epts.$eund.$emm.$edd.$eyyyy);

		if($md5str == "none" && $ename == null){
			$i++; continue;
		}else{
			if(@$lastid >= $eid){ $eid = $lastid; $eid++; } 
			$lastid = $eid;
		}

		if($md5str != "none" && $md5str != $newmd5str){
			// update query
			$query = "UPDATE competitions 
				SET competitionname = '$ename', 
					favorite = '$efav', 
					underdog = '$eund', 
					pointspread = '$epts',
					day = '$edd',
					month = '$emm',
					year = '$eyyyy'
				WHERE competitionid = '$eid'";
			$result = mysql_query($query) or die("MySQL ERROR: $query <br> ".mysql_error());

			echo "<font color=orange><b>The events were successfully updated</b></font><br>";
		}elseif($md5str == "none" && $ename != null){
			// insert query
			$query = "INSERT INTO competitions(
					`competitionname`,
					`favorite`,
					`pointspread`,
					`underdog`,
					`month`,
					`day`,
					`year`,
					`competitionid`
				) VALUES(
					'$ename',
					'$efav',
					'$epts',
					'$eund',
					'$emm',
					'$edd',
					'$eyyyy',
					'$eid'
				)";
			$result = mysql_query($query) or die("MySQL ERROR: $query <br> ".mysql_error());

			echo "<font color=orange><b>The events were successfully inserted</b></font><br>";
		}elseif($deleterow == "on"){
			// delete query
			$query = "DELETE FROM `competitions` WHERE `competitionid`='".$eid."';";
			$result = mysql_query($query) or die("MySQL ERROR: $query <br> ".mysql_error());

			echo "<font color=orange><b>The events were successfully deleted</b></font><br>";
		}
		$i++;
	}
}

// and anything below this is the displayment code
$eventdata= mysql_query("SELECT * FROM competitions WHERE competitionid <= $events");
$count=0;

include("./Includes/tablestart.php");

WHILE($count <= $events){
	if($eventdatarow= @mysql_fetch_array($eventdata)){
		$ename=$eventdatarow['competitionname'];
		$efav=$eventdatarow['favorite'];
		$epts=$eventdatarow['pointspread'];
		$eund=$eventdatarow['underdog'];
		$emm=$eventdatarow['month'];
		$edd=$eventdatarow['day'];
		$eyyyy=$eventdatarow['year'];
		$eid=$eventdatarow['competitionid'];
		$md5_str = md5($ename.$efav.$epts.$eund.$emm.$edd.$eyyyy);

		if($eid == null){ $eid = $lasteid+1; }
		$lasteid = $eid;

	} else {
		$ename="";
		$efav="";
		$epts="";
		$eund="";
		$emm="";
		$edd="";
		$eyyyy="";
		$md5_str = "none";
	}
	Include("./Includes/perrow.php");
	$count++;
}
Include("./Includes/tableend.php");
} else {
// header('Location:admin.php?notloggedin=1'); this line provokes a browser redirection loop. make sure you do something to handle the client.

echo("Please Log In");
}
?>
</div>

 

dbconfig.php

<?php
$host="localhost"; // Host name
$user=""; // Mysql username
$password=""; // Mysql password
$dbName="poolsystem"; // Database name
$tbl_admin="admin"; // Admin table
$tbl_members="members"; //Registerd Member Table
$tbl_picks="picks"; // pick table
$tbl_winners="winners"; // winner table
$paymentamount = "5.00"; // Dollar Amount that goes into the Pool

//Connect to server and select database.
Function dbConn(){
Global $host,$user,$password,$dbName;
$dbConnection = mysql_connect($host,$user,$password) or die(error_log(mysql_error()));
mysql_select_db($dbName);
return $dbConnection;
}
?>

 

and now all the includes in the "Includes" folder. (i hate messy code).

 

tablea.php

<TABLE BORDER=2 CELLPADDING=2 CELLSPACING=2 align=center>
<CAPTION ALIGN=TOP><B>The Current Configuration of the Pool</B></CAPTION>
<TR>
  <TH> Entry Price</TH>
  <TH> Pot Amount</TH>
  <TH> Last Day to Enter</TH>
  <TH> Referral Reward</TH>
  <TH> Events</TH>
  <TH> 1st Place</TH>
  <TH> 2nd Place</TH>
  <TH> 3rd Place</TH>
</TR>
<TR>
  <TD align=center><?php echo($poolamount); ?></TD>
  <TD align=center><?php echo($poolcharge); ?></TD>
  <TD align=center><?php echo($lastmonth.'/'.$lastday.'/'.$lastyear); ?></TD>
  <TD align=center><?php echo($refreward); ?></TD>
  <TD align=center><?php echo($events); ?></TD>
  <TD align=center><?php echo($firstplace); ?> %</TD>
  <TD align=center><?php echo($secondplace); ?> %</TD>
  <TD align=center><?php echo($thirdplace); ?> %</TD>
</TR>
</TABLE>

 

reconfigtable.php

<br/>
<TABLE BORDER=2  align=center WIDTH=690>
<form name='adminconfig' action='./adminconfig.php' method='POST'>
<CAPTION ALIGN=TOP><B>The Re-Configuration of the Pool</B></CAPTION>
<TR>
  <TH> Entry Price</TH>
  <TH> Pot Amount</TH>
  <TH> Last Day to Enter</TH>
  <TH> Referral Reward</TH>
  <TH> Events</TH>
  <TH> 1st Place</TH>
  <TH> 2nd Place</TH>
  <TH> 3rd Place</TH>
</TR>
<TR>
  <TD align=center><select name='entryprice'>
<option value='5'>5</option>
<option value='8'>8</option>
<option value='10'>10</option>
<option value='12'>12</option>
<option value='15'>15</option>
<option value='18'>18</option>
<option value='20'>20</option>
<option value='25'>25</option>
<option value='30'>30</option>
<option value='35'>35</option>
<option value='40'>40</option>
<option value='45'>45</option>
<option value='50'>50</option>
</select></TD>
  <TD align=center><select name='potamount'>
<option value='3'>3</option>
<option value='5'>5</option>
<option value='7'>7</option>
<option value='10'>10</option>
<option value='12'>12</option>
<option value='15'>15</option>
<option value='18'>18</option>
<option value='22'>22</option>
<option value='27'>27</option>
<option value='30'>30</option>
<option value='35'>35</option>
<option value='40'>40</option>
<option value='45'>45</option>
</select></TD>
  <TD>
<input type='text' size='2' MAXLENGTH='2' value='mm' name='month'>
<input type='text' size='2' MAXLENGTH='2' value='dd' name='day'> 
<input type='text' size='4' MAXLENGTH='4' value='yyyy' name='year'> 
</TD>
  <TD align=center><input type='text' size='3' MAXLENGTH='4' value='0.50' name='refreward'>
</TD>
  <TD align=center><input type='text' size='2' MAXLENGTH='2' value='32' name='events'>
</TD>
  <TD align=center><select name='firstplace'>
<option value='100'>100%</option>
<option value='90'>90%</option>
<option value='80'>80%</option>
<option value='70'>70%</option>
</select></TD>
  <TD align=center><select name='secondplace'>
<option value='0'>0%</option>
<option value='8'>8%</option>
<option value='15'>15%</option>
<option value='20'>20%</option>
</select></TD>
  <TD align=center><select name='thirdplace'>
<option value='0'>0%</option>
<option value='2'>2%</option>
<option value='5'>5%</option>
<option value='10'>10%</option>
</select></TD>
</TR>
</TABLE>
<TABLE align=center>
<TR>
<TD>
<input type='submit' name='submit' value='Re-Configure the Pool'>
<input type='reset' name='reset' value='Reset'><br/>
</TD>
</TR>
</TABLE>
</form>

 

text.php

<b><font color=orange>**Make sure that your Entry Price is ABOVE the Pot Amount**</font></b><br/>
<b><font color=orange>**Make sure that your Placement %'s = 100%**</font></b><br/>
<font size=0.005>*The <u>entry price</u> the the price the user pays to enter. The <u>pot amount</u> is how much money from the entry price actually enters into the pool.</font><br/>
<font size=0.005>*The <u>referral reward</u> is the amount the user makes for a paying referral.</font><br/>
<font size=0.005>*The <u>Events</u> is the amount GAMEs that will be in the pool.</font>

 

tablestart.php

<TABLE BORDER=2 CELLPADDING=2 CELLSPACING=2 align=center WIDTH=790>
<form name='eventsconfig' action='./admin.php' method='POST'>
<CAPTION ALIGN=TOP><B>Pool Form Setup Table</B><br/></CAPTION>
<TR>
  <TH> Event Name</TH>
  <TH> Favorite Team</TH>
  <TH> Point Spread</TH>
  <TH> Underdog</TH>
  <TH> Event Date</TH>
  <TH> Delete Row</TH>
</TR>

 

perrow.php

<TR>
  <TD align=center><input type='text' size='20' MAXLENGTH='20' value='<?php echo($ename); ?>' name='eventname<?php echo($count); ?>'></TD>
  <TD align=center><input type='text' size='20' MAXLENGTH='20' value='<?php echo($efav); ?>' name='eventfav<?php echo($count); ?>'></TD>
  <TD align=center><input type='text' size='6' MAXLENGTH='6' value='<?php echo($epts); ?>' name='eventpts<?php echo($count); ?>'></TD>
  <TD align=center><input type='text' size='20' MAXLENGTH='20' value='<?php echo($eund); ?>' name='eventund<?php echo($count); ?>'>
  <TD align=center>
	   <input type='text' size='2' MAXLENGTH='2' value='<?php echo($emm); ?>' name='eventmonth<?php echo($count); ?>'>
	   <input type='text' size='2' MAXLENGTH='2' value='<?php echo($edd); ?>' name='eventday<?php echo($count); ?>'> 
	   <input type='text' size='4' MAXLENGTH='4' value='<?php echo($eyyyy); ?>' name='eventyear<?php echo($count); ?>'> 
  </TD>
  <TD align=center><input type='checkbox' name='eventdel<?php echo($count); ?>'></TD>
           <input type='hidden' name='eventid<?php echo($count); ?>' value='<?php echo($eid); ?>'>
	   <input type="hidden" name="md5_string<?php echo($count); ?>" value="<?php echo($md5_str); ?>">
</TR>

 

tableend.php

</TABLE>
<TABLE align=center>
<TR>
<TD>
<input type='submit' name='eventsubmit' value='Add/Update Events'>
<input type='reset' name='eventreset' value='Reset'><br/>
</TD>
</TR>
</TABLE>
</form>

------------------------

 

have a GOOD look through and make sure you understand every aspect of code. here are the changes:

 

 

fixed you dbConn() function, (function use private variables so any variable defined OUTSIDE the function cannot be accessed with specifying it as a GLOBAL first) - take a look.

 

added "md5_string" hidden input, the script hashes all the row data into a 32-bit string, when data is submitted the script makes a new hash of the submitted data and checks against the md5_string field that was posted, if its different the data has changed and updates.

 

added eventdel checkbox so you can delete entries entirely.

 

this piece of code:

			if($md5str == "none" && $ename == null){
			$i++; continue;
		}else{
			if(@$lastid >= $eid){ $eid = $lastid; $eid++; } 
			$lastid = $eid;
		}

Determines the current Competition ID number to be used when inserting/updating (even allows you to add a new row thats not directly underneath a used row, even the bottom row :P)

 

-------------

thats about it apart from using include() for all your giant echo data.

 

--------

good luck coding in the future, uniflare

Link to comment
Share on other sites

Thank you soo very much for your hard work.. i really appreciate it.. but im having a problem.. i must be doing something wrong.. but im double checking all of the code a copied to make sure i didnt miss a line or something..

but im still not getting the delete or insert to work?

(random problem.. 2 of my sites css images will not load? only in firefox and it just started doing that about an 1hr ago.. all of the other one's show up.. and it works fine in ie.. NO IDEA! ever just get the urge to throw your computer?? lol.. back to the topic!)

here is my questions???

 

<input type="hidden" name="md5_string<?php echo($count); ?>" value="<?php echo($md5_str); ?>">

$varname18 = 'md5_string'.$i; // used to tell if the data has been changed or not. (to skip unnecessary update queries)

		$md5str = mysql_escape_string(@$_POST[$varname18]);
		$deleterow = mysql_escape_string(@$_POST[$varname19]);
		$newmd5str = md5($ename.$efav.$epts.$eund.$emm.$edd.$eyyyy);

if($md5str == "none" && $ename == null)

elseif($deleterow == "on")

you used $md5_str in the form (where is that defined? or is it a php function? if its a function what does it do?)

based on ur answer to ^ question this one may be obvious.. if 'md5_string'.$i increments how will it ever =="none"?

is $deleterow ever defined?

Link to comment
Share on other sites

ok its all defined here:

 

	if(isset($_POST['eventsubmit'])){
	$i=0;
	while($i<=$events){

		// all of these do not store the variable, these are just the array "names" used below.
		$varname10 = 'eventname'.$i;
		$varname11 = 'eventfav'.$i;
		$varname12 = 'eventpts'.$i;
		$varname13 = 'eventund'.$i;
		$varname14 = 'eventmonth'.$i;
		$varname15 = 'eventday'.$i;
		$varname16 = 'eventyear'.$i;
		$varname17 = 'eventid'.$i;
		$varname18 = 'md5_string'.$i; // used to tell if the data has been changed or not. (to skip unneccessary update queries)
		$varname19 = 'eventdel'.$i;

		// These are all the submitted "data". except the last one which is the new md5 hash of the posted data.
		$ename = mysql_escape_string(@$_POST[$varname10]);
		$efav = mysql_escape_string(@$_POST[$varname11]);
		$epts = mysql_escape_string(@$_POST[$varname12]);
		$eund = mysql_escape_string(@$_POST[$varname13]);
		$emm = mysql_escape_string(@$_POST[$varname14]);
		$edd = mysql_escape_string(@$_POST[$varname15]);
		$eyyyy = mysql_escape_string(@$_POST[$varname16]);
		$eid = mysql_escape_string(@$_POST[$varname17]);
		$md5str = mysql_escape_string(@$_POST[$varname18]);
		$deleterow = mysql_escape_string(@$_POST[$varname19]);
		$newmd5str = md5($ename.$efav.$epts.$eund.$emm.$edd.$eyyyy);

 

also i forgot to mention some changes to your html output (more specifically your form options).

 

 

take note:

<TR>
  <TD align=center><input type='text' size='20' MAXLENGTH='20' value='<?php echo($ename); ?>' name='eventname<?php echo($count); ?>'></TD>
  <TD align=center><input type='text' size='20' MAXLENGTH='20' value='<?php echo($efav); ?>' name='eventfav<?php echo($count); ?>'></TD>
  <TD align=center><input type='text' size='6' MAXLENGTH='6' value='<?php echo($epts); ?>' name='eventpts<?php echo($count); ?>'></TD>
  <TD align=center><input type='text' size='20' MAXLENGTH='20' value='<?php echo($eund); ?>' name='eventund<?php echo($count); ?>'>
  <TD align=center>
	   <input type='text' size='2' MAXLENGTH='2' value='<?php echo($emm); ?>' name='eventmonth<?php echo($count); ?>'>
	   <input type='text' size='2' MAXLENGTH='2' value='<?php echo($edd); ?>' name='eventday<?php echo($count); ?>'> 
	   <input type='text' size='4' MAXLENGTH='4' value='<?php echo($eyyyy); ?>' name='eventyear<?php echo($count); ?>'> 
  </TD>
  <TD align=center><input type='checkbox' name='eventdel<?php echo($count); ?>'></TD>
           <input type='hidden' name='eventid<?php echo($count); ?>' value='<?php echo($eid); ?>'>
	   <input type="hidden" name="md5_string<?php echo($count); ?>" value="<?php echo($md5_str); ?>">
</TR>

 

the very last hidden INPUT is called "md5_string", which i set as $md5_string in the script, if there is no data the form input value is "none", if it has data the value is the "md5 hash". these are used with the php to determine if the data in the existing fields have "changed".

---------

 

as for insert and delete not working tell me what it says with this:

 

admin.php

<div id="stuff">
<?php


session_start();
if(isset($_SESSION['admin_user'])){
$tmp=$_SESSION['admin_user'];

include_once("./dbconfig.php");
dbConn();

// So this is the update for the pool configuration? ok.
if(@$_POST['submit'] && is_numeric($_POST['month']) && is_numeric($_POST['day']) && is_numeric($_POST['year']) && is_numeric($_POST['events']) && ($_POST['entryprice']) > ($_POST['potamount']) && ($_POST['refreward']) <= '1.00' && ($_POST['firstplace']) + ($_POST['secondplace']) + ($_POST['thirdplace']) < '101' && ($_POST['firstplace']) + ($_POST['secondplace']) + ($_POST['thirdplace']) > '99') {
	$var1 = mysql_escape_string($_POST['entryprice']);
	$var2 = mysql_escape_string($_POST['potamount']);
	$var3a = mysql_escape_string($_POST['month']);
	$var3b = mysql_escape_string($_POST['day']);
	$var3c = mysql_escape_string($_POST['year']);
	$var4 = mysql_escape_string($_POST['refreward']);
	$var5 = mysql_escape_string($_POST['firstplace']);
	$var6 = mysql_escape_string($_POST['secondplace']);
	$var7 = mysql_escape_string($_POST['thirdplace']);
	$var8 = mysql_escape_string($_POST['events']);
	$update= mysql_query("UPDATE config SET poolamount = $var1, poolcharge = $var2, lastmonth = $var3a, lastday = $var3b, lastyear = $var3c, refferralreward = $var4, 1stplace = $var5, 2ndplace = $var6, 3rdplace = $var7, events = $var8 WHERE configid = 1")
		 or die(mysql_error());
	echo "<font color=orange><b>The pool was successfully configured</b></font>";
        } // TODO: ELSE { tell the user what went wrong and exit(); }

$data= mysql_query("SELECT * FROM config WHERE configid = 1 ") or die(mysql_error());
$datarow= mysql_fetch_array($data);
$poolamount=$datarow['poolamount'];
$poolcharge=$datarow['poolcharge'];
$lastmonth=$datarow['lastmonth'];
$lastday=$datarow['lastday'];
$lastyear=$datarow['lastyear'];
$refreward=$datarow['refferralreward'];
$firstplace=$datarow['1stplace'];
$secondplace=$datarow['2ndplace'];
$thirdplace=$datarow['3rdplace'];
$events=$datarow['events'];

include("./Includes/tablea.php");
include("./Includes/reconfigtable.php");
include("./Includes/text.php");
echo "<hr />";

// So this is the update/Insert for the row data
if(isset($_POST['eventsubmit'])){
	$i=0;
	while($i<=$events){

		// all of these do not store the variable, these are just the array "names" used below.
		$varname10 = 'eventname'.$i;
		$varname11 = 'eventfav'.$i;
		$varname12 = 'eventpts'.$i;
		$varname13 = 'eventund'.$i;
		$varname14 = 'eventmonth'.$i;
		$varname15 = 'eventday'.$i;
		$varname16 = 'eventyear'.$i;
		$varname17 = 'eventid'.$i;
		$varname18 = 'md5_string'.$i; // used to tell if the data has been changed or not. (to skip unneccessary update queries)
		$varname19 = 'eventdel'.$i;

		// These are all the submitted "data". except the last one which is the new md5 hash of the posted data.
		$ename = mysql_escape_string(@$_POST[$varname10]);
		$efav = mysql_escape_string(@$_POST[$varname11]);
		$epts = mysql_escape_string(@$_POST[$varname12]);
		$eund = mysql_escape_string(@$_POST[$varname13]);
		$emm = mysql_escape_string(@$_POST[$varname14]);
		$edd = mysql_escape_string(@$_POST[$varname15]);
		$eyyyy = mysql_escape_string(@$_POST[$varname16]);
		$eid = mysql_escape_string(@$_POST[$varname17]);
		$md5str = mysql_escape_string(@$_POST[$varname18]);
		$deleterow = mysql_escape_string(@$_POST[$varname19]);
		$newmd5str = md5($ename.$efav.$epts.$eund.$emm.$edd.$eyyyy);

		if($md5str == "none" && $ename == null){
			$i++; continue;
		}else{
			if(@$lastid >= $eid){ $eid = $lastid; $eid++; } 
			$lastid = $eid;
		}

		if($md5str != "none" && $md5str != $newmd5str){
			// update query
			$query = "UPDATE competitions 
				SET `competitionname` = '$ename', 
					`favorite` = '$efav', 
					`underdog` = '$eund', 
					`pointspread` = '$epts',
					`day` = '$edd',
					`month` = '$emm',
					`year` = '$eyyyy'
				WHERE `competitionid = '$eid'";
			echo($query."<br>");
			// $result = mysql_query($query) or die("MySQL ERROR: $query <br> ".mysql_error());

			// echo "<font color=orange><b>The events were successfully updated</b></font><br>";
		}elseif($md5str == "none" && $ename != null){
			// insert query
			$query = "INSERT INTO competitions(
					`competitionname`,
					`favorite`,
					`pointspread`,
					`underdog`,
					`month`,
					`day`,
					`year`,
					`competitionid`
				) VALUES(
					'$ename',
					'$efav',
					'$epts',
					'$eund',
					'$emm',
					'$edd',
					'$eyyyy',
					'$eid'
				)";
			echo($query."<br>");
			// $result = mysql_query($query) or die("MySQL ERROR: $query <br> ".mysql_error());

			// echo "<font color=orange><b>The events were successfully inserted</b></font><br>";
		}elseif($deleterow == "on"){
			// delete query
			$query = "DELETE FROM `competitions` WHERE `competitionid`='".$eid."';";
			$result = mysql_query($query) or die("MySQL ERROR: $query <br> ".mysql_error());

			echo "<font color=orange><b>The events were successfully deleted</b></font><br>";
		}
		$i++;
	}
}

// and anything below this is the displayment code
$eventdata= mysql_query("SELECT * FROM competitions WHERE competitionid <= $events");
$count=0;

include("./Includes/tablestart.php");

WHILE($count <= $events){
	if($eventdatarow= @mysql_fetch_array($eventdata)){
		$ename=$eventdatarow['competitionname'];
		$efav=$eventdatarow['favorite'];
		$epts=$eventdatarow['pointspread'];
		$eund=$eventdatarow['underdog'];
		$emm=$eventdatarow['month'];
		$edd=$eventdatarow['day'];
		$eyyyy=$eventdatarow['year'];
		$eid=$eventdatarow['competitionid'];
		$md5_str = md5($ename.$efav.$epts.$eund.$emm.$edd.$eyyyy);

		if($eid == null){ $eid = $lasteid+1; }
		$lasteid = $eid;

	} else {
		$ename="";
		$efav="";
		$epts="";
		$eund="";
		$emm="";
		$edd="";
		$eyyyy="";
		$md5_str = "none";
	}
	Include("./Includes/perrow.php");
	$count++;
}
Include("./Includes/tableend.php");
} else {
// header('Location:admin.php?notloggedin=1'); this line provokes a browser redirection loop. make sure you do something to handle the client.

echo("Please Log In");
}
?>
</div>

 

cheers,

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.