PHP文件在服务器上传时给出错误

时间:2013-12-03 11:27:04

标签: php

<?php
$con = “mysqli_connect("https://some.com”,”userid”,”password”)”;
if (!$con)
  {
  die('Could not connect:'.mysql_error());
  }

mysql_select_db(“tomcatsp_userID”, $con);

$sql=INSERT INTO ‘SampleTable’ (USERID, PASSWORD) VALUES ('$_POST[USERID]’,’$_POST[PASSWORD]’);

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }

echo "1 record added to tags";

mysql_close($con)
?>

这是我想在服务器上传的php代码。但是当我在服务器上传时给我错误。

下面是错误日志请帮我解决这类要求。

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<?php $con = mysql_connect("https://173.243.120.204:2083â€

5 个答案:

答案 0 :(得分:0)

mysql_connect("address","username","password") or die("cannot connect DB");
mysql_select_db("iglobe") or die("cannot select DB");
$sql="INSERT INTO SampleTable (USERID, PASSWORD) VALUES ('$_POST[USERID]’,’$_POST[PASSWORD]’)";
mysql_query($sql) or die(mysql_error());;
if(!$sqlselect)
  die('Error: '.mysql_error());
else
  echo "1 record added to tags";

答案 1 :(得分:0)

更改此行并尝试在主机名中删除https

$con = mysqli_connect("https://myaddress.com”,”abc”,xyz”);
 to
$con = mysqli_connect("myaddress.com”,”abc”,xyz”);

答案 2 :(得分:0)

第1期

问题在于这一行:

$con = mysql_connect("https://myaddress.com”,”abc”,xyz”);

您未在"

附近添加了xyz”

将其更改为:

$con = mysql_connect('myaddress.com','abc','xyz');

查看本手册,了解有关mysql_connect

的更多详细信息

第2期

以下行也不正确,请用引号括起来:

$sql=INSERT INTO ‘SampleTable’ (USERID, PASSWORD) VALUES ('$_POST[USERID]’,’$_POST[PASSWORD]’);

将其更改为:

$sql= "INSERT INTO ‘SampleTable’ (USERID, PASSWORD) VALUES ('$_POST[USERID]’,’$_POST[PASSWORD]’)";

答案 3 :(得分:0)

<?php
$con = mysqli_connect("myaddress.com","abc","xyz");
if (!$con)
  {
  die('Could not connect:'.mysqli_error());
  }

mysqli_select_db("iglobe", $con);

$sql="INSERT INTO SampleTable (USERID, PASSWORD) VALUES (".$_POST[USERID].",'".$_POST[PASSWORD]."')";
$result=mysqli_query($con,$sql);
if (!$result)
die('Error: ' . mysqli_error());

echo "1 record added to tags";

mysqli_close($con)
?>

答案 4 :(得分:0)

mysql_connect is deprecated as of php 5.5.0 自PHP 5.5.0起,此扩展已弃用,将来将被删除。相反,应该使用MySQLi或PDO_MySQL扩展。

 $mysqli = new mysqli('localhost', 'my_user', 'my_password', 'my_db');
  • 这是“官方”的OO方式,
  • 但是$ connect_error被破坏,直到PHP 5.2.9和5.3.0。

     if ($mysqli->connect_error) 
      {
       die('Connect Error (' . $mysqli->connect_errno . ')'. $mysqli->connect_error);
      }