我无法更新数据库中的数据,但它显示数据是成功的关键,我也有几个错误,但我不知道如何纠正它们,因为我&#39 ;新来的php..please帮助我。
我的firstform.php:
<?php
session_start();
include 'connect.php';
$query = mysql_query("SELECT *FROM firstform WHERE $id='$_SESSION[manager_name]'");
while($row = mysql_fetch_assoc($query))
{
$manager =$row['manager_name'];
$evaluator =$row['evaluator_name'];
$outlet =$row['outlet_location'];
$date =$row['date'];
$day =$row['day'];
$timein =$row['time_in'];
$timeout =$row['time_out'];
$overall=$row['overall'];
$quality=$row['quality'];
$service=$row['service'];
$cleanliness=$row['cleanliness'];
}
?>
这是我的updatefirstform.php:
<?php
//error_reporting(0);
include'connect.php';
session_start();
$manager =$_POST['manager_name'];
$evaluator =$_POST['evaluator_name'];
$outlet =$_POST['outlet_location'];
$date =$_POST['date'];
$day =$_POST['day'];
$timein =$_POST['time_in'];
$timeout =$_POST['time_out'];
$overall=$_POST['overall'];
$quality=$_POST['quality'];
$service=$_POST['service'];
$cleanliness=$_POST['cleanliness'];
mysql_query("UPDATE firstform SET id ='$id' manager_name='$manager', evaluator_name ='$evaluator',outlet_location='$outlet',date='$date',day='$day',time_in ='$timein',time_out='$timeout',overall='$overall',quality='$quality',service='$service',cleanliness='$cleanliness' WHERE $id ='$_SESSION[manager_name]'");
echo ("<SCRIPT LANGUAGE ='JavaScript'>
window.alert ('Data are Sucessfully Updated!')
window.location.href ='secondform.php'
</SCRIPT>");
?>
错误:
Errors :Notice: Undefined variable: manager in C:\xampp\htdocs\marrybrown_clean\firstform.php on line 4
Notice: Undefined index: manager_name in C:\xampp\htdocs\marrybrown_clean\firstform.php on line 4
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\marrybrown_clean\firstform.php on line 6
答案 0 :(得分:1)
设置ID后忘记了,
。在更新条件中,为什么$id
而不是id
?顺便提一下$id
的价值是多少?它应该是这样的:
mysql_query("UPDATE firstform SET id ='$id',
manager_name='$manager',
evaluator_name ='$evaluator',
outlet_location='$outlet',
date='$date',
day='$day',
time_in ='$timein',
time_out='$timeout',
overall='$overall',
quality='$quality',
service='$service',
cleanliness='$cleanliness'
WHERE id = '$_SESSION[manager_name]'");
与SELECT语句相同:
$query = mysql_query("SELECT * FROM firstform WHERE id = '".$_SESSION['manager_name']."'");
在将变量绑定到查询之前,也请使用*_real_escape_string
。
$manager = mysql_real_escape_string($_POST['manager_name']);
// ^^ do this for the rest of your passed-on variables
答案 1 :(得分:0)
Private Sub Timer1__Tick()...
call GET_QUEUED_EMAILS
Timer2.Start
Timer1.Stop
End sub
Private Sub Timer2__Tick()...
call Function2
Timer3.Start
Timer2.Stop
End sub
Private Sub Timer3__Tick()...
call Function3
Timer3.Start
End sub
更新
中的相同问题答案 2 :(得分:0)
首先,manager_name发布数据不能来自您的更新表单,请检查它。
之后使用它
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>JERSEYProject</groupId>
<artifactId>JERSEYProject</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>simple-service-webapp</name>
<build>
<finalName>simple-service-webapp</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
</dependency>
</dependencies>
答案 3 :(得分:0)
我编辑了我的firstform.php:
<?php
//error_reporting(0);
include'connect.php';
session_start();
if(isset($_POST['submit'])) {
$id=mysqli_real_escape_string($_POST['user_id']);
$manager =mysqli_real_escape_string($_POST['manager_name']);
$evaluator =mysqli_real_escape_string($_POST['evaluator_name']);
$outlet =mysqli_real_escape_string($_POST['outlet_location']);
$date =mysqli_real_escape_string($_POST['date']);
$day =mysqli_real_escape_string($_POST['day']);
$timein =mysqli_real_escape_string($_POST['time_in']);
$timeout =mysqli_real_escape_string($_POST['time_out']);
$overall=mysqli_real_escape_string($_POST['overall']);
$quality=mysqli_real_escape_string($_POST['quality']);
$service=mysqli_real_escape_string($_POST['service']);
$cleanliness=mysqli_real_escape_string($_POST['cleanliness']);
mysqli_query("UPDATE firstform SET manager_name='$manager', evaluator_name ='$evaluator',outlet_location='$outlet',date='$date',day='$day',time_in ='$timein',time_out='$timeout',overall='$overall',quality='$quality',service='$service',cleanliness='$cleanliness' WHERE $id ='$_SESSION[user_id]'");
}
if (isset($_GET['submit'])) {
echo ("<SCRIPT LANGUAGE ='JavaScript'>
window.alert ('Data are Sucessfully Updated!')
window.location.href ='secondform.php'
</SCRIPT>");
}
?>
<?php
mysql_close($connection);
?>
and i'm getting this error again, how to fix it?
Notice: Undefined variable: id in C:\xampp\htdocs\marrybrown_clean\firstform.php on line 5
Notice: Undefined index: user_id in C:\xampp\htdocs\marrybrown_clean\firstform.php on line 5
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\marrybrown_clean\firstform.php on line 6
also each my data in my form shows undefined variable like :
<br /><b>Notice</b>: Undefined variable: manager in <b>C:\xampp\htdocs\marrybrown_clean\firstform.php</b> on line <b>139</b><br />
i think my form is okay, but why is it showing error? if i take the id away, how to start my session by manager name only?
This would be my form :
<h2><font size ="5">Pre Evaluation Checklist</font></h2>
<form action="updatefirstform.php" method="post">
<div class="form_settings">
<p><input class ="input" type ="hidden" name="user_id" value ="<?php echo $id; ?>" /> </p>
<p><span>Manager on Duty :</span><input type="manager" id="manager_name" name="manager_name" value="<?php echo $manager;?>" /></p>
<p><span>Evaluator's Name :</span><input type="evaluator_name" name="evaluator_name" value="<?php echo $evaluator;?>" /></p>
<p><span>Outlet Location :</span><input type="outlet_location" name="outlet_location" value="<?php echo $outlet;?>"/></p>
<p><span>Date :</span><input type="date" name="date" value="<?php echo $date;?>" /></p>
<p><span>Day :</span><input type="day" name="day" value="<?php echo $day;?>" /></p>
<p><span>Time In :</span><input type="timein" name="time_in" value="<?php echo $timein;?>" /></p>
<p><span>Time Out :</span><input type="timeout" name="time_out" value="<?php echo $timeout;?>" /></p>
<table width="100%" height="79" border-spacing:0;>
<tr><th width="15%">Overall </th><th width="15%">Quality</th><th width="15%">Service </th><th width="15%"> Cleanliness </th></tr>
<tr><td><input type="overall" name="overall" value ="<?php echo $overall;?>"/></td><td><input type="overall" name="quality" value="<?php echo$quality;?>"/> </td><td><input type="service" name="service" value ="<?php echo $service;?>"/></td><td><input type="cleanliness" name="cleanliness" value="<?php echo $cleanliness;?>"/></td></tr>
</table>
还有我的updatefirstform.php:
#!/opt/lampp/bin/php
<?php
$host = "localhost";
$port = 3027;
$con = 1;
set_time_limit(0);
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP) or die('Could not create socketn');
$result = socket_bind($socket, $host, $port) or die('Could not bind to socketn');
$result = socket_listen($socket, 3) or die('Could not set up socket listenern');
while (true)
{
$spawn = socket_accept($socket) or die('Could not accept incoming connectionn');
if(socket_getpeername($spawn , $host , $port))
{
echo "Client $address : $port is now connected to us. \n";
}
$input = socket_read($spawn, 1024) or die('Could not read inputn');
$input = trim($input);
$output = strrev($input) . 'n';
socket_write($spawn, $output, strlen ($output)) or die('Could not write output n');
}
socket_close($spawn);
socket_close($socket);
?>