Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

Need help PHP fail "edit" code

xnayeon

Recruit
Basic Member
Messages
6
Reaction score
0
Points
16
Kelangan ko po ng tulong. Kung ano-ano na ginawa ko ayaw talaga ng edit na code. pero bago ko gawin un.. dun sa Edit page ko nais ko sana lagyan ng values na kapag pinindot yung edit button .. yung existing value na nakalagay, matatawag dun sa form kaso nagbibigay saken ng error. iaattach ko po yung files ko pati na rin yung codes and sql file ko

upon entering po sa site.. mag login po kayo .. Ang username ay "admin" ang password ay "password"
then punta po kayo sa "go to" na tab then choose ticket... makikita nyo po yung error dun tnx po.. gusto ko po sana matuto :pray:
 

Attachments

  • error.png
    error.png
    623.9 KB · Views: 28
  • rog_db.sql.zip
    805 bytes · Views: 6
  • rog.rar
    4 MB · Views: 27
I-post mo na lang dito ang code for edit at pati yung database schema.
 
sa edit form ko po

<!DOCTYPE html>
<html>
<title>Republic of Gamers</title>

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/a.css">
<link rel="stylesheet" href="css/b.css">
<link rel="stylesheet" href="css/c.css">
<style>
body {font-family: "Lato", sans-serif}
.mySlides {display: none}
</style>
<head>
<style>
body {
background-image: url("bg.png");
background-repeat: no-repeat;
background-position: right top;
background-attachment: fixed;
}
</style>
</head>
<BODY>

<?php
$arrUser = array();
$conn = mysql_connect('localhost', 'root', '');
if($conn)
{
if(mysql_select_db('ROG_DB', $conn))
{
$qry = "SELECT * FROM users WHERE id = '". $_GET["id"] ."'";
$result = mysql_query($qry);
while($rows = mysql_fetch_array($result))
{

$arrUser["id"] = $rows['id'];
$arrUser["ticket_no"] = $rows['ticket_no'];
$arrUser["date_and_time"] = $rows['date_and_time'];
$arrUser["branch"] = $rows['branch'];
$arrUser["issue"] = $rows['issue'];
$arrUser["priority"] = $rows['priority'];
$arrUser["technician"] = $rows['technician'];
$arrUser["supervisor"] = $rows['supervisor'];
$arrUser["status"] = $rows['status'];
$arrUser["Action1"] = $rows['Action1'];
$arrUser["Action2"] = $rows['Action2'];
$arrUser["Action3"] = $rows['Action3'];
$arrUser["tech"] = $rows['tech'];
$arrUser["issue"] = $rows['issue'];
$arrUser["SV"] = $rows['SV'];
$arrUser["sv_remarks"] = $rows['sv_remarks'];
}
}
else
{
echo "db not found";
}
}
else
{
echo "cannot connect";
}

mysql_close();

?>

<style>
input[type=text], select {
width: 60%;
padding: 12px 20px;
margin-left: 250px;
display: inline-block;
border: 10px solid #ccc;
border-radius: 4px;
box-sizing: border-box;

}

input[type=datetime-local], select {
width: 60%;
padding: 12px 20px;
margin-left: 250px;
display: inline-block;
border: 10px solid #ccc;
border-radius: 4px;
box-sizing: border-box;

}

input[type=submit] {
width: 100%;
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;

}

input[type=submit]:hover {
background-color: #45a049;
}

input[type=submit] {
width: 60%;
background-color: black;
color: white;
padding: 14px 20px;
margin-left: 100px;
border: none;
border-radius: 4px;
cursor: pointer;
margin-left: 250px;

}

input[type=submit]:hover {
background-color: dimgray;
}




div {
border-radius: 5px;
background-color: snow;
opacity:0.25;
padding: 20px;
}
</style>
<br>
<br>
<br>


<style>
h3 {
color:black;
text-align: center;
font-family: sans-serif;
font-size: 40px;
}
</style>

<style>
h4 {
color:black;
text-align: center;
font-size: 20px;
font-style: normal;
}
</style>

<style>
h5 {
color:black;
text-align: center;
font-size: 20px;
font-style: normal;
}
</style>

<style>
h6 {
color:black;
text-align: center;
font-size: 20px;
font-style: normal;
}
</style>

