Jump to content

Unable to execute query


zhshero

Recommended Posts

Unable to execute query (SELECT * FROM lb-players) in the database : 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 '-players' at line 1

 

I don't know why i am getting this error. All i can think of that is taking away lb from "lb-players" when you add a " -  "?

 

[m]<?php
$conn = mysql_connect("23.23.23.23", "unknown", "itsAsecertxD");//ignore this xD
if (!$conn) {
echo "Unable to connect to the database : " . mysql_error();
   exit;
}
if (!mysql_select_db("minecraft-rc")) {
   echo "Unable to select database mydbname : " . mysql_error();
   exit;
}
$sql = 'SELECT * FROM lb-players';
$result = mysql_query($sql);
if (!$result) {
   echo "Unable to execute query ($sql) in the database : " . mysql_error();
   exit;
}
if (mysql_num_rows($result) == 0) {
   echo "No rows found, nothing to display.";
   exit;
}
while ($row = mysql_fetch_assoc($result)) {
   echo $row["playername"];
}

mysql_free_result($result);

?>[/m]

 

tell me if i posted this in the wrong place its been forever since i last been on this site :$

Link to comment
https://forums.phpfreaks.com/topic/260721-unable-to-execute-query/
Share on other sites

the code is correct and working me correctly.

 

<?php

$conn = mysql_connect("localhost", "root", "");//ignore this xD

if (!$conn) {

echo "Unable to connect to the database : " . mysql_error();

  exit;

}

if (!mysql_select_db("salhia_arabic")) {

  echo "Unable to select database mydbname : " . mysql_error();

  exit;

}

$sql = 'SELECT * FROM st_admin';

$result = mysql_query($sql);

if (!$result) {

  echo "Unable to execute query ($sql) in the database : " . mysql_error();

  exit;

}

if (mysql_num_rows($result) == 0) {

  echo "No rows found, nothing to display.";

  exit;

}

while ($row = mysql_fetch_assoc($result)) {

  echo $row["admin_username"];

}

 

mysql_free_result($result);

 

?>

 

 

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.