这是我的代码,由于某种原因,我是否为输入id指定了一个值,它似乎提供了一个,因为只运行if语句.此外,当我为id(或不)提供值时,不会更新或更改任何内容.
<?php
$culture = $_POST["culture"];
if (isset($_POST["id"])) {
$UID = $_POST["id"];
mysql_query("UPDATE culture SET cult_desc='$culture' WHERE cult_id=$UID");
echo $UID . " " . $culture . " If Statement Activated";
}
else {
mysql_query("INSERT INTO culture
VALUES(cult_desc='$culture')");
echo $culture . " Else Statement Activated";
}
?>
Run Code Online (Sandbox Code Playgroud)
这是html代码:
<form action="addculture.php" method="POST">
<span><input type="text" size="3" name="id" />
<input type="text" name="culture" />
<input type="submit" value="add" /></span>
</form>
Run Code Online (Sandbox Code Playgroud) 我遇到的问题是我有一个用户输入字符串...可能是少于156个字符,如果字符串中没有撇号或引号,DBI语句将完美地插入字符串.
这很好 - >我正在工作!这不起作用 - >我不工作!
要插入我使用以下代码:
$sth = $dbh->prepare("INSERT INTO table VALUES('$var1','$var2','$var3')");
$sth->execute();
Run Code Online (Sandbox Code Playgroud)
我知道Perl用"'和""插入不同的字符串,但是当我尝试时,我的程序会抛出一个拟合.我也尝试使用联接使用""标记一起加入该prepare语句.存储155个字符的变量如果重要则为$ var3,并且所有3个都是VARCHAR属性.有什么建议?
例:
INSERT INTO table.Diagnosis([DESCRIPTION]) VALUES('person's')
Run Code Online (Sandbox Code Playgroud)
怎么插入呢?
我是编程的新手.我有我的程序有问题,我所要做的是创建一个注册页面,以便用户可以注册,它会保存到SQL数据库,但我得到了一个错误,我不知道这意味着什么,我会全贴错误消息抱歉,如果它不具体.如果可能的话,请用简单的语言向我解释.
这是我的代码:
protected void registerBtn_Click(object sender, EventArgs e)
{
String conString = @"Data Source=sql-server;Initial Catalog=wa310;Integrated Security=True";
SqlConnection myConnection = new SqlConnection(conString);
string cmd = "INSERT INTO Student( First_Name, Surname, User_ID, Password) VALUES ( '" + fNameTxt.Text + "' , '" + sNameTxt.Text + "','" + userIdTxt.Text + "' ,'" + passwordTxt.Text + "')";
SqlCommand myCommand = new SqlCommand(cmd, myConnection);
try
{
myCommand.Connection = myConnection;
myConnection.Open();
myCommand.ExecuteNonQuery();
Label1.Text = "You have successfully registered";
}
catch (Exception ex)
{
Label1.Text = "Exception …Run Code Online (Sandbox Code Playgroud) 我运行了几分钟前制作的脚本,但仍然没有完成运行.
现在它有了,我得到了500内部服务器错误.
编辑---错误发生在第126行,这是while循环的端口:
while ($row == mysql_fetch_assoc($query)) {
mysql_query("DELETE FROM `Likes` WHERE `accountID` = '$id'");
}
Run Code Online (Sandbox Code Playgroud)
请问你能告诉我是什么导致我的脚本这么慢?
if ($param == "closeAccount") {
$username = NULL;
$password = NULL;
$emailAdd = NULL;
$id = NULL;
if (isset($_GET['username'])) {
$username = $_GET['username'];
}
else {
exit("No username is set");
}
if (isset($_GET['password'])) {
$password = md5($_GET['password']);
}
else {
exit("No password is set");
}
if (isset($_GET['emailAddress'])) {
$emailAdd = $_GET['emailAddress'];
}
else {
exit("No email address is set");
}
$query = …Run Code Online (Sandbox Code Playgroud) mysql_fetch_array在我的代码中不起作用: - 我得到了这样的错误......
警告:mysql_fetch_array():提供的参数不是第38行的C:\ Program Files\xampp\htdocs\finalreports\generatereport.php中的有效MySQL结果资源
我的代码到目前为止....
if(array_key_exists('server_guid',$_GET))
{
$guids = $_GET['server_guid'];
$guid_array = explode(",",$guids);
//$reporttype = "Server Resources";
for($i=0 ; $i<count($guid_array); $i++)
{
$query = "select vid from vendor_registration where bussname='".$guid_array[$i]."'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
$name_array[$i] = $row[0];
}
}
}
Run Code Online (Sandbox Code Playgroud) 如果我讨厌你们,我真的很抱歉,但这是关于.htaccess技巧的最后一个问题
我需要wordpress风格,'非常永久链接'
但这对我来说太混乱了.
我需要,这个网址http://test.com/?page=test&ID=1是http://test.com/test/NAMEFROMDATABASE
怎么样?我知道如何ID=1通过使用$_GET['ID'],但如何将数据库中的值放入网址,并阅读它?
问题是我的代码没有使用asp.net c#将新记录插入/保存到我的SQL Server数据库中,并且没有给我任何错误.
这是我的代码:
public partial class AddNews_AddNews : System.Web.UI.Page
{
protected SqlConnection _connection;
protected SqlCommand _command;
protected SqlDataAdapter _adp;
protected System.Data.DataTable _tbl;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click1(object sender, EventArgs e)
{
prepareConnection();
_command.CommandText = "INSERT INTO" + drbdlSection.SelectedItem + "(Title,Contect) VALUES (" + titleTextBox.Text + "," + CKEditor1.Text + ");";
}
protected void prepareConnection()
{
_connection = new SqlConnection(@"Data Source=localhost;Initial Catalog=BrainStorms;User ID=sa;Password=xxx");
_connection.Open();
_command = new SqlCommand();
_command.Connection = _connection;
}
}
Run Code Online (Sandbox Code Playgroud) 我尝试在c#.NET中使用3轮胎架构在DB中插入数据,但是出现以下错误.
错误:
Server Error in '/3tweb' Application.
Incorrect syntax near the keyword 'User'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'User'.
Source Error:
Line 25: objconn.Open();
Line 26: SqlCommand objcmd = new SqlCommand(sqlstring, objconn);
Line 27: objcmd.ExecuteNonQuery();
Line 28: }
Line 29: public DataSet LoadCustomerDB()
Source File: C:\ASP …Run Code Online (Sandbox Code Playgroud) sqlQuery = "INSERT INTO community_market" +
"VALUES (" + a.transaction_id + ",'" + a.community_name + "'," +
a.community_id + ",'" + a.item_name + "'," +
a.item_quantity + "," + a.price + ");";
Run Code Online (Sandbox Code Playgroud)
这是我试图运行的查询,我得到的错误是:
SqliteSyntaxException:near"1":语法错误Mono.Data.SqliteClient.SqliteCommand.GetNextStatement(IntPtr pzStart,System.IntPtr&pzTail,System.IntPtr&pStmt)Mono.Data.SqliteClient.SqliteCommand.ExecuteReader(CommandBehavior behavior,Boolean want_results,System. Int32和rows_affected)Mono.Data.SqliteClient.SqliteCommand.ExecuteReader(CommandBehavior behavior)Mono.Data.SqliteClient.SqliteCommand.ExecuteDbDataReader(CommandBehavior behavior)System.Data.Common.DbCommand.ExecuteReader()System.Data.Common.DbCommand.System. Data.IDbCommand.ExecuteReader()
可以使用一些帮助
尝试学习和理解 SQL 注入。
谁能向我解释为什么' or 1=1; --- 允许我绕过身份验证但or 1=1没有?
我厌倦了看到这个错误信息任何人请帮助我; 它是一个简单的php mysql搜索引擎; 其中搜索元素是"adm_no";
mY代码如下
<?php
require_once("lib/connection.php");
require_once("lib/functions.php");
$adm_no=$_POST['adm_no'];
//if (!$adm_no==ctype_digit) echo "You Entered wrong Admission no Recheack Admission no" ; exit();
$clas=$_POST['clas'];
$query="SELECT * FROM $clas WHERE adm_no = $adm_no";
$result = mysql_query($query);
//searchs the query in db.
while($result = mysql_fetch_array( $result))
{
echo $result['adm_no'];
echo " ";
echo $result['adm_dt'];
echo "";
echo $result['name'];
echo "";
echo $result['dob'];
echo " ";
echo $result['f_name'];
echo " ";
echo $result['f_office'];
echo " ";
echo $result['f_o_no'];
echo " ";
echo …Run Code Online (Sandbox Code Playgroud) mysql ×6
php ×5
c# ×4
asp.net ×3
sql-server ×3
sql ×2
.htaccess ×1
dbi ×1
message ×1
mod-rewrite ×1
perl ×1
permalinks ×1
sqlite ×1
string ×1
t-sql ×1