update mysql using php? how to?

hi every one, this is my first post.

I have a website with a voicechat. in the admin panel there is an option to change user’s details. you click on the link and takes you to a user list page where you select teh user you want and then you can edit the information for that user.

is there away to make a link on the chatroom for users to click on it and hav an option to change their own details?

the admin panel to change people’s info doesnt work properly, the company who provided me with the script won’t help me get ride of the errors, whenever i press Apply changes i get this error “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 ‘Activate = 1,ShowIP = 0,ShowBAN = 0,Webcam = 0 WHERE Username=‘Whatever’’ at line 1”

below is the sourcecode for the page where the admin can edit the user’s details. i really need this, please let me know if you can help me, am not good at programming.

[code]<?
ini_set(“output_buffering”, “1”);
ini_set(“register_globals”, “0”);
ini_set(“session.use_cookies”, “1”);
ini_set(“session.use_trans_sid”, “1”);

require_once “inc/iv-app.class.php”;

$app = new CBabChatApp();

if (!$app->isRoot())
{
$app->execute("./logout.php");
}

$gotError = false;
$errorMsg = “”;

$conn = new CConnection(DB_USER, DB_PASS, DB_HOST);

if ($app->getPost(“action”) === “update”)
{
if (strlen(trim($app->getPost(“email”))) == 0)
{
$gotError = true;
$errorMsg = “You Must Supply An Email Address”;
}

if ($app->getPost("changePasswd") == 1)
{
	if (strlen(trim($app->getPost("passwd2"))) == 0)
	{
		$gotError = true;
		$errorMsg = "You Must Retype Your Password";
	}
	if (strlen(trim($app->getPost("passwd"))) == 0)
	{
		$gotError = true;
		$errorMsg = "You Must Supply A Password";
	}
	if ($app->getPost("passwd") !== $app->getPost("passwd2"))
	{
		$gotError = true;
		$errorMsg = "Passwords Do Not Match";
	}
}

if (!$gotError)
{
	if ($conn->open(DB_NAME))
	{
		$mode = $app->getPost("Mode");

		$invisible = $app->getPost("invisible");

		if ($app->getPost("disguised") == 1)
		{
			$invisible = 2;
		}

		$rec = new CRecord(&$conn);
		$rec->setTableName("Users");
		$rec->initTableData(sprintf("Username = '%s'", $app->getQuery("user")));
		$rec->setItem("Email", $app->getPost("email"));
		$rec->setItem("Color", $app->getPost("color"));

		if ($app->getPost("changePasswd") == 1)
		{
			$rec->setItem("Password", $app->myEncrypt($app->getPost("passwd")));
		}

		$rec->setItem("isAdmin", $app->getPost("isAdmin"));
		$rec->setItem("Mode", $mode);
		$rec->setItem("Invisible", $invisible);
		$rec->setItem("Sex", $app->getPost("sex"));
		$rec->setItem("ShowIP", $app->getPost("showip"));
		$rec->setItem("Activate", $app->getPost("active"));
		$rec->setItem("VoicePM", $app->getPost("voicepm"));
		$rec->setItem("TextPM", $app->getPost("textpm"));
		$rec->setItem("ShowBAN", $app->getPost("showban"));
		$rec->setItem("Webcam", $app->getPost("webcam"));

		$gotError = !$rec->update(sprintf("Username='%s'", $app->getPost("user")));

		if ($gotError)
		{
			$errorMsg = $conn->getError();
		}

		$conn->close();

		if (!$gotError)
		{
			$app->execute("./usermanager.php?page=" . $app->getQuery("page"));
		}
	}
}

}

if (!$app->userExists($app->getQuery(“user”)) && !$app->userExists($app->getPost(“user”)))
{
$app->execute("./usermanager.php?page=" . $app->getQuery(“page”));
}

if ($conn->open(DB_NAME))
{
$rs = new CRecordSet(&$conn);

if ($rs->query(sprintf("SELECT * FROM Users WHERE (Username = '%s')", $app->getQuery("user"))))
{
	if ($rs->getNumRows() != 0)
	{
		$user = $rs->getAssoc();
	}

	$rs->free();
}

$conn->free();

}

?>

:: user editor " method="post"> ">
Editing User Information For: <?= $app->getQuery("user"); ?>
<? if ($gotError) { ?> <? } ?>
<?= $errorMsg ?>
Email " size="40">
Change Password getPost("changePasswd") == 1) ? " CHECKED" : ""?> name="changePasswd" type="radio" value="1"> Yes  getPost("changePasswd") != 1) ? " CHECKED" : ""?> name="changePasswd" type="radio" value="0"> No
Account Active name="active" type="radio" value="1"> Yes  name="active" type="radio" value="0"> No
Root Access >None value="2">Admin value="3">Root
Password " size="40">
Retype Password " size="40">
Operator Level >None value="1">Level1 value="2">Level2 value="3">Level3
Invisible name="invisible" type="radio" value="1"> Yes   name="invisible" type="radio" value="0"> No
Disguised name="disguised" type="radio" value="1"> Yes   name="disguised" type="radio" value="0"> No
Show User IP name="showip" type="radio" value="1"> Yes   name="showip" type="radio" value="0"> No
Show Ban History name="showban" type="radio" value="1">  Yes   name="showban" type="radio" value="0">  No
Voice PM name="voicepm" type="radio" value="1"> Yes  name="voicepm" type="radio" value="0"> No
Text PM name="textpm" type="radio" value="1"> Yes  name="textpm" type="radio" value="0"> No
Webcam name="webcam" type="radio" value="1"> Yes  name="webcam" type="radio" value="0"> No
User Color " size="6" maxlength="6">
Sex name="sex" type="radio" value="2">  Male   name="sex" type="radio" value="3">  Female
 ';">
