Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

MySQL error: "Incorrect table name ``": [was: please help me]

New Here ,
Apr 07, 2010 Apr 07, 2010

Copy link to clipboard

Copied

the script language is php & mysql database

i created 2 files :

the first : i made in it the following steps :

1- created recordset

2- dragged and dropped one field which i need to delete

3- put ( delete ) word and linked it with the second page by parameter id

and the second page : i made a blank page with one recordset and made it filter by ( id )

next, from insert menu clicked on data objects , insert record and delete record

after that when i preview the the first page in the browser and click in ( delete ) link

the massege appeared is :

Incorrect table name ''

the first page php code :

<?php require_once('../Connections/dwcon.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;   
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$maxRows_rscomment = 10;
$pageNum_rscomment = 0;
if (isset($_GET['pageNum_rscomment'])) {
  $pageNum_rscomment = $_GET['pageNum_rscomment'];
}
$startRow_rscomment = $pageNum_rscomment * $maxRows_rscomment;

mysql_select_db($database_dwcon, $dwcon);
$query_rscomment = "SELECT * FROM `comment`";
$query_limit_rscomment = sprintf("%s LIMIT %d, %d", $query_rscomment, $startRow_rscomment, $maxRows_rscomment);
$rscomment = mysql_query($query_limit_rscomment, $dwcon) or die(mysql_error());
$row_rscomment = mysql_fetch_assoc($rscomment);

if (isset($_GET['totalRows_rscomment'])) {
  $totalRows_rscomment = $_GET['totalRows_rscomment'];
} else {
  $all_rscomment = mysql_query($query_rscomment);
  $totalRows_rscomment = mysql_num_rows($all_rscomment);
}
$totalPages_rscomment = ceil($totalRows_rscomment/$maxRows_rscomment)-1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>التحكم في التعليقات</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="../styles.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
#contmain #main #page #content table tr td div strong {
    color: #0F0;
}
-->
</style>
</head>
<body>
<!-- start header -->
<div id="contmain">
<div id="menu">
        <ul>
            <li><a href="#"></a></li>
            <li><a href="#"></a></li>
            <li><a href="#"></a></li>
            <li><a href="#"></a></li>
            <li><a href="../index.php"></a></li>
        </ul>
    </div>
<div id="main">
<div id="header">
<div id="logo">
    <h1><a href="../index.php"></a><a href="" id="metamorph"></a></h1>
    </div>       
<!-- end header -->
</div>
<!-- start page -->
<div id="page">
  <div align="center">
    <!-- start sidebar two -->
  </div>
  <div id="sidebar2" class="sidebar">
      <ul>
          <li>
                <h2> </h2>
                <div class="title_back">
                <ul>
                  <table width="130" height="136" border="0">
                    <tr>
                      <td height="47" bgcolor="#99CC66"><h1><a href="cp.php">اللوحة الرئيسية</a></h1></td>
                      <td bgcolor="#99CC66"><img src="../images/icons/Dreamweaver.png" width="36" height="35" alt="" /></td>
                    </tr>
                    <tr>
                      <td height="40" bgcolor="#99CC33"><h1><strong>المقالات</strong></h1></td>
                      <td bgcolor="#99CC33"><img src="../images/icons/Dreamweaver.png" width="36" height="35" alt="" /></td>
                    </tr>
                    <tr>
                      <td height="41" bgcolor="#99CC66"><h1><strong><a href="logout.php">تسجيل الخروج</a></strong></h1></td>
                      <td bgcolor="#99CC66"><img src="../images/icons/Dreamweaver.png" width="36" height="35" alt="" /></td>
                    </tr>
                  </table>
                  <li></li>
                </ul>
            </div>
          </li>
          <li>
                <h2> </h2>
                <div class="title_back">
                  <ul>
                  <li><!-- end sidebar two -->
    <!-- start content -->
