PHP和SQL的新功能,试图使语法正确
Sub MultiDArray()
' Define variables
Dim arrayColumns As Integer
Dim arrayRows As Integer
Dim constants() As Integer
Dim initialRow As Integer
Dim initialColumn As Integer
Dim rowCounter As Integer
Dim columnCounter As Integer
' Define how many rows
arrayRows = 4
' Define how many columns
arrayColumns = Range("B3").Value
' Define row to begin gathering data
initialRow = 7
' Define column to begin gathering data
initialColumn = 2
' Redimension array to number of rows and columns
ReDim constants(1 To arrayRows, 1 To arrayColumns)
' Loop through each row
For rowCounter = 1 To arrayRows
' Loop through each column
For columnCounter = 1 To arrayColumns
' Gather data into array
constants(rowCounter, columnCounter) = Cells(rowCounter + initialRow, columnCounter + initialColumn)
' For debugging purposes
Debug.Print "Cell: " & Cells(rowCounter + initialRow, columnCounter + initialColumn).Address, "Row: " & rowCounter, "Column: " & columnCounter, "Value:" & constants(rowCounter, columnCounter)
Next columnCounter
Next rowCounter
End Sub
会话带来的用户ID
这是我要纠正的查询
<?php
include("php/functions.php");
$userId = $_SESSION['userID'];
include("connections/conn.php");
?>
答案 0 :(得分:3)
在重复键更新查询has slightly different syntax上:
INSERT INTO selfesteemscore (
selestscore
, UserID
) VALUES(
'NEW VALUE'
, 'NEW USER ID VALUE'
)
ON DUPLICATE KEY UPDATE
selestscore = 'NEW VALUE'
, UserID = 'NEW USER ID VALUE'
;
或者更好的是,不要重复两次新值:
INSERT INTO selfesteemscore (
selestscore
, UserID
) VALUES(
'NEW VALUE'
, 'NEW USER ID VALUE'
)
ON DUPLICATE KEY UPDATE
selestscore = VALUES(selestscore)
, UserID = VALUES(UserID)
;
警告:请阅读有关SQL注入和转义值或使用粗略语句的信息。
P.S。您初始化变量$ userId,但稍后使用变量$ userID