<style>
h7 {
color:black;
margin-left: 625px;
font-size: 20px;
font-style: normal;
}
</style>

<style>
h8 {
color:black;
margin-left: 620px;
font-size: 20px;
font-style: normal;
}
</style>

<style>
h9 {
color:black;
margin-left: 605px;
font-size: 20px;
font-style: normal;
}
</style>

<style>
h10 {
color:black;
margin-left: 605px;
font-size: 20px;
font-style: normal;
}
</style>

<style>
h11 {
color:black;
margin-left: 625px;
font-size: 20px;
font-style: normal;
}
</style>

<style>
h12 {
color:black;
margin-left: 620px;
font-size: 20px;
font-style: normal;
}
</style>

<style>
h13 {
color:black;
margin-left: 620px;
font-size: 20px;
font-style: normal;
}
</style>

<style>
h14 {
color:black;
margin-left: 620px;
font-size: 20px;
font-style: normal;
}
</style>

<style>
h15 {
color:black;
margin-left: 625px;
font-size: 20px;
font-style: normal;
}
</style>

<style>
h16 {
color:black;
margin-left: 600px;
font-size: 20px;
font-style: normal;
}
</style>

<style>
h17 {
color:black;
margin-left: 635px;
font-size: 20px;
font-style: normal;
}
</style>

<style>
h18 {
color:black;
margin-left: 605px;
font-size: 20px;
font-style: normal;
}
</style>


<form action="editticket.php?id=<?=$arrTicket["id"]?>" method="post">

<br>
<br>
<div class="form-group">
<label><h3>Edit Ticket Form</h3></label><br>

</div>


<div class="form-group">
<label for="ticket_no"><h4>Ticket no:</h4></label><br>
<input type="text" name="ticket_no" placeholder="Ticket no" class="form-control" required="required" value="<?=$arrUser["ticket_no"]?>">
</div>

<div class="form-group">
<label for="date_and_time"><h5>Date and Time:</h5></label>
<input type="datetime-local" value="2016-12-01T07:30" name="date_and_time" required="required" value="<?php echo $date_and_time?>">
</div>

<div class="form-group">
<label for="branch"><h6>Branch:</h6></label>
<select class="form-control" name="branch" value="<?php echo $branch?>">
<option>C5</option>
<option>TUKTUKAN</option>
<option>EVANGELISTA</option>
</select>
</div>

<div class="form-group">
<label for="issue"><h7>Issue:</h7></label><br>
<input type="text" name="issue" placeholder="Issue" class="form-control" value="<?php echo $issue?>">
</div>

<div class="form-group">
<label for="priority"><h8>Priority:</h8></label>
<select class="form-control" name="priority" value="<?php echo $priority?>">
<option>P1</option>
<option>P2</option>
<option>P3</option>
</select>
</div>

<div class="form-group">
<label for="technician"><h9>Technician:</h9></label><br>
<select class="form-control" name="technician" value="<?php echo $technician?>">
<option>Rael</option>
<option>Bhokies</option>
</select>
</div>

<div class="form-group">
<label for="supervisor"><h10>Supervisor:</h10></label>
<select class="form-control" name="supervisor" value="<?php echo $supervisor?>">
<option>Drew</option>
<option>Kim</option>
<option>Thunz</option>
</select>
</div>

<div class="form-group">
<label for="status"><h11>Status:</h11></label>
<select class="form-control" name="status" value="<?php echo $status?>">
<option>Closed</option>
<option>Open</option>
<option>Pending</option>
</select>
</div>

<div class="form-group">
<label for="Action1"><h12>Action 1:</h12> </label>
<input type="text" name="Action1" placeholder="Action1" class="form-control" value="<?php echo $Action1?>">
</div>

<div class="form-group">
<label for="Action2"><h13>Action 2:</h13></label>
<input type="text" name="Action2" placeholder="Action2" class="form-control" value="<?php echo $Action2?>">
</div>

<div class="form-group">
<label for="Action3"><h14>Action 3:</h14></label>
<input type="text" name="Action3" placeholder="Action3" class="form-control" value="<?php echo $Action3?>">
</div>