</li>
                </ul>
                </div>
          </li>
      </ul>
  </div>
  <div id="content">
            <div class="box">
             <div class="box2">
            <h4 align="right"><a href="#"></a></h4>
            <p> </p>
            <p> </p>
             </div>
            </div>
            <?php do { ?>
              <table width="299" border="0" align="center" cellpadding="5" cellspacing="5">
                <tr>
                  <td colspan="2" bgcolor="#006666"><div align="center"><strong>العمليات</strong></div></td>
                  <td width="154" bgcolor="#006666"><div align="center"><strong>العنوان</strong></div></td>
                </tr>
                <tr>
                  <td width="42" bgcolor="#99CC66"><p><img src="../images/icons/Multiply, delete.png" width="43" height="40" alt="hh" /></p>
                    <p><a href="deletecomment.php?comm_id=<?php echo $row_rscomment['comm_id']; ?>">حذف</a></p></td>
                  <td width="53" bgcolor="#99CC66"><p><img src="../images/icons/Configuration Files or Utilities.png" width="44" height="39" alt="yy" /></p>
                    <p><a href="updatecomment.php?comm_id=<?php echo $row_rscomment['comm_id']; ?>">تعديل</a></p></td>
                  <td bgcolor="#99CC66"><?php echo $row_rscomment['comment']; ?></td>
                </tr>
              </table>
  <p> </p>
              <div class="box">
            <div class="box2"> </div></div>
              <?php } while ($row_rscomment = mysql_fetch_assoc($rscomment)); ?>
  </div>
    <!-- end content -->
   
    <div id="bottom" style="clear: both;"></div>
</div><!-- end page -->
<!-- start footer -->
<div id="footer">
    <h1>&copy;</h1>
    <h1><a href=http://www.metamorphozis.com/" title="Flash Website Templates"></a>
        </h1>
</div>
</div>
</div>
<!-- end footer -->
<div style="text-align: center; font-size: 0.75em;"></div></body>
</html>
<?php
mysql_free_result($rscomment);
?>
------------------------------------------------------

the second page php code is :

<?php require_once('../Connections/dwcon.php'); ?>

<?php

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

  if (PHP_VERSION < 6) {

    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {

    case "text":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;

    case "long":

    case "int":

      $theValue = ($theValue != "") ? intval($theValue) : "NULL";

      break;

    case "double":

      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";

      break;

    case "date":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;

    case "defined":

      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

      break;

  }

  return $theValue;

}

}

if ((isset($_GET['comm_id'])) && ($_GET['comm_id'] != "")) {

  $deleteSQL = sprintf("DELETE FROM ``comment`` WHERE comm_id=%s",

                       GetSQLValueString($_GET['comm_id'], "text"));

  mysql_select_db($database_dwcon, $dwcon);

  $Result1 = mysql_query($deleteSQL, $dwcon) or die(mysql_error());

  $deleteGoTo = "commentcontrol.php";

  if (isset($_SERVER['QUERY_STRING'])) {

    $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";

    $deleteGoTo .= $_SERVER['QUERY_STRING'];

  }

  header(sprintf("Location: %s", $deleteGoTo));

}

$colname_Recordset1 = "-1";

if (isset($_GET['comm_id'])) {

  $colname_Recordset1 = $_GET['comm_id'];

}

mysql_select_db($database_dwcon, $dwcon);

$query_Recordset1 = sprintf("SELECT * FROM `comment` WHERE comm_id = %s", GetSQLValueString($colname_Recordset1, "int"));

$Recordset1 = mysql_query($query_Recordset1, $dwcon) or die(mysql_error());

$row_Recordset1 = mysql_fetch_assoc($Recordset1);

$totalRows_Recordset1 = mysql_num_rows($Recordset1);

$colname_rscomment = "-1";

if (isset($_GET['comm_id'])) {

  $colname_rscomment = $_GET['comm_id'];

}

mysql_select_db($database_dwcon, $dwcon);

$query_rscomment = sprintf("SELECT * FROM `comment` WHERE comm_id = %s", GetSQLValueString($colname_rscomment, "int"));

$rscomment = mysql_query($query_rscomment, $dwcon) or die(mysql_error());

$row_rscomment = mysql_fetch_assoc($rscomment);

$colname_rsdeletecomment = "-1";


