I am a beginner at this. I have made a System DSN aas well as a User DSN called 'phpDB'. I tried with the userDSN first and when that gave an error, i created a SystemDSN. I am getting the following errors.
Warning: SQL error: , SQL state 00000 in SQLConnect in C:\php\php\nt\Php_DynTree.php on line 3
Warning: Supplied argument is not a valid ODBC-Link resource in C:\php\php\nt\Php_DynTree.php on line 7
Warning: Supplied argument is not a valid ODBC-Link resource in C:\php\php\nt\Php_DynTree.php on line 126
Warning: Supplied argument is not a valid ODBC-Link resource in C:\php\php\nt\Php_DynTree.php on line 126
I have the Database in MS Access 97. I can do this in ASP but have little clue about PHP
The code is:
<?php
// connect to ODBC database
$connect = odbc_pconnect("phpDB", "nt", "nt");
// query all data from a table
$query = "SELECT * FROM Names";
//execute the query
$rs = odbc_exec($connect, $query);
?>
<head>
<title> Smart Folding Menu Tree- inASP </title>
<style>
<!--
#foldheader{cursor:hand ; font-weight:bold ;
list-style-image:url(fold.gif)}
#foldinglist{list-style-image:url(list.gif)}
//-->
</style>
<script language="JavaScript1.2">
<!--
var head="display:''"
img1=new Image()
img1.src="fold.gif"
img2=new Image()
img2.src="open.gif"
function change(){
if(!document.all)
return
if (event.srcElement.id=="foldheader") {
var srcIndex = event.srcElement.sourceIndex
var nested = document.all[srcIndex+1]
if (nested.style.display=="none") {
nested.style.display=''
event.srcElement.style.listStyleImage="url(open.gif)"
}
else {
nested.style.display="none"
event.srcElement.style.listStyleImage="url(fold.gif)"
}
}
}
document.onclick=change
//-->
</script>
<body>
<ul>
<li id="foldheader">Name</li>
<ul id="foldinglist" style="display:none" style=&{head};>
<?php
while(odbc_fetch_row($rs))
{
print "<li>" . odbc_result($rs, "Name") . "</li>";
}
?>
</ul>
</ul>
<form name=frm method="post" action ="addname.asp">
New Name: <INPUT type="text" size = 10 maxlength=20 name=newName>
<INPUT type="submit" value="Add" >
</form>
<script language="JavaScript1.2">
<!--
/**
Get cookie routine by Shelley Powers
(shelley.powers@ne-dev.com)
*/
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
// if cookie exists
if (offset != -1) {
offset += search.length
// set index of beginning of value
end = document.cookie.indexOf(";", offset);
// set index of end of cookie value
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
if (get_cookie(window.location.pathname) != ''){
var openresults=get_cookie(window.location.pathname).split(" ")
for (i=0 ; i < openresults.length ; i++){
foldinglist[openresults].style.display=''
document.all[foldinglist[openresults].sourceIndex -
1].style.listStyleImage="url(open.gif)"
}
}
if (document.all){
var nodelength=foldinglist.length-1
var nodes=new Array(nodelength)
var openones=''
}
function check(){
for (i=0 ; i <= nodelength ; i++){
if (foldinglist.style.display=='')
openones=openones + " " + i
}
document.cookie=window.location.pathname+"="+openones
}
if (document.all)
document.body.onunload=check
//-->
</script>
</body>
<?php
odbc_close($connect);
?>