Do you have access to php vars outside the tags ?
If i 'GET' some incoming vars i want to parse the incoming data with VBscript,
for ex,
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<body>
<?php
$u= $HTTP_GET_VARS['p'];
?>
<script type="text/vbscript">
Const fsoForWriting = 2
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Open the text file
Dim objTextStream
Set objTextStream = objFSO.OpenTextFile("myXML.xml", fsoForWriting, True)
'Write Data
objTextStream.WriteLine "<?xml version=" & chr(34) & "1.0" & chr(34) & " encoding=" & chr(34) & "ISO-8859-1" & chr(34) & "?>"
objTextStream.WriteLine "<table>"
objTextStream.WriteLine " <ID>" & u & "</FriendID>"
objTextStream.WriteLine "</table>"
'Close the file and clean up
objTextStream.Close
Set objTextStream = Nothing
Set objFSO = Nothing
</script>
</body>
</html>
Isn't giving me any errors but not producing the XML file, also as i said in the title, how do i access the u variables outside the php tags ?
If i put as msgbox u in the VBscript, its empty ?
Re: Do you ave access to php vars outside the tags ?
becareful when printing out XML from php because PHP will parse the <? ?> tags as PHP and not ignore them as you want it to. To get around this just split them up in your code.
As for accessing "u" from outside the php tags, this cant be done, if you want to use a variable from PHP you need to include it inside <? ?> tags. Printing out variable from php is easy so you dont need to worry, it can simply be done like this <?=$variable?>
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<body>
<?php
$u= $HTTP_GET_VARS['p'];
?>
<script type="text/vbscript">
Const fsoForWriting = 2
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Open the text file
Dim objTextStream
Set objTextStream = objFSO.OpenTextFile("myXML.xml", fsoForWriting, True)
'Write Data
objTextStream.WriteLine "<" & "?xml version=" & chr(34) & "1.0" & chr(34) & " encoding=" & chr(34) & "ISO-8859-1" & chr(34) & "?" & ">"
objTextStream.WriteLine "<table>"
objTextStream.WriteLine " <ID><?=$u?></FriendID>"
objTextStream.WriteLine "</table>"
'Close the file and clean up
objTextStream.Close
Set objTextStream = Nothing
Set objFSO = Nothing
</script>
</body>
</html>
Edit:
Just looking at your VBscript what are you trying to do? You cant write files to the clients computer? You can only write cookies.
Re: Do you ave access to php vars outside the tags ?
Ok bit of a newb at this php, i will have incoming data and want to basically output that data to an XML file and thought i could do it using VBscript FILE I/O inside a php file.
Dont even know if you can do this was just assuming you could.
Its not getting past,
VB Code:
Set objTextStream = objFSO.OpenTextFile("myXML.xml", fsoForWriting, True)
Any ideas?
Your answer to the variable works great, thanks!
I know i could do this via php but would rather use vbscript if i can get away with it.
Re: Do you have access to php vars outside the tags ?
Your PHP code is fine but the problem is the VBScript. This runs on the client, since you cannot write file to the clients computer this is why the script is stopping.
If you want to store values on the users computer then i suggest that you use cookies
look at http://www.php.net/setcookie
Gives a good intro into using cookies
Re: Do you have access to php vars outside the tags ?
Will do it in php.
To write an xml file you need tags that encapsulate all your sub cats like
<start>
<name></name>
<date></date>
<name></name>
<date></date>
</start>
talking about the <start> and </start> tags.
So for every new incoming data i have to write an end tag </start> well i need to remove that an readd it onto the end for each write to the xml file, i thought this would work but no luck,
PHP Code:
$read = $read."<HEAD>"."\r\n";
$read = $read." <name>".$a."</name>"."\r\n";
$read = $read." <Time-Date>".$b."</Time-Date>"."\r\n";
$read = $read." <Refs>".$c."</Refs>"."\r\n";
$read = $read."</HEAD>"."\r\n";
$rTag = str_replace("</START>", "", $read);
$rTag = $rTag."</START>";
fwrite($fh, $rTag."\r\n");
Re: Do you have access to php vars outside the tags ?
There is a speical extension which has been written for parsing and editing XML files:
http://www.php.net/domxml
http://www.php.net/dom <-- PHP 5