Jump to content

ZeroShade

Members
  • Content Count

    186
  • Joined

  • Last visited

Community Reputation

0 Neutral

About ZeroShade

  • Rank
    Member
  1. Hi I have a home server accessible over the net... and I've been tweaking it without touching the server side code... mostly because I don't have access to the asp.net code without a project file or at least I don't think i have access... so I have been adding javascript functionality instead by grabbing file ID's. I am able to stream the file locally when accessing my server locally via a browser but on the web it does not work. I am using an embed tag to embed media player into the page. Any ideas as to why it isn't streaming over the web or any suggestions on how to get it to work? Thanks!~Marty
  2. How can I get the number thats in the first row first column of my table? How can I select something that specific?
  3. I need help... not that kinda help either. I'm playing with php a bit... and what I did was create a separate file that deals with creating a random number and storing it in a database as well. Then I basically need that $select variable returned so that I can use it in my javascript. Can anybody help me out? <?php $username = "Martin"; $password = "Legends"; $hostname = "localhost"; $dbh = mysql_connect($hostname, $username, $password) or die("Unable to connect to database."); mysql_select_db ("RandomNumber", $dbh); srand((double)microtime()*1000000); $rand = rand(1, 5); $row = mysql_query('SELECT * FROM `number`'); $result = mysql_num_rows($row); if ($result == "0") { mysql_query("INSERT INTO number (Number) VALUES ($rand)"); } else { mysql_query("UPDATE number SET Number = '$rand'"); } $select = mysql_query('SELECT COUNT( * ) AS `Rows` , `Number` FROM `number`'); mysql_close($dbh); echo $select;?> var rand should equal what $select is in the php file. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Guess My Number!</title> <script language="javascript" type="text/javascript"> var XMLHttpRequestObject = false; if (window.XMLHttpRequest) { XMLHttpRequestObject = new XMLHttpRequest(); } else if (window.ActiveXObject) { XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Your browser does not support AJAX."); } function getRandomNumber() { var randNum = document.getElementById("guess").value; var url = "rand.php?guess=" + escape(guess); url = url + "?dummy=" + new Date().getTime(); request.open("GET", url, true); request.onreadystatechange = check; request.send(null); } function check() { if (XMLHttpRequestObject) { if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) { var rand = var guess = document.getElementById("guess").value; if (!isNaN(guess)) { if (rand == guess) { alert("You guessed the number!"); location.reload(true); } else if (guess > 5 || guess < 1) { alert("Please guess a number between 1 and 5."); document.getElementById("guess").value = ""; } else if (rand > guess) { alert("Guess higher..."); document.getElementById("guess").value = ""; } else if (rand < guess) { alert("Guess lower..."); document.getElementById("guess").value = ""; } } else { alert("Please insert a valid number"); document.getElementById("guess").value = ""; } } } } </script> </head> <body style="background-color:#000000; color:#ffffff;"> <div style="text-align:center;"> <h1>Pick Your Random Number</h1> </div> <p />Please insert a number from 1 to 5. <form method="post"> <input type="text" id="guess" onkeyup="check()" /> </form> </body></html>
  4. NVM, i needed to put my php script in the head... wasn't thinking.
  5. Now that that error is freed up i can test my page. But I'm still having a problem with the ajax portion to pass the guessed variable through on the onchange. Any thoughts?
  6. Wow... I havn't done something like that for a good 2 years.
  7. I'm trying to get the user to input a number into the textbox and as the user inputs a number a function is called with ajax to see if the number is correct or not... but I'm getting this error: Parse error: syntax error, unexpected T_STRING in c:\Inetpub\vhosts\domain.com\httpdocs\Index.php on line 62 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Guess My Number!</title> <script language="javascript" type="text/javascript"> var XMLHttpRequestObject = false; if (window.XMLHttpRequest) { XMLHttpRequestObject = new XMLHttpRequest(); } else if (window.ActiveXObject) { XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP"); } function getData(data, targetDiv) { if (XMLHttpRequestObject) { var obj = document.getElementById(targetDiv); XMLHttpRequestObject.open("GET", data, true); XMLHttpRequestObject.onreadystatechange = function() { if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) { // Ready state is complete and status is 200. } } var rand = <?php print "'".$rand."'"; ?>; obj.innerHTML = rand; } } </script> </head> <body> <?php $username = "Martin"; $password = "Legends"; $hostname = "localhost"; $dbh = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); mysql_select_db ("RandomNumber", $dbh); srand((double)microtime()*1000000); $rand = rand(0, 5); mysql_query("INSERT INTO number (Number) VALUES ($rand)"); $select = mysql_query('SELECT COUNT( * ) AS `Rows` , `Number` FROM `number`; //mysql_query("DELETE FROM `number` WHERE `number`.`Number` = $rand LIMIT 1"); //mysql_close($dbh); ?> <h1>Pick Your Random Number</h1> <p />Please insert a number from 0 to 5. <form> <input type="text" value="guess" id="guess" onchange="getData('guess', 'targetDiv')" /> </form> <div id="targetDiv"> <p /> </div> </body></html>
  8. ZeroShade

    Not working!

    What do you suggest I should do to create the random number in php... and then using ajax figure out if the user puts in the guessed number in the textbox? I know I could do it in javascript... but that would defeat the purpose of what I'm trying to do.
  9. ZeroShade

    Not working!

    I'm having a problem with my page... basically the targetDiv is suppose to say hi when I pass the guess value from the text field. Anybody see any problems? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Guess My Number!</title> <script language="javascript" type="text/javascript"> var XMLHttpRequestObject = false; if (window.XMLHttpRequest) { XMLHttpRequestObject = new XMLHttpRequest(); } else if (window.ActiveXObject) { XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP"); } function getData(data, targetDiv) { if (XMLHttpRequestObject) { var obj = document.getElementById(targetDiv); XMLHttpRequestObject.open("GET", data); XMLHttpRequestObject.onreadystatechange = function() { if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) { // Ready state is complete and status is 200. } } obj.innerHTML = "<?php if ($select){ echo 'hi'; } mysql_close($dbh); ?>"; } } </script> </head> <body> <?php $username = "username"; $password = "password"; $hostname = "localhost"; $dbh = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); mysql_select_db ("RandomNumber", $dbh); srand((double)microtime()*1000000); $rand = rand(0, 5); mysql_query("INSERT INTO number (Number) VALUES ($rand)"); $select = mysql_query('SELECT COUNT( * ) AS `Rows` , `Number` FROM `number`; //mysql_query("DELETE FROM `number` WHERE `number`.`Number` = $rand LIMIT 1"); //mysql_close($dbh); ?> <h1>Pick Your Random Number</h1> <p />Please insert a number from 0 to 5. <form> <input type="text" value="guess" id="guess" onchange="getData('guess', 'targetDiv')" /> </form> <div id="targetDiv"> <p /> </div> </body></html>
  10. I need to create a random number and store it in a mysql database before the page is finished loading (as soon as possible). How should I go about doing this?
  11. I finally figured it out... I made the mistake and casted my variables as int and not var.
  12. I put the px in after the width and height... and I'm debugging it right now.Its strange because int originalHeight = obj.width; where obj.width = 51 and int originalWidth = obj.height; where obj.height = 23.I doubt this is the problem but those are the height and widths of the thumbnails. But obj isn't a thumbnail. It should be the original picture.It also says on the thumbnail image I click on that an object is expected. Why would this be after I put in the height and width code?
  13. Its probably easier if I showed you what I already have... maybe you can tell me why it doesn't work: <script type="text/javascript" language="javascript"> var xmlHttpRequestObject = false; try { // Firefox, Opera 8.0+, Safari xmlHttpRequestObject = new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttpRequestObject = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); window.location="Default.aspx"; } } } function changeImage(img) { if (xmlHttpRequestObject) { var obj = document.getElementById("ViewImage"); xmlHttpRequestObject.open("GET", img); xmlHttpRequestObject.onreadystatechange = function() { if(xmlHttpRequestObject.readyState == 4 && xmlHttpRequestObject.status == 200) { // The state is complete and the status is successful. } } int originalHeight = obj.width; int originalWidth = obj.height; int panelWidth = 576; int panelHeight; if (originalHeight >= originalWidth) { panelHeight = panelWidth * (originalWidth / originalHeight); panelWidth = originalWidth / (originalHeight / panelHeight); } else { panelWidth = panelWidth * (originalHeight / originalWidth); panelHeight = originalHeight / (originalWidth / panelWidth); } obj.style.width = panelWidth; obj.style.height = panelHeight; obj.src = "album/" + img; } else { alert("Your browser does not support AJAX!"); window.location="Default.aspx"; } } function changeDescription(desc) { if (xmlHttpRequestObject) { var descObj = document.getElementById("objDesc"); xmlHttpRequestObject.open("GET", desc); xmlHttpRequestObject.onreadystatechange = function() { if(xmlHttpRequestObject.readyState == 4 && xmlHttpRequestObject.status == 200) { // The state is complete and the status is successful. } } descObj.innerHTML = desc; } else { alert("Your browser does not support AJAX!"); window.location="Default.aspx"; } } </script> <div style="background-image:url('img/Header.png'); background-repeat:no-repeat; height:50px; font-family:Verdana; text-align:center; font-size:medium; font-weight:bold; "> <br />Photos </div> <center> <asp:Panel ID="ImageViewPanel" runat="server" Height="432px" Width="576px" BorderColor="white" BorderWidth="5px"> <asp:FormView ID="ImageFormView" runat="server" DataSourceID="ImageObjectDataSource" DataKeyNames="ImageId"> <ItemTemplate> <img src='album/<%# Eval("ImageName") %>' id="ViewImage" alt="" /> <div id="objDesc"><%# Eval("ImageDescription") %></div> </ItemTemplate> </asp:FormView> </asp:Panel> <p /><asp:DataList ID="ImageDataList" RepeatDirection="Horizontal" RepeatColumns="5" runat="server" DataKeyField="ImageId" DataSourceID="ImageObjectDataSource"> <ItemTemplate> <div style="padding:10px;"> <img src='album/thumb_<%# Eval("ImageName") %>' onclick="changeImage('<%# Eval("ImageName") %>'); changeDescription('<%# Eval("ImageDescription") %>')" alt='<%# Eval("ImageDescription") %>' style="background-color:White;" /> </div> </ItemTemplate> </asp:DataList> </center>
  14. How can I take a huge image and resize it to fit inside a panel thats 600 by 400? Lets say the image is 2000 by 1700.
×
×
  • Create New...