if (isset($_GET['comm_id'])) {
  $colname_rsdeletecomment = $_GET['comm_id'];
}
mysql_select_db($database_dwcon, $dwcon);
$query_rsdeletecomment = sprintf("SELECT * FROM `comment` WHERE comm_id = %s", GetSQLValueString($colname_rsdeletecomment, "int"));
$rsdeletecomment = mysql_query($query_rsdeletecomment, $dwcon) or die(mysql_error());
$row_rsdeletecomment = mysql_fetch_assoc($rsdeletecomment);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>حذف التعليق</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="../styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<!-- start header -->
<div id="contmain">
<div id="menu">
        <ul>
            <li><a href="#"></a></li>
            <li><a href="#"></a></li>
            <li><a href="#"></a></li>
            <li><a href="#"></a></li>
            <li><a href="../index.php"></a></li>
        </ul>
    </div>
<div id="main">
<div id="header">
<div id="logo">
    <h1><a href="../index.php"></a><a href="http://www.metamorphozis.com/" id="metamorph"></a></h1>
    </div>       
<!-- end header -->
</div>
<!-- start page -->
<div id="page">
  <div align="center">
    <!-- start sidebar two -->
  </div>
  <div id="sidebar2" class="sidebar">
      <ul>
          <li>
                <h2> </h2>
                <div class="title_back">
                <ul><li></li>
                </ul>
                </div>
          </li>
          <li></li>
          <li>
            <div class="title_back"> </div>
            </li>
        </ul>
    </div><!-- end sidebar two -->
    <!-- start content -->
<div id="content">
            <div class="box">
             <div class="box2">
            <h4 align="right"> </h4>
<p> </p>
             </div>
            </div>
<p> </p>
            <div class="box">
        <div class="box2"> </div></div>        
    </div>
    <!-- end content -->
   
    <div id="bottom" style="clear: both;"></div>
</div><!-- end page -->
<!-- start footer -->
<div id="footer">
    <p>&copy; </p>
    <p><a href="http://www.metamorphozis.com/" title="Flash Website Templates"></a>
        </p>
</div>
</div>
</div>
<!-- end footer -->
<div style="text-align: center; font-size: 0.75em;"></div></body>
</html>
<?php
mysql_free_result($Recordset1);
?>

--------------------------------------------------------------------

TOPICS
Server side applications

Views

5.1K
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 07, 2010 Apr 07, 2010

Copy link to clipboard

Copied

When posting in a forum like this, please give your post a meaningful subject line. It helps everyone, including others who might have the same problem, and are looking for a solution.

The cause of your error message almost certainly lies in your second page, which has this code:

if ((isset($_GET['comm_id'])) && ($_GET['comm_id'] != "")) {

  $deleteSQL = sprintf("DELETE FROM ``comment`` WHERE comm_id=%s",

                      GetSQLValueString($_GET['comm_id'], "text"));

What's causing the problem is the extra pair of backticks around `comment`. It should be this:

if ((isset($_GET['comm_id'])) && ($_GET['comm_id'] != "")) {

  $deleteSQL = sprintf("DELETE FROM `comment` WHERE comm_id=%s",

                GetSQLValueString($_GET['comm_id'], "text"));

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 08, 2010 Apr 08, 2010

Copy link to clipboard

Copied

I thought I'd chime in here... Maybe David can shed some light... DW constantly adds a second pair of single quotes to my code (like above.)  It always seems to do it around the same table name in a given page.  I am always going back in and deleting a pair of single quotes that DW just added for some reason.

Any idea why it does that??

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 10, 2010 Apr 10, 2010

Copy link to clipboard

Copied

LATEST

They are not single quotes, but backticks. You can see the difference more clearly here:

This is a single quote: '

This is a backtick: `

Backticks are used by phpMyAdmin and Dreamweaver to allow reserved words or invalid names to be used as column or table names in SQL queries.

It sounds as though you are copying SQL from phpMyAdmin. What is happening is that your SQL already has backticks, and Dreamweaver is adding an extra pair. Don't use backticks in the Dreamweaver Recordset dialog box.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines