<?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)
?>
This is my php code i wanted to upload on server. but when i upload on server give me error.
Below is error log please help me to solve such kind of requirement.
#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â€
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";
Change this line and try.remove https in the hostname
$con = mysqli_connect("https://myaddress.com”,”abc”,xyz”);
to
$con = mysqli_connect("myaddress.com”,”abc”,xyz”);
Issue 1
Issue is with this line:
$con = mysql_connect("https://myaddress.com”,”abc”,xyz”);
You didn't added opening "
near xyz”
Change it like:
$con = mysql_connect('myaddress.com','abc','xyz');
Check this manual for further details about mysql_connect
Issue 2
Also the following line is also not correct, wrap it in quotes:
$sql=INSERT INTO ‘SampleTable’ (USERID, PASSWORD) VALUES ('$_POST[USERID]’,’$_POST[PASSWORD]’);
Change that to:
$sql= "INSERT INTO ‘SampleTable’ (USERID, PASSWORD) VALUES ('$_POST[USERID]’,’$_POST[PASSWORD]’)";
<?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)
?>
mysql_connect is deprecated as of php 5.5.0 This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used.
$mysqli = new mysqli('localhost', 'my_user', 'my_password', 'my_db');
BUT $connect_error was broken until PHP 5.2.9 and 5.3.0.
if ($mysqli->connect_error)
{
die('Connect Error (' . $mysqli->connect_errno . ')'. $mysqli->connect_error);
}