Gyz i have some serious prob my code.
if you find any error plz correct me .

My code for Pay Fees (Update)

<div id="wb_Form1" style="position:absolute;width:365px;height:270px;">
<form name="update" method="post" action="./Update_Fess.php" id="Form1">
<div id="wb_Text7" style="position:absolute;left:10px;top:15px;width:104px;height:16px;z-index:1;text-align:left;">
<span style="color:#000000;font-family:Arial;font-size:13px;">ISPID#:</span></div>
<input type="text" id="Editbox1" style="position:absolute;left:124px;top:15px;width:198px;height:23px;line-height:23px;z-index:2;" name="ISPID" value="">
<div id="wb_Text9" style="position:absolute;left:10px;top:45px;width:104px;height:16px;z-index:3;text-align:left;">
<span style="color:#000000;font-family:Arial;font-size:13px;">August 2013:</span></div>
<input type="text" id="Editbox2" style="position:absolute;left:124px;top:45px;width:198px;height:23px;line-height:23px;z-index:4;" name="Aug2013" value="">
<div id="wb_Text11" style="position:absolute;left:10px;top:75px;width:104px;height:16px;z-index:5;text-align:left;">
<span style="color:#000000;font-family:Arial;font-size:13px;">September 2013:</span></div>
<input type="text" id="Editbox3" style="position:absolute;left:124px;top:75px;width:198px;height:23px;line-height:23px;z-index:6;" name="Sep2013" value="">
<div id="wb_Text12" style="position:absolute;left:10px;top:105px;width:104px;height:16px;z-index:7;text-align:left;">
<span style="color:#000000;font-family:Arial;font-size:13px;">Octuber 2013:</span></div>
<input type="text" id="Editbox4" style="position:absolute;left:124px;top:105px;width:198px;height:23px;line-height:23px;z-index:8;" name="Oct2013" value="">
<div id="wb_Text13" style="position:absolute;left:10px;top:135px;width:104px;height:16px;z-index:9;text-align:left;">
<span style="color:#000000;font-family:Arial;font-size:13px;">November 2013:</span></div>
<input type="text" id="Editbox5" style="position:absolute;left:124px;top:135px;width:198px;height:23px;line-height:23px;z-index:10;" name="Nov2013" value="">
<div id="wb_Text14" style="position:absolute;left:10px;top:165px;width:104px;height:16px;z-index:11;text-align:left;">
<span style="color:#000000;font-family:Arial;font-size:13px;">December 2013:</span></div>
<input type="text" id="Editbox6" style="position:absolute;left:124px;top:165px;width:198px;height:23px;line-height:23px;z-index:12;" name="Dec2013" value="">
<input type="submit" id="Button1" name="" value="Send" style="position:absolute;left:124px;top:195px;width:96px;height:25px;z-index:13;">
<input type="reset" id="Button2" name="" value="Reset" style="position:absolute;left:124px;top:225px;width:96px;height:25px;z-index:14;">
</form>
</div>

And this is my Update Action (Update_fee)

<?php
$host="abc.com"; // Host name 
$username="12333231"; // Mysql username 
$password="213123"; // Mysql password 
$db_name="Members"; // Database name 
$tbl_name="ASDF"; // Table name 

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// update data in mysql database 
$sql="UPDATE $tbl_name SET id='$id', ISPID='$ISPID', Aug2013='$Aug2013', Sep3013='$Sep2013, 'WHERE id='$id'";
$result=mysql_query($sql);

// if successfully updated. 
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='list_records.php'>View result</a>";
}

else {
echo "ERROR";
}

?>

Plz Help Me..

Recommended Answers

All 28 Replies

You never set the values of $id, $ISPID, $Aug2013 and $Sep2013
Do a var_dump($_POST), they are in there.
check out mysql_real_escape_string
also notice that mysql is deprecated and replaced by mysqli

what are the error messages your are getting..

action="./Update_Fess.php"

should be

action="../Update_Fess.php"

as pointed by @pzuurveen you have not set $id, $ISPID, $Aug2013 and $Sep2013 values

you will not get $id as your form doesn't have any input for id

Start using mysqli or PDO

I gor Error Any Body

Your responses so far have been that you get an error.. Have you fixed those items and can you provide more details with regard to the error?

gyx gve me some exapmles

Gyz i write New Code but It Sohws The Following Error:

My New Code For Update:

<?php
$host="123131231"; // Host name 
$username="2313213"; // Mysql username 
$password="13331"; // Mysql password 
$db_name="312deede"; // Database name 
$tbl_name="Fees"; // Table name 

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