<div class="form-group">
<label for="tech"><h15>Tech:</h15></label>
<select class="form-control" name="tech" value="<?php echo $Tech?>">
<option> </option>
<option>Ok</option>
</select>
</div>

<div class="form-group">
<label for="tech_remarks"><h16>Tech Remarks:</h16></label>
<input type="text" name="tech_remarks" placeholder="Tech Remarks" class="form-control" value="<?php echo $tech_remarks?>">
</div>



<div class="form-group">
<label for="SV"><h17>SV:</h17></label>
<select class="form-control" name="SV" value="<?php echo $SV?>">
<option> </option>
<option>Ok</option>
</select>
</div>

<div class="form-group">
<label for="sv_remarks"><h18>SV Remarks:</h18></label>
<input type="text" name="sv_remarks" placeholder="SV Remarks" class="form-control" value="<?php echo $sv_remarks?>">
</div>



<input id="btn-submit" type="submit" name="editticket" href= "ticket.php" value="Submit"/>
<br> <a style="color:white; font-size:20px; margin-left:620px;" href="ticket.php">CANCEL</a>

</form>
</div>
</div>
</div>

</form>
</div>
</div>
</div>



<!-- Navbar -->
<div class="w3-top">
<ul class="w3-navbar w3-black w3-card-2 w3-right-align">
<li class="w3-hide-medium w3-hide-large w3-opennav w3-right">
<a class="w3-padding-large" href="javascript:void(0)" onclick="myFunction()" title="Toggle Navigation Menu"><i class="fa fa-bars"></i></a>
</li>



</div>
</li>
</ul>
</div>
<script>

// Used to toggle the menu on small screens when clicking on the menu button
function myFunction() {
var x = document.getElementById("navDemo");
if (x.className.indexOf("w3-show") == -1) {
x.className += " w3-show";
} else {
x.className = x.className.replace(" w3-show", "");
}
}

// When the user clicks anywhere outside of the modal, close it
var modal = document.getElementById('ticketModal');
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>



<!-- End Page Content -->
</div>


<!-- Footer -->
<footer class="w3-container w3-padding-64 w3-center w3-opacity w3-black w3-xsmall">

<img src="logo.png" img size="-100px" >


</footer>

<script>

// Used to toggle the menu on small screens when clicking on the menu button
function myFunction() {
var x = document.getElementById("navDemo");
if (x.className.indexOf("w3-show") == -1) {
x.className += " w3-show";
} else {
x.className = x.className.replace(" w3-show", "");
}
}

// When the user clicks anywhere outside of the modal, close it
var modal = document.getElementById('ticketModal');
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>

</body>
</html>


then sa edit php code ko po

<?php
include("connect.php");
if($con->connect_error) {
die("Connection failed: " . $con->connect_error);
}

if(isset($_POST['editticket']))
{
$id = $_POST['id'];
$editticket_no = $_POST['editticket_no'];
$editdate_and_time = $_POST['editdate_and_time'];
$editbranch = $_POST['editbranch'];
$editissue = $_POST['editissue'];
$editpriority = $_POST['editpriority'];
$edittechnician = $_POST['edittechnician'];
$editsupervisor = $_POST['editsupervisor'];
$editstatus = $_POST['editstatus'];
$editAction1 = $_POST['editAction1'];
$editAction2 = $_POST['editAction2'];
$editAction3 = $_POST['editAction3'];
$edittech = $_POST['edittech'];
$edittech_remarks = $_POST['edittech_remarks'];
$editSV = $_POST['editSV'];
$editsv_remarks = $_POST['editsv_remarks'];



$sql = "UPDATE ticket_main SET ticket_no='$editticket_no',
date_and_time='$editdate_and_time',
branch='$editbranch',
issue='$editissue',
priority='$editpriority',
technician='$edit',
supervisor='$editsupervisor',
status='$editstatus',
Action1='$editAction1',
Action2='$editAction2',
Action3='$editAction3',
tech='$edittech',
tech_remarks='$edittech_remarks',
SV='$editSV',
sv_remarks='$editsv_remarks',
WHERE id='$id'";

if (mysqli_query($con, $sql)) {
header('Location:ticket.php');
}
else {
echo "Error: " . $sql . "<br>" . mysqli_error($con);
}
mysqli_close($con);
}
?>

