Jeg får en fejl der lyder:
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
<?php require_once('Connections/cms.php');
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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;
}
}
mysql_select_db($database_cms, $cms);
$query_rsVisSider = "SELECT * FROM sider";
$rsVisSider = mysql_query($query_rsVisSider, $cms) or die(mysql_error());
$row_rsVisSider = mysql_fetch_assoc($rsVisSider);
$totalRows_rsVisSider = mysql_num_rows($rsVisSider);
?><?php require_once('Connections/cms.php');
$query_rsNav = "SELECT * FROM sider";
$rsNav = mysql_query($query_rsNav, $cms) or die(mysql_error());
// top of page under $rsNav
$rsNav2 = mysql_query($query_rsNav, $cms) or die(mysql_error());
$colname_rsTop = (!isset($_GET['id'])) ? "id" : ((get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']));
$menu = (empty($_GET['uID'])) ? 'sider' : 'undersider';
$type = (empty($_GET['uID'])) ? 'main' : 'sub';
$query_rs = "SELECT * FROM $menu WHERE id = $colname_rsTop";
$rs = mysql_query($query_rs, $cms) or die(mysql_error());
$row_rs = mysql_fetch_assoc($rs);
$totalRows_rs = mysql_num_rows($rs);
$colname_rsSub = (!isset($_GET['uID'])) ? $row_rs['id'] : ((get_magic_quotes_gpc()) ? $_GET['uID'] : addslashes($_GET['uID']));
$query_rsSub = "SELECT * FROM undersider WHERE uID = $colname_rsSub";
$rsSub = mysql_query($query_rsSub, $cms) or die(mysql_error());
//$row_rsSub = mysql_fetch_assoc($rsSub);
$totalRows_rsSub = mysql_num_rows($rsSub);
?>
<html>
<head>
<title>index2</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="StyleSheet" href="style.css" type="text/css">
</head>
<body>
<?php
while ($row_rsNav2 = mysql_fetch_assoc($rsNav2))
{
echo '<a class="style4" href="redigerside.php?id=' . $row_rsNav2['id'] . '">' . $row_rsNav2['navn'] . '</a><br>';
if ($row_rsNav2['id'] == $colname_rsSub)
{
while ($row_rsSub = mysql_fetch_assoc($rsSub))
{
echo '<span class="alm"> - </span><a class="style4" href="redigerunderside.php?id=' . $row_rsSub['id'] . '&uID=' . $row_rsSub['uID'] . '">' . $row_rsSub['navn'] . '</a><br>';
}
}
}
?>
</body>
Når der er noget i tabellen "sider" så viser den det og så er der heller ikke nogen problemer. Nå jeg så sletter det, så der ikke er nogen rækker i tabellen sider så kommer den med fejlen. Hvad kan der være galt? Koden laver et php menu træ, eks.:
1
- 1.1
- 1.2
2
3
- 3.1
- osv..