Jump to content

problems, problems :'(


burnside

Recommended Posts

EDIT : It sort of works. The code changed the value but only after mine is changed my code is :

 

the $on['id'] value is set in the script. Via

$get_on = mysql_query(sprintf("SELECT * FROM `members` WHERE game_show='N' ORDER BY 'id' DESC ")) or die('Error: ' . mysql_error());
				while($on = mysql_fetch_array($get_on)) 

 

The form code is :

 

<form action=\"update.php\" method=\"post\">

<input type=\"hidden\" name=\"id\" value=\"".$on['id']."\"><input type=\"text\" name=\"game_show\" value=\"".$info['game_show']."\" size=\"1\"> <input type=submit value=update>

 

The update script is :

 

<?php
include("connect.php");



$id=$_POST['id'];
$game_show=$_POST['game_show'];


$query="UPDATE members SET game_show='$game_show' WHERE id=$id";
mysql_query($query);
echo "Record Updated <a href=mem.php>MEM</a>";
mysql_close();

?>

 

I mean the code updates the data but only if i update mine first and i am readig up on GET & POST

Link to comment
Share on other sites

  • Replies 56
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

if i go to change the form from say yes to no, you get the update sucsessful msg, but doesnt change anything in the db, but if i update mine first id 1, i get the update sucsefful msg then if i update next one it works. its like will only let me update them in id order.

Link to comment
Share on other sites

i had this code :

 

$get_on = mysql_query(sprintf("SELECT * FROM `members` WHERE game_show='N' ORDER BY id DESC ")) or die('Error: ' . mysql_error());
while($on = mysql_fetch_array($get_on))

 

changed it to this :

 

$get_on = mysql_query(sprintf("SELECT * FROM `members` WHERE game_show='N' ")) or die('Error: ' . mysql_error());
				while($on = mysql_fetch_array($get_on))

and it works fine now.

 

 

EDIT  : Doesnt work it has reversed the order ie : will only let me change id2 then id 1 etc...

Link to comment
Share on other sites

Try this

change

$get_on = mysql_query(sprintf("SELECT * FROM `members` WHERE game_show='N' ")) or die('Error: ' . mysql_error());
				while($on = mysql_fetch_array($get_on))

 

too

$get_on = mysql_query(sprintf("SELECT * FROM `members` WHERE game_show='N' ")) or die('Error: ' . mysql_error());
				while($on = mysql_fetch_array($get_on))
                                                                      { $id = $on['id']} 

then change

 

<form action=\"update.php\" method=\"post\">

<input type=\"hidden\" name=\"id\" value=\"".$on['id']."\"><input type=\"text\" name=\"game_show\" value=\"".$info['game_show']."\" size=\"1\"> <input type=submit value=update>

 

to

 

<form action=\"update.php\" method=\"post\">

<input type=\"hidden\" name=\"id\" value=\"".$id."\"><input type=\"text\" name=\"game_show\" value=\"".$info['game_show']."\" size=\"1\"> <input type=submit value=update>

 

 

Failing that we can set the url to contain the id. Then use the url to update the database.

Link to comment
Share on other sites

