1 Attachment(s)
php dhtml vbscript problem
I have a page of vbscript included by "include file" in a php.
Line 443 shows error:
Quote:
Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\search\cat\cdynlistbox.php on line 443
Line 443 is:
Code:
sTemp = sTemp & "<xsl:stylesheet xmlns:xsl=""http://www.w3.org/TR/WD-xsl"">" & vbCrlf
Code:
<script language="VBScript" runat="server">
...
Private Function GetXSLStream()
Dim sTemp
sTemp = "<?xml version='1.0'?>" & vbCrlf
sTemp = sTemp & "<xsl:stylesheet xmlns:xsl=""http://www.w3.org/TR/WD-xsl"">" & vbCrlf
sTemp = sTemp & "<xsl:template match=""/"">" & vbCrlf
sTemp = sTemp & "if (!assocArray) var assocArray = new Object();<xsl:for-each select=""root/table1"">" & vbCrlf
sTemp = sTemp & "assocArray[""%listname%=<xsl:value-of select=""@search"" />""] = new Array(" & vbCrlf
sTemp = sTemp & "<xsl:for-each select=""table2"">" & vbCrlf
sTemp = sTemp & "<xsl:value-of select=""table2"" /> ""<xsl:value-of select=""@dvalue"" />"",""<xsl:value-of select=""@display"" />""," & vbCrlf
sTemp = sTemp & "</xsl:for-each> ""EOF"");</xsl:for-each>" & vbCrlf
sTemp = sTemp & "</xsl:template>" & vbCrlf
sTemp = sTemp & "</xsl:stylesheet>" & vbCrlf
GetXSLStream = sTemp
End Function
...
</script>
If you want the full script then check out the attached file zipped and in a txt file.
Re: php dhtml vbscript problem
Just so you know, you typically dont mix VBCode with PHP. Are you aware of this?
Re: php dhtml vbscript problem
No I didn't know.
I was converting old asp files to php.
But I'm stuck at this point.
I'm looking for a triple combo listboxes where one has "book" the other "chapter" and the third "verse". The book is populated by a database table. Once book is selected then chapter is populated and then verse.
Any tutorial related to this?
Re: php dhtml vbscript problem
Re: php dhtml vbscript problem
I like this one:
http://www.dynamicdrive.com/dynamici...ects/index.htm
I was using a recycled script from ASP, trying to convert it to php and feel that the same problem might reoccur. I want to use the example above.
Populating the first listbox is alright. But when I don't know how to populate the 2nd listbox.
Re: php dhtml vbscript problem
I'm converting ASP to PHP:
PHP Code:
<?php
/*'Option Explicit*/
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Read the King James Bible</title>
<script language="JavaScript" type="text/javascript">
<!--
function go(action) {
// set variables pointing to the two forms we need
var theForm = document.forms["myForm"];
var otherForm = window.parent.document.forms["myForm"];
// construct the "search" part of the URL from all the elements
var query = "?Book=" + theForm.Book.options[theForm.Book.selectedIndex].value;
query += "&Chapter=" + theForm.Chapter.options[theForm.Chapter.selectedIndex].value;
// test to see if a verse has been selected, if not we won't pass the values
if( theForm.verse.selectedIndex != -1 ) {
for( var i=0; i < theForm.verse.options.length; i++ ) {
if( theForm.verse.options[i].selected ) {
query += "&Verse=" + theForm.verse.options[i].value;
}
}
}
query += "&Keyword=" + escape(otherForm.Keyword.value);
query += "&Keywordb=" + escape(otherForm.Keywordb.value);
query += "&Keywordc=" + escape(otherForm.Keywordc.value);
query += "&Keywordd=" + escape(otherForm.Keywordd.value);
query += "&Keyworde=" + escape(otherForm.Keyworde.value);
query += "&Keywordf=" + escape(otherForm.Keywordf.value);
query += "&";
// either redirect this page or the child frame depending on which select was changed
if(action == "refresh") {
location.href = "showbook.php" + query;
} else {
ifrVerse.location.href = "showverse.php" + query;
}
}
//-->
</script>
</head>
<body>
<?php
/*
Dim Book
Dim Chapter
Dim Verse
Dim DSNName
Dim Conn
Dim RS
Dim SQL1
Dim Keyword
*/
?>
<table border="0" bgcolor="#FFFCDC">
<td>
<form name="myForm" action="showverse.php" method="get" target="ifrVerse">
<table border="0" bgcolor="#FFFCDC">
<tr>
<th align="center" color="white">
</tr>
<tr>
<th colspan="1" align="center">book</th>
<th colspan="1" align="center">chapter</th>
</tr>
<tr>
<td>
<?php
require_once('mysql.php');
/*
'This function checks to see that numerical values are valid
Function ValidateInt(SomeInt)
if IsNumeric(SomeInt) = False or SomeInt = "" then
SomeInt = 1
end if
ValidateInt = SomeInt
End Function
'Setting up search variables
Book = ValidateInt(request("book"))
Chapter = ValidateInt(request("Chapter"))
Verse = request("Verse")
*/
?>
<?php
?>
<input type="hidden" name="Keyword" value="" />
<input type="hidden" name="Keywordb" value="" />
<input type="hidden" name="Keywordc" value="" />
<input type="hidden" name="Keywordd" value="" />
<input type="hidden" name="Keyworde" value="" />
<input type="hidden" name="Keywordf" value="" />
<?php
/*
<a name="bcv"><select name="Book" size="5" style="width:150px;" onChange="go('refresh');"
></a> */
?>
<?php
$result = mysql_query("SELECT DISTINCT book_title, book FROM bible");
echo "<a name='bcv'><select name='Book' size='5' style='width:150px;' onChange=\"go('refresh');\"></a>"."\n";
while($row = mysql_fetch_array($result))
{
echo "<option value='" . $row['book'] . "'>";
echo $row['book_title'];
echo "</option>"."\n";
}
echo "</select>";
//mysql_close($con);
/*
Do until RS.eof
*/
?>
<?php
/*<option if int(book) = int(RS("Book")) then response.write "selected" end if
value="
=RS("Book")
?>">=RS("Book_Title")</option>
RS.movenext
if RS.eof then
exit do
end if
loop
</select>
RS.Close
*/
?>
</td>
<td colspan="1" align="center">
<?php
/*
'This SQL statement creates a list of books
SQL1 = "Select DISTINCT(Chapter), Book FROM Bible WHERE Book = " & Book & " ORDER BY Chapter ASC"
rs.Open sql1,conn, 1
*/
?>
<?php
/* <select name="Chapter" size="5" style="width:75px;" onChange="go('refresh');" 'onchange="go2();">*/
?>
<?php
$result = mysql_query("SELECT DISTINCT chapter, book FROM bible WHERE book = " . $row['book'] . "");
echo "<select name='Chapter' size='5' style='width:150px;' onChange=\"go('refresh');\">"."\n";
while($row = mysql_fetch_array($result))
{
echo "<option value='" . $row['chapter'] . "'>";
echo $row['chapter'];
echo "</option>"."\n";
}
echo "</select>";
mysql_close($con);
/*
Do until RS.eof
*/
?>
<option <?php
/*if int(Chapter) = int(rs("Chapter")) then response.write "selected" end if*/
?> value="<?php
/*=RS("Chapter")*/
?>"><?php
/*=RS("Chapter")*/
?></option>
<?php
/*
rs.movenext
if rs.eof then
exit do
end if
Loop
*/
?>
</select>
I'm getting this error:
Quote:
<select name='Chapter' size='5' style='width:150px;' onChange="go('refresh');">
<br />
<b>Warning</b>: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in <b>C:\xampp\htdocs\wheelofgod\search\cat\showbook.php</b> on line <b>192</b><br />
</select>
Re: php dhtml vbscript problem
that error is telling you that there is something wrong with this:
$result = mysql_query("SELECT DISTINCT book_title, book FROM bible");
there must be a problem with the SQL syntax. Could be that book_title or book fields dont exist or bible table doesnt exisit
Re: php dhtml vbscript problem
I think that in itself is fine. The problem is when I start another $sql, for populating the chapters. What things have to be rename and be distinct?
If $sql applies for the first listbox, then should i Put $sql2 for chapters? What about $result?
Can you verify the syntax making sure that it doesn't confuse between the two?
Re: php dhtml vbscript problem
since it is 2 different queries, it should not matter... Try adding 1 at the end of the other vars
Re: php dhtml vbscript problem
Quote:
Originally Posted by gilgalbiblewhee
I think that in itself is fine. The problem is when I start another $sql, for populating the chapters. What things have to be rename and be distinct?
If $sql applies for the first listbox, then should i Put $sql2 for chapters? What about $result?
Can you verify the syntax making sure that it doesn't confuse between the two?
I think it is not fine. No one will know unless you put an error checking statement in. If you execute a query and it fails it will return FALSE instead of a resource.
If you get the "not a valid MYSQL resource" error, it means your query has failed. Use the following to check.
PHP Code:
$result = mysql_query("SELECT DISTINCT book_title, book FROM bible");
if (! $result) {
echo(mysql_error()); // remove both these lines in production
die(); // version and replace with an error handler.
}
And don't use echo t product HTML :P