Jump to content

[MySQL] Newbie PHP Help Needed


walkineagle

Recommended Posts

<?php
$verificate = $_GET["ver"];
$username = $_GET["user"];
$password = $_GET["pass"];

$dbh = mysql_connect("localhost","XXXXXX_dtbusre","my database password here")
                            or die(mysql_error());
mysql_select_db("databasename_zxq_dtb")     or die(mysql_error());
$sql = "SELECT loggedin FROM entityTable WHERE username=$username";
$result = mysql_query($sql) or die(mysql_error());
while ($line = mysql_fetch_array($result)){
  echo $line[0]."\t".$line[1]."\n";
}
mysql_close($dbh);

if($verificate === "144356455343"){
echo "SURE";
}
else{
echo "NOPE";
}
?>

 

I get this:

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 '' at line 1

Link to comment
https://forums.phpfreaks.com/topic/252280-mysql-newbie-php-help-needed/
Share on other sites

I am a new comer myself. But from what I can see, try to rewrite it like this:

 

$dbh = mysql_connect("localhost","XXXXXX_dtbusre","my database password here", "databasename_zxq_dtb" );

$sql = "SELECT loggedin FROM entityTable WHERE username = '{$username}'";

$result = mysql_query($dbh, $sql) or die(mysql_error());

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.