Jump to content

Not Updating


Lamez

Recommended Posts

The script below is suppose to see if there is any data in the MySQL table, and if there is it uses the MySQL update function, if not then it is suppose to add the new data.

 

It does not update or add, what am I doing wrong here?

 

<?php
include ("../../style/include/session.php");
include ("../../style/include/cons/head_2.php");
if($session->isAdmin()){
print '<div class="box"><h2>Point Value Settings</h2>';
?>
<SCRIPT TYPE="text/javascript">
function numbersonly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key== || 
    (key==9) || (key==13) || (key==27) )
   return true;

// numbers
else if ((("0123456789").indexOf(keychar) > -1))
   return true;

// decimal point jump
else if (dec && (keychar == "."))
   {
   myfield.form.elements[dec].focus();
   return false;
   }
else
   return false;
}

//-->
</SCRIPT>
<?php
$getlink = $_GET["action"];
$link = md5("addpointstodb");
if ($getlink == $link) {
if(isset ($_POST['Submit'])){
  $a = $_POST['1'];
  $b = $_POST['2'];
  $c = $_POST['3'];
  $d = $_POST['4'];
  $e = $_POST['5'];
  $f = $_POST['6'];

  
   $q = "Select count(*) as row_count from `points`";
   $r = mysql_query($q) or die(mysql_error()."<br /><br />".$q);
  if(mysql_num_rows($r) >0){
$q = "UPDATE `points` SET `1`=$a WHERE `1`='$a', '$b', '$c'";

mysql_query($q)or die(mysql_error());
echo "Updated Points to Database";
echo '<br><br><a href="pinval.php">View Points</a>';
  }else{
    $q = "INSERT INTO `points` VALUES ('$a', '$b', '$c', '$d', '$e', '$f', '$g')";
mysql_query($q)or die(mysql_error());
echo "Added points to Database";
echo '<br><br><a href="pinval.php">View Points</a>';
  }  
}else{
echo "No data to enter";
echo '<br><br><a href="pinval.php">Try Again</a>';
}
}else{
$paid = "select * from points";
$q = mysql_query($paid) or die('Error: ' . mysql_error());
$rs=mysql_fetch_array($q);
?>


<form name="updatepoints" method="post" action="?action=<?php echo $link; ?>">
<table width="387" height="198" border="0">
  <tr>
    <td width="136"><strong>Round Name </strong></td>
    <td width="124"><strong>Point Value </strong></td>
    <td width="113"> </td>
  </tr>
  <tr>
    <td>1st Round </td>
    <td align="center"><input name="2" type="text" id="2" onkeypress="return numbersonly(this, event)" size="10" value="<?php echo $rs['2']; ?>" /></td>
    <td> </td>
  </tr>
  <tr>
    <td>2nd Round </td>
    <td align="center"><input name="3" type="text" id="3" onkeypress="return numbersonly(this, event)" size="10" value="<?php echo $rs['3']; ?>" /></td>
    <td> </td>
  </tr>
  <tr>
    <td>Sweet 16 </td>
    <td align="center"><input name="4" type="text" id="4" onkeypress="return numbersonly(this, event)" size="10" value="<?php echo $rs['4']; ?>" /></td>
    <td> </td>
  </tr>
  <tr>
    <td>Elite Eight </td>
    <td align="center"><input name="5" type="text" id="5" onkeypress="return numbersonly(this, event)" size="10" value="<?php echo $rs['5']; ?>" /></td>
    <td> </td>
  </tr>
  <tr>
    <td>Final Four </td>
    <td align="center"><input name="6" type="text" id="6" onkeypress="return numbersonly(this, event)" size="10" value="<?php echo $rs['6']; ?>" /></td>
    <td> </td>
  </tr>
  <tr>
    <td>Championship</td>
    <td align="center"><input name="7" type="text" id="7" onkeypress="return numbersonly(this, event)" size="10" value="<?php echo $rs['7']; ?>" /></td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td align="left"><input type="submit" name="Submit" value="Submit" />
      <input name="Reset" type="reset" id="Reset" value="Reset" /></td>
    <td align="left"><label></label></td>
  </tr>
</table>
</form>
<p> </p>

<?php
}
}else{
header("Location: ../../index.php");
}
print '</div>';
include ("../../style/include/cons/foot.php");
?>

Link to comment
Share on other sites

this

echo "$getlink is really = to $link";

befor this

if ($getlink == $link) {

 

A possible problems could be that $getlink is not = to $link so the update never happens. It's hard to find resons of what can cause your problem since all you told us is it's not working ...

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.