yung sa database po mga keme lng po un for testing.. kumbaga memalagay lng wala pa syang special tulad ng manipulation.. need lng po talaga ng help kung bakit pumapalpak yung edit ko heheh thanks po in advance
 
<?php
$arrUser = array();
$conn = mysql_connect('localhost', 'root', '');
if($conn)
{
if(mysql_select_db('ROG_DB', $conn))
{
$qry = "SELECT * FROM users WHERE id = '". $_GET["id"] ."'";
$result = mysql_query($qry);
while($rows = mysql_fetch_array($result))
/*gawin mong mysql_fetch_assoc($result) kasi nka column name yun $row[] mo.
or gawin mong $row[0] ang id, $row[1] ang tiket_no and so on based on the index in the database mo kung
gusto mong mysql_fetch_array ang gagamitin mo.*/

{

$arrUser["id"] = $rows['id'];
$arrUser["ticket_no"] = $rows['ticket_no'];
$arrUser["date_and_time"] = $rows['date_and_time'];
$arrUser["branch"] = $rows['branch'];
$arrUser["issue"] = $rows['issue'];
$arrUser["priority"] = $rows['priority'];
$arrUser["technician"] = $rows['technician'];
$arrUser["supervisor"] = $rows['supervisor'];
$arrUser["status"] = $rows['status'];
$arrUser["Action1"] = $rows['Action1'];
$arrUser["Action2"] = $rows['Action2'];
$arrUser["Action3"] = $rows['Action3'];
$arrUser["tech"] = $rows['tech'];
$arrUser["issue"] = $rows['issue'];
$arrUser["SV"] = $rows['SV'];
$arrUser["sv_remarks"] = $rows['sv_remarks'];
}
}
else
{
echo "db not found";
}
}
else
{
echo "cannot connect";
}

mysql_close();

?>

para ito sa undefined index ng "ticket_no".
feedback mo ako ts kung anong resulta.
 
<?php
$arrUser = array();
$conn = mysql_connect('localhost', 'root', '');
if($conn)
{
if(mysql_select_db('ROG_DB', $conn))
{
$qry = "SELECT * FROM users WHERE id = '". $_GET["id"] ."'";
$result = mysql_query($qry);
while($rows = mysql_fetch_array($result))
/*gawin mong mysql_fetch_assoc($result) kasi nka column name yun $row[] mo.
or gawin mong $row[0] ang id, $row[1] ang tiket_no and so on based on the index in the database mo kung
gusto mong mysql_fetch_array ang gagamitin mo.*/

{

$arrUser["id"] = $rows['id'];
$arrUser["ticket_no"] = $rows['ticket_no'];
$arrUser["date_and_time"] = $rows['date_and_time'];
$arrUser["branch"] = $rows['branch'];
$arrUser["issue"] = $rows['issue'];
$arrUser["priority"] = $rows['priority'];
$arrUser["technician"] = $rows['technician'];
$arrUser["supervisor"] = $rows['supervisor'];
$arrUser["status"] = $rows['status'];
$arrUser["Action1"] = $rows['Action1'];
$arrUser["Action2"] = $rows['Action2'];
$arrUser["Action3"] = $rows['Action3'];
$arrUser["tech"] = $rows['tech'];
$arrUser["issue"] = $rows['issue'];
$arrUser["SV"] = $rows['SV'];
$arrUser["sv_remarks"] = $rows['sv_remarks'];
}
}
else
{
echo "db not found";
}
}
else
{
echo "cannot connect";
}

mysql_close();

?>

para ito sa undefined index ng "ticket_no".
feedback mo ako ts kung anong resulta.


Sir ganto po ba?