error_reporting(E_ALL);
// update data in mysql database 
$sql="UPDATE $tbl_name SET Aug2013='$Aug2013', Sep3013='$Sep2013',
WHERE ISPID= $ISPID";
$result=mysql_query($sql);

// if successfully updated. 
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='list_records.php'>View result</a>";
}
else {
echo "ERROR";
}

Got the following Error:
Parse error: syntax error, unexpected '<' in /home/122121/public_html/as/099/9090/etc/Update_Fess.php on line 315

What is line 315?
< is probley from an html tag
than means that you put html code in within the <?php ?> tag

its ok i chk 3 times

Prob is >>** Parse error: syntax error, unexpected**

yes, It also tell you exactly what the problem is:

there is an '<' where there shouldn't

and where:

on Line 315 (you total code, not just the part you post here)

ok i'm checking again & if i didn't solve then i will insert the code

Check out my codes.
This is all of them.

Ha gyz ple out me from this shit.

plz help me

can any body hrlp me

Can some body prove me info

post the code

Update_ac.php

<?php
$host="expamle.com"; // Host name 
$username="aassdasd"; // Mysql username 
$password="Xasd333332239"; // Mysql password 
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
  die('Could not connect: ' . mysql_error());
}

$Aug2013 = $_POST['Aug2013'];
$Sep2013 = $_POST['Sep2013'];
$Oct2013 = $_POST['Oct2013'];
$Nov2013 = $_POST['Nov2013'];

$sql = "UPDATE fees ".
       "SET Aug2013 = $Aug2013 ".
       "Sep2013 = $Sep2013 ".
       "Oct2013 = $Oct2013 ".
       "Nov2013 = $Nov2013 ".
       "WHERE id = $id" ;

mysql_select_db('fees_db');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
  die('Could not update data: ' . mysql_error());
}
echo "Updated data successfully\n";
mysql_close($conn);
}
else
{
?></div>
</div>
</body>
</html>

When i submite my data it shown sucessfully but it didn't update my database

any body find any srror or something

Are you sure your POST data is populated?
try dumping the content of POST: var_dump($_POST);

Member Avatar for diafol

Few things:

$sql = "UPDATE fees ".
   "SET Aug2013 = $Aug2013 ".
   "Sep2013 = $Sep2013 ".
   "Oct2013 = $Oct2013 ".
   "Nov2013 = $Nov2013 ".
   "WHERE id = $id" ;

You do not sanitize your input (POST) data - use mysql_real_escape_string() on every user input if you insist on using the soon-to-die mysql_* functions.
Also, are inputs text or integer or float? If text, then the field values (variables) require quotes around them. Although your table name is fees, it's not clear whether these fields are amounts or 'paid/upaid'
You also need commas between your fieldname=fieldvalue pairs.

$sql = "UPDATE fees SET Aug2013 = '$Aug2013', Sep2013 = '$Sep2013', Oct2013 = 'Oct2013', Nov2013 = '$Nov2013' WHERE id = $id" ;

ARe you sure that your DB schema is set up properly?
The field names suggest that you'r looking at creating something like:

fees

fee_id
student_id
period (e.g. 2013-08-01)
fee

commented: no my DB is (id,Name,Aug2013,Sep2013,Oct2013 & Nov2013 thats it +2

My Fee Database

id int (10)
Name (Ver)
Aug2013 (Ver)
Sep2013 (Ver)
Oct2013 (Ver)
Nov2013 (Ver)

Member Avatar for diafol

Your fee table I think you mean

id int (10)
Name (Ver)
Aug2013 (Ver)
Sep2013 (Ver)
Oct2013 (Ver)
Nov2013 (Ver)

Will you be adding fields like Dec2013, Jan2014 ? If so, your schema is all wrong.
ANyway, did the changes to the query work?

Then what i do now

Member Avatar for diafol

Then what i do now

Depends. You haven't answered any of the questions, so I don't know what's going on.

commented: i provide every thing, i did some changes but not working can you give me some example i provide Databse struture & code +2

what kind of changes you are suggesting to me

Member Avatar for diafol

i provide every thing, i did some changes but not working can you give me some example i provide Databse struture & code

No you didn't - you didn't answer:

Will you be adding fields like Dec2013, Jan2014 ?

Then...

what kind of changes you are suggesting to me

I already suggested:

fees

fee_id
student_id
period (e.g. 2013-08-01)
fee

The reason for this structure is that you don't want to be creating new fields every time a new month comes along. This also means that you have to change your SQL queries every month. In short it is not maintainable - well it is - but it's a ridiculous amount of work - and there's no need for it.

tnaks all of you but i write new code with the help of sme forums now its working.

Member Avatar for diafol

I'm pleased that we didn't waste our time then :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.