PHP中的SQL查询未插入行

时间:2019-02-26 09:24:13

标签: php sql

我用php写了一个用于用户注册的代码。因此,该代码不起作用。我找不到错误。谁能帮助我解决错误。 我尝试并回应了它们都起作用的表单值。但是注释后的代码回显了语句(

services.AddMvc()
        .AddJsonOptions(
            options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
        );

无效。

代码如下:-

#!/usr/bin/env /usr/bin/python3

from pysnmp.entity import engine, config
from pysnmp.carrier.asyncore.dgram import udp
from pysnmp.entity.rfc3413 import ntfrcv
from pysnmp.proto.api import v2c
from pysnmp.smi.rfc1902 import ObjectIdentity

snmpEngine = engine.SnmpEngine()

# Transport setup

# UDP over IPv4
config.addTransport(
    snmpEngine,
    udp.domainName,
    udp.UdpTransport().openServerMode(('0.0.0.0', 162)),
)

# SNMPv3/USM setup
config.addV3User(
    snmpEngine, '<username>',
    config.usmHMACMD5AuthProtocol, '<password>',
    config.usmAesCfb128Protocol, '<password>',
    securityEngineId=v2c.OctetString(hexValue='<engineid>')
)

def cbFun(snmpEngine, stateReference, contextEngineId, contextName,
          varBinds, cbCtx):
    print('Notification from ContextEngineId "%s", ContextName "%s"' (contextEngineId.prettyPrint(), contextName.prettyPrint()))
    for name, val in varBinds:
        print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))

# Register SNMP Application at the SNMP engine
ntfrcv.NotificationReceiver(snmpEngine, cbFun)

snmpEngine.transportDispatcher.jobStarted(1)  # this job would never finish

# Run I/O dispatcher which would receive queries and send confirmations
try:
    snmpEngine.transportDispatcher.runDispatcher()
except:
    snmpEngine.transportDispatcher.closeDispatcher()
    raise

2 个答案:

答案 0 :(得分:0)

您的代码中缺少

my_connect()函数。

 if (!mysqli_query($conn,$sql))
 {
   echo "<script>alert('Error description: " . mysqli_error($conn) . " 
  );</script>";
 }

将以上代码更改为:

 $insert_qry = mysqli_query($conn,$sql);
 if (!$insert_qry)
 {
   echo "<script>alert('Error description: " . mysqli_error($conn) . " 
  );</script>";
 }

答案 1 :(得分:0)

//change
$sql = 'SELECT enroll from alumni where enroll ='.$enroll.'';
//to
$sql = "SELECT enroll from alumni where enroll ='$enroll'";

//change also
$sql = "INSERT INTO alumni (enroll, pass, fullname, fathername, collegename, course, sessionfrom, sessionto, mobno, email, current_status) VALUES (".$enroll." , '".$password."' , '".$fullname."' , '".$fathername."' , '".$collegename."' , '".$course."' , ".$sessionfrom." , ".$sessionto." , ".$mobno." , '".$email."' , '".$currently."')";

//to
$sql = "INSERT INTO alumni (enroll, pass, fullname, fathername, collegename, course, sessionfrom, sessionto, mobno, email, current_status) VALUES ('$enroll' , '$password' , '$fullname' , '$fathername' , '$collegename' , '$course' , '$sessionfrom' , '$sessionto' , '$mobno' , '$email' , '$currently')";//also change this with

know how to use single quote and double quotes.