<?php
$arrUser = array();
$conn = mysql_connect('localhost', 'root', '');
if($conn)
{
if(mysql_select_db('ROG_DB', $conn))
{
$qry = "SELECT * FROM users WHERE id = '". $_GET["id"] ."'";
$result = mysql_query($qry);
while($rows = mysql_fetch_array($result))
{

$arrUser["id"] = $rows[0];
$arrUser["ticket_no"] = $rows[1];
$arrUser["date_and_time"] = $rows[2];
$arrUser["branch"] = $rows[3];
$arrUser["issue"] = $rows['issue'];
$arrUser["priority"] = $rows['priority'];
$arrUser["technician"] = $rows['technician'];
$arrUser["supervisor"] = $rows['supervisor'];
$arrUser["status"] = $rows['status'];
$arrUser["Action1"] = $rows['Action1'];
$arrUser["Action2"] = $rows['Action2'];
$arrUser["Action3"] = $rows['Action3'];
$arrUser["tech"] = $rows['tech'];
$arrUser["issue"] = $rows['issue'];
$arrUser["SV"] = $rows['SV'];
$arrUser["sv_remarks"] = $rows['sv_remarks'];
}
}
else
{
echo "db not found";
}
}
else
{
echo "cannot connect";
}

mysql_close();

?>

ganon parin po error nung nasubukan ko eh:praise::pray::help:
 
sa hindi pagyayabang, mali kayong lahat sa isang bagay.

Sa Query

Errors founds:

-Wrong Table
look at the query:
$qry = "SELECT * FROM users WHERE id = '". $_GET["id"] ."'";

sa table na users
may dalawang fields lang
`user`
`password`

tapos nag loop ka through all the fields based on the `users` table na obviously mali kasi wala doon yung data na gusto mong i access.

-may mga repeating variables

-hindi nagamit ang variables ng array.


Note: Mysql is obsolete better move on with Mysqli or PDO.
Na solve ko na problem mo pero gusto kong ikaw mismo ang mag solve sa problema mo hirap nang i spoon feed nalang dba. Try mo TS. may hints ako sa taas
 
Sir ganto po ba?

<?php
$arrUser = array();
$conn = mysql_connect('localhost', 'root', '');
if($conn)
{
if(mysql_select_db('ROG_DB', $conn))
{
$qry = "SELECT * FROM users WHERE id = '". $_GET["id"] ."'";
$result = mysql_query($qry);
while($rows = mysql_fetch_array($result))
{

$arrUser["id"] = $rows[0];
$arrUser["ticket_no"] = $rows[1];
$arrUser["date_and_time"] = $rows[2];
$arrUser["branch"] = $rows[3];
$arrUser["issue"] = $rows['issue'];
$arrUser["priority"] = $rows['priority'];
$arrUser["technician"] = $rows['technician'];
$arrUser["supervisor"] = $rows['supervisor'];
$arrUser["status"] = $rows['status'];
$arrUser["Action1"] = $rows['Action1'];
$arrUser["Action2"] = $rows['Action2'];
$arrUser["Action3"] = $rows['Action3'];
$arrUser["tech"] = $rows['tech'];
$arrUser["issue"] = $rows['issue'];
$arrUser["SV"] = $rows['SV'];
$arrUser["sv_remarks"] = $rows['sv_remarks'];
}
}
else
{
echo "db not found";
}
}
else
{
echo "cannot connect";
}

mysql_close();

?>

ganon parin po error nung nasubukan ko eh:praise::pray::help:

error nga talaga yan sir kasi ang table na ginamit mo is yung "user".
gamitin mo yung "ticket_main" na table mo.

$qry = "SELECT * FROM ticket_main WHERE id = '". $_GET["id"] ."'";
ngayon ko lang din napansin to kasi ngayon ko lang din nakita yung db na attached mo.
pasensya.
 
Last edited:
sa hindi pagyayabang, mali kayong lahat sa isang bagay.

sa query

errors founds:

-wrong table
look at the query:
$qry = "select * from users where id = '". $_get["id"] ."'";

sa table na users
may dalawang fields lang
`user`
`password`

tapos nag loop ka through all the fields based on the `users` table na obviously mali kasi wala doon yung data na gusto mong i access.

-may mga repeating variables

-hindi nagamit ang variables ng array.


Note: Mysql is obsolete better move on with mysqli or pdo.
Na solve ko na problem mo pero gusto kong ikaw mismo ang mag solve sa problema mo hirap nang i spoon feed nalang dba. Try mo ts. May hints ako sa taas

bosss!!!! Woooooooooo na solve ko na hahahahaa
 
nice...
mabuti naman
mag PDO or MYSQLi kana ts ang luma nang MYSQL
 
Back
Top Bottom