[/code]

MOD EDIT: Changed quote to code tags

Can’t find the faulty SQL query in the code you provided. Trace back where the query is that’s throwing the error and post that query here instead.

thank you for your reply i searched through the all files i have and i cant find where that error comes from.

anyway how can i make this viewable to my users, each user should be able to see that page for their own profiles. ? please

thank you

the code below is for the main chat page where users should be able to see a link to the page where they can edit their profile.

[code]<?

require_once “inc/iv-app.class.php”;

$app = new CBabChatApp();

if (!$app->hasAuth())
{
$app->execute("./logout.php");
}

if ($app->isBanned())
{
$app->execute("./banned.php");
}

$rId = $app->getPost(“roomID”);

if (!in_array($rId, $rooms) && !in_array($rId, $roomsP))
{
$rId = DEFAULT_ROOMID;
}

$keys = array_keys($rooms);

for ($ii = 0; $ii < count($keys); $ii++)
{
if ($rooms[$keys[$ii]] == $rId)
{
$curRoom = $keys[$ii];
}
}

$keys = array_keys($roomsP);

for ($ii = 0; $ii < count($keys); $ii++)
{
if ($roomsP[$keys[$ii]] == $rId)
{
$curRoom = $keys[$ii];
}
}

$app->getServerInfo(&$server, &$version, &$accountid, &$adminpw);

srand(time());
$sid = rand(0, 100000);

$_SESSION["session_id"] = $sid;
$_SESSION["session_time"] = time();

?>

Wilat.com Voice Chat A:hover {color: #B3B3D9}







  <table border="0" cellpadding="0" cellspacing="0" width="613" style="border-collapse: collapse" height="36">
    <tr>
      <td valign="top" align="center" width="1038" height="360">
        <table width="100%" height="371" border="8" cellpadding="0" cellspacing="0" bordercolor="#666666" id="AutoNumber11" style="border-collapse: collapse">
          <tr>
            <td width="100%">
	    <param name="_Version" value="65536">
	    <param name="_ExtentX" value="15875">
	    <param name="_ExtentY" value="9525">
      	<param name="_StockProps" value="0">

		<param name="name" value="<?= $app->getSessionVal("DISPLAY_NAME") ?>">
		<param name="mode" value="<?= $app->getSessionVal("MODE") ?>">
		<param name="auth" value="<?= $app->getSessionVal("MODE") == "0" ? "0" : $adminpw?>">
		<param name="roomID" value="20152">
		<param name="talkLimit" value="370000">
		<param name="kickTime" value="259200">
		<param name="server" value="<?=$server?>">
		<param name="accountID" value="<?=$accountid?>">
		<param name="textWindowWidth" value="450">
		<param name="listTextColor" value="<?=$app->getSessionVal("COLOR") == "" ? "002F5E" : $app->getSessionVal("COLOR");?>">
		<param name="listBgColor" value="FFFFFF">
		<param name="textFontName" value="verdana">
		<param name="textFontSize" value="10">
		<param name="textUserColor" value="002F5E">
		<param name="textColor" value="000000">
		<param name="textWindowBgColor" value="FFFFFF">
		<param name="privateMessage" value="1">
		<param name="optimizeLatency" value="1">
		<param name="welcomeMessage" value="<?= sprintf(WELCOME_FORMAT, $curRoom); ?>">
		<param name="userIcon" value="<?= $app->getSessionVal("SEX"); ?>">
		<param name="invisible" value="<?= $app->getInvisible(); ?>">
		<param name="textCharLimit" value="300">
		<param name="floodControl" value="100">
		<param name="showUserIP" value="1">
		<param name="showBanHistory" value="1">
		<param name="privateVoiceEnable" value="1">
		<param name="publicCameraEnable" value="<?=$app->getSessionVal("WEBCAM")?>">
		</object>


 









 


 


 



























<?
if ($app->isRoot())
{
?>












<?
}
?>
<?
if ($app->isAdmin())
{
?>






<?
}
?>



Gorani

Gftugou Duan



Log Out

Ban Manager

User Manager

Log Manager

 Account Manager

Ban Manager

Log Manager

                  

 

 

 

[/code]

MOD EDIT: Changed quote to code tags

First of all: use code tags instead of quote tags when posting code.

Second: we’re not here to solve your problems for you, we’re here to help you solve your own problems. Read our thread on debugging. See my signature for the link. You make yourself look like you don’t care at all and don’t put any effort into it, and just expect us to solve your problem. That’s just not the way it works.

Sponsor our Newsletter | Privacy Policy | Terms of Service