找回密码
 加入
搜索
查看: 4468|回复: 7

[网络通信] 已解决 sql插入语句中如何使用变量

  [复制链接]
发表于 2011-12-2 19:28:52 | 显示全部楼层 |阅读模式
本帖最后由 nop 于 2011-12-2 23:50 编辑

添加记录,如果用常量就可以,变量就不行了,       '"+$vv+"'是不是格式错了?
#include <array.au3>
#include "mysql.au3"

; MYSQL starten, DLL im PATH (enth鋖t auch @ScriptDir), sont Pfad zur DLL angeben. DLL muss libmysql.dll hei遝n.
_MySQL_InitLibrary()
$MysqlConn = _MySQL_Init()
$connected = _MySQL_Real_Connect($MysqlConn, "111.com", "root", "333", "test")
If $connected = 0 Then Exit MsgBox(16, 'Connection Error', _MySQL_Error($MysqlConn))

Dim $vv = "bb"; 
MsgBox(1,"",$vv )
$query1 = "INSERT INTO s  (pc,email) VALUES ('AAAAA-23','"+$vv+"')";
_MySQL_Real_Query($connected, $query1)


$query = "SELECT * FROM s"
_MySQL_Real_Query($connected, $query)


$res = _MySQL_Store_Result($MysqlConn)



$array = _MySQL_Fetch_Result_StringArray($res)
_ArrayDisplay($array)





; Abfrage freigeben
_MySQL_Free_Result($res)

; Verbindung beenden
_MySQL_Close($MysqlConn)
; MYSQL beenden
_MySQL_EndLibrary()
发表于 2011-12-2 21:57:16 | 显示全部楼层
'"&$vv&"'   ...........

评分

参与人数 1金钱 +10 收起 理由
nop + 10

查看全部评分

发表于 2011-12-2 22:37:00 | 显示全部楼层
看看第12行的拼写
发表于 2011-12-2 23:20:17 | 显示全部楼层
变量需要加'引号'
 楼主| 发表于 2011-12-2 23:49:50 | 显示全部楼层
回复 2# sour


    多谢
发表于 2011-12-2 23:58:59 | 显示全部楼层
实在无语。。。爆无语、
发表于 2011-12-2 23:59:32 | 显示全部楼层
太。。。。。回你的贴竟然倒扣20B
发表于 2014-7-9 16:01:01 | 显示全部楼层
学习了,小细节决定大成败
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-6-12 23:28 , Processed in 0.088348 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表