Jump to content

[SOLVED] Mysql is not updating!


jamesxg1

Recommended Posts

Mysql is not updating with this code

 

<?php 
if(isset($_POST['terminate'])) {
  $sql = "UPDATE users SET bio = '$bio' WHERE username = '{$_SESSION['username']}'";
  mysql_query($sql) or die(mysql_error());
  header("Location: ../main/bioedit2.php");
}
?>

<html><style type="text/css">

.progress{
width: 1px;
height: 14px;
color: white;
font-size: 12px;
  overflow: hidden;
background-color: orange;
padding-left: 5px;
}

</style>

<script type="text/JavaScript">

function textCounter(field,counter,maxlimit,linecounter) {
// text width//
var fieldWidth =  parseInt(field.offsetWidth);
var charcnt = field.value.length;        

// trim the extra text
if (charcnt > maxlimit) { 
	field.value = field.value.substring(0, maxlimit);
}

else { 
// progress bar percentage
var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
document.getElementById(counter).innerHTML="Limit: "+percentage+"%"
// color correction on style from CCFFF -> CC0000
setcolor(document.getElementById(counter),percentage,"background-color");
}
}

function setcolor(obj,percentage,prop){
obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}

</script></head>
<body><center>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">

<textarea rows="5" cols="40" name="$bio" id="$bio" 
onKeyDown="textCounter(this,'progressbar1',1000)" 
onKeyUp="textCounter(this,'progressbar1',1000)" 
onFocus="textCounter(this,'progressbar1',1000)" ></textarea><br />

<div id="progressbar1" class="progress"></div>
<script>textCounter(document.getElementById("maxcharfield"),"progressbar1",1000)</script>
<input type="submit" name="terminate" value="Terminate">
</form>
</center>
</body>
</html>

 

 

 

But it will with this exact same one just without a Var

 

<?php 
if(isset($_POST['terminate'])) {
  $sql = "UPDATE users SET bio = 'WHATEVER I WANT WITH NO VAR' WHERE username = '{$_SESSION['username']}'";
  mysql_query($sql) or die(mysql_error());
  header("Location: ../main/bioedit2.php");
}
?>

<html><style type="text/css">

.progress{
width: 1px;
height: 14px;
color: white;
font-size: 12px;
  overflow: hidden;
background-color: orange;
padding-left: 5px;
}

</style>

<script type="text/JavaScript">

function textCounter(field,counter,maxlimit,linecounter) {
// text width//
var fieldWidth =  parseInt(field.offsetWidth);
var charcnt = field.value.length;        

// trim the extra text
if (charcnt > maxlimit) { 
	field.value = field.value.substring(0, maxlimit);
}

else { 
// progress bar percentage
var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
document.getElementById(counter).innerHTML="Limit: "+percentage+"%"
// color correction on style from CCFFF -> CC0000
setcolor(document.getElementById(counter),percentage,"background-color");
}
}

function setcolor(obj,percentage,prop){
obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}

</script></head>
<body><center>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">

<textarea rows="5" cols="40" name="$bio" id="$bio" 
onKeyDown="textCounter(this,'progressbar1',1000)" 
onKeyUp="textCounter(this,'progressbar1',1000)" 
onFocus="textCounter(this,'progressbar1',1000)" ></textarea><br />

<div id="progressbar1" class="progress"></div>
<script>textCounter(document.getElementById("maxcharfield"),"progressbar1",1000)</script>
<input type="submit" name="terminate" value="Terminate">
</form>
</center>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/142818-solved-mysql-is-not-updating/
Share on other sites

where is your session_start()? and i don't see where $bio is set...

 

Hiya,

 

$bio is the var for the texarea and it does have a session_start but i had to cut it out as it has some data that is unhidden yet due to not finishing it yet.

change this:

<textarea rows="5" cols="40" name="$bio" id="$bio" 

to

<textarea rows="5" cols="40" name="bio" id="bio" 

 

and use this at the top:

<?php 
if(isset($_POST['terminate'])) {
  $bio = mysql_real_escape_string($_POST['bio']);
  $sql = "UPDATE users SET bio = '$bio' WHERE username = '{$_SESSION['username']}'";
  mysql_query($sql) or die(mysql_error());
  header("Location: ../main/bioedit2.php");
  exit;
}
?>

change this:

<textarea rows="5" cols="40" name="$bio" id="$bio" 

to

<textarea rows="5" cols="40" name="bio" id="bio" 

 

and use this at the top:

<?php 
if(isset($_POST['terminate'])) {
  $bio = mysql_real_escape_string($_POST['bio']);
  $sql = "UPDATE users SET bio = '$bio' WHERE username = '{$_SESSION['username']}'";
  mysql_query($sql) or die(mysql_error());
  header("Location: ../main/bioedit2.php");
  exit;
}
?>

 

Worked!, Cheerz mate your a *

 

James.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.