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
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);

 

?>

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.