if($_GET[action] == 'update_off' )
			{
				//second level security

				if($info[security] <= '7' ) 

						{ 		

							$page_to_view = " Tried to view who has update off. ";

							echo "  
								<br /><br />$space<span style=\"color: orange\"> <strong>Unable to view this page. Level 7 security or higher required. This action has been logged.<strong></span> "; 
								$sql = "INSERT INTO `logged_1` (`id`, `username`, `player_id`, `page_to_view`, `ip_address`) VALUES ('','" . $info['username'] . "', '" .$info['id'].  "', '" . $page_to_view . "', '$info[ip]')";
       									if ( !$result = mysql_query($sql) ) { die('MySQL Error: ' . mysql_error());



					}		

			} else
				 { 
				echo "   <form action=\"update.php\" method=\"post\"><br /> <br /> $space This is all game members who have the update messages turned <strong>off</strong>.   <br />";

				echo " $space <table width=\"50%\"> <td width=\"15%\">$space <u>Username</u></td> <td width=\"10%\"><u>Game Id</u></td> <td width=\"15%\"><u>Action</u></td> <td width=\"15%\"><u>Change</u></td></table>";

				$get_on = mysql_query(sprintf("SELECT * FROM `members` WHERE game_show='N' ")) or die('Error: ' . mysql_error());
				while($on = mysql_fetch_array($get_on))
                                                                       { $id = $on['id']; 


				echo " <table width=\"50%\"> <td width=\"15%\"> $space <a href=\"view.php?\">" .$on['username']. "</a></td> <td width=\"10%\">" .$on['id']. "</td><td width=\"15%\">Contact</a></td><td width=\"15%\"><input type=\"hidden\" name=\"id\" value=\" ".$id." \"><input type=\"text\" name=\"game_show\" value=\"".$on['game_show']." \" size=\"1\"> <input type=submit value=update></td></table>";

} 

echo "<br /><br /> $space <a href=mem.php>Finished</a>	";	}

 

update.php is as followed.

 


<?php
include("connect.php");



$id=$_POST['id'];
$game_show=$_POST['game_show'];


$query="UPDATE members SET game_show='$game_show' WHERE id='$id'";
mysql_query($query) or die(mysql_error());
echo "Record Updated <a href=mem.php>MEM</a>";
echo " the is you changed was ".$id." "; 
mysql_close();

?>

Link to comment
Share on other sites

update.php

<?php
include("connect.php");



$id=$_POST['id'];
$game_show=$_POST['game_show'];

mysql_query("UPDATE members SET game_show = '$games_show'
WHERE id = '$id' ") or die(mysql_error());

echo "Record Updated <a href=mem.php>MEM</a>";
echo " the id you changed was ".$id." "; 
mysql_close();

?>

 

The rest

 

if($_GET[action] == 'update_off' )
	{
		//second level security

		if($info[security] <= '7' ) 

				{ 		

					$page_to_view = " Tried to view who has update off. ";

					echo "  
						<br /><br />$space<span style=\"color: orange\"> <strong>Unable to view this page. Level 7 security or higher required. This action has been logged.<strong></span> "; 
						$sql = "INSERT INTO `logged_1` (`id`, `username`, `player_id`, `page_to_view`, `ip_address`) VALUES ('','" . $info['username'] . "', '" .$info['id'].  "', '" . $page_to_view . "', '$info[ip]')";
       							if ( !$result = mysql_query($sql) ) { die('MySQL Error: ' . mysql_error());



			}		

	} else
		{
		echo "   <form action=\"update.php\" method=\"post\"><br /> <br /> $space This is all game members who have the update messages turned <strong>off</strong>.   <br />";

		echo " $space <table width=\"50%\"> <td width=\"15%\">$space <u>Username</u></td> <td width=\"10%\"><u>Game Id</u></td> <td width=\"15%\"><u>Action</u></td> <td width=\"15%\"><u>Change</u></td></table>";

		$get_on = mysql_query(sprintf("SELECT * FROM `members` WHERE game_show='N' ")) or die('Error: ' . mysql_error());
		while($on = mysql_fetch_array($get_on))
                                                       {


		echo " <table width=\"50%\"> <td width=\"15%\"> $space <a href=\"view.php?\">" .$on['username']. "</a></td> <td width=\"10%\">" .$on['id']. "</td><td width=\"15%\">Contact</a></td><td width=\"15%\"><input type=\"hidden\" name=\"id\" value=\" ".$on['id']." \"><input type=\"text\" name=\"game_show\" value=\"".$on['game_show']." \" size=\"1\"> <input type=submit value=update></td></table>";

} 

echo "<br /><br /> $space <a href=mem.php>Finished</a>	";	}

Link to comment
Share on other sites

Now all it does is if i edit id 2 value to "Y" and click update on the up date page is updates the next value say have 4 id 1 2 3 4 it will satart at four then if i click edit on 1 it will do 3 if you understand what im saying. 

Link to comment
Share on other sites

did that actually in mysql and it worked. and created a script and it worked. So i have no idea why its not working :(

That makes no sense.

 

I think I mentioned this on my previous post. What's $info[security]? I don't see that defined anywhere. I think it should also be $info['security'].

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.