0

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

6
Contributors
28
Replies
135
Views
4 Years
Discussion Span
Last Post by diafol
Featured Replies
  • 1
    diafol 3,720   4 Years Ago

    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 … Read More

  • 1
    diafol 3,720   4 Years Ago

    >Then what i do now Depends. You haven't answered any of the questions, so I don't know what's going on. Read More

0

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

Edited by code_rum

0

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?

0

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

0

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

0

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)

0

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

Edited by spluskhan

0

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

1

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

Votes + Comments
no my DB is (id,Name,Aug2013,Sep2013,Oct2013 & Nov2013 thats it
0

My Fee Database

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

0

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?

1

Then what i do now

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

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

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.

0

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

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.