Jump to content

garcon

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

garcon's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Oh man, you don't write 'var' in front of an argument in the function definition! 2 minutes more fiddling and I solved it. Sorry!
  2. var xmlhttp; var xmlhttpTwit; //function gets an xmlhttp object function getXmlHttpObj() { if(window.XMLHttpRequest) { //IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if(window.ActiveXObject) { //IE5, IE6 return new ActiveXObject("Microsoft.XMLHTTP"); } //not supported return null; } function loadXmlHttpObj() { //get xmlhttp objects xmlhttp = getXmlHttpObj(); xmlhttpTwit = getXmlHttpObj(); if(xmlhttpTwit == null) { alert("XMLHTTP not supported. You need to upgrade your web browser, suckah."); return; } } //call this to update twitter status function getTwitter() { //set callback function xmlhttpTwit.onreadystatechange = updateTwitter; //open and send request var req = "get_twitter.php"; xmlhttpTwit.open("GET", req, true); xmlhttpTwit.send(null); //restart timer refreshTwitter(); } //calls getTwitter after timeDelay function refreshTwitter() { //60 seconds delay var timeDelay = 60000; setTimeout("getTwitter();", timeDelay); } function updateTwitter() { //if readyState is 4, then request is complete if(xmlhttpTwit.readyState == 4) { //write in new definition document.getElementById("twitterStatus").innerHTML = xmlhttpTwit.responseText; //call last fm update getLastfm(); } } //call this to update lastfm function getLastfm() { //set callback function xmlhttpTwit.onreadystatechange = updateLastfm; //open and send request var req = "get_lastfm.php"; xmlhttpTwit.open("GET", req, true); xmlhttpTwit.send(null); } function updateLastfm() { //if readyState is 4, then request is complete if(xmlhttpTwit.readyState == 4) { //write in new definition document.getElementById("lastfm").innerHTML = xmlhttpTwit.responseText; } } function changeContent(var page) { //loading bar document.getElementById("content").innerHTML = "<img src=\"images/main/loading.gif\" />"; //set callback function xmlhttp.onreadystatechange = updateContent; //open and send request var req = page + ".php"; xmlhttp.open("GET", req, true); xmlhttp.send(null); } function updateContent() { //if readyState is 4, then request is complete if(xmlhttp.readyState == 4) { //write in new definition document.getElementById("content").innerHTML = xmlhttp.responseText; } } If I comment out changeContent() and updateContent() then the Twitter and lastfm bits will work fine. With them in - nothing works! I've tried vice versa. Is there something I don't see going wrong? I'm lost! Cheers
  3. Me being an idiot! The examples in the php.net manual were modifying the array so it was a pointer. I of course don't need this and it appears to have speeded things up a bit. Cheers fella.
  4. <?php $rules_list = explode("*",$venue->rules); echo "<ul class=\"venue_rules\">"; foreach($rules_list as &$rule) { echo "<li>$rule</li>"; } echo "</ul>"; ?> This seems to be slow - the page takes a noticeable couple of seconds to load when testing it on my PC since I added it. I think maybe that is not the correct use of foreach and there's a quicker way to do the same thing? Can anyone point me in the right direction? Cheers.
  5. I've solved it by making sure that $facility_id won't ever be NULL and instead is 0 now. Cheers for the help
  6. $facility_id = $_POST["facility_id"]; if($facility_id == NULL) echo "new"; else echo $facility_id; Why does the above code never echo new? Tis confusing me. I can post code more in full if needed. I've also tried if(!$facility_id)
  7. Why could I only see the missing closed-bracket seconds after posting? The first two questions still stand...
  8. Hi, just started learning php and I've created a little practice website which has 5 "venues" you can post reviews for. You need to sign up to post a review but you don't need to login (so no sessions etc.). There's fields for email/password on the add review form. This is the last script I need to get working then my little site is finished.... When I try to post a review the server returns nothing for this page not even the HTML, previously this has been because I've done something like miss a semi-colon, but I've scoured this script and can't see anything like that. So I guess my questions.. 1. Is there a simple and comprehensive guide out there for installing php/mysql on my home machine 2. Will the above allow me to step through the php line by line so I can debug? 3. Is it just an idiotic mistake like a missing semi-colon in the code below that I can't see? <?php //connection include("connect.php"); //create header escape string thing $returntoform = "Location: add_review.php?id=" . $_POST["venue_id"]; if(isset($_POST["submit"]) { if(empty($_POST["email"]) || empty($_POST["password"]) || empty($_POST["title"]) || empty($_POST["body"])) { echo "Form not completed."; header($returntoform); exit; } //check user details $email = $_POST["email"]; $password = $_POST["password"]; $sql = "SELECT user_id, password FROM user WHERE email='$email'"; $result = mysql_query($sql); if(!$result) { echo "email address not found!"; header($returntoform); exit; } $user = mysql_fetch_object($result); if($user->password != $password) { echo "Password incorrect!"; header($returntoform); exit; } $user_id = $user->user_id; $title = $_POST["title"]; $body = $_POST["body"]; $venue_id = $_POST["venue_id"]; //email and password, OK. Insert review $sql = "INSERT INTO `review` (venue_id, post_date, title, body, user_id) VALUES ('$venue_id', CURRENT_TIMESTAMP, '$title', '$body', '$user_id')"; $result = mysql_query($sql); if(!$result) { echo "Failed to add review!"; } else { echo "Thankyou for your review. Please click <a href=\"venue.php?id="; echo $venue_id; echo "\">here</a> to return to the venue's page and see your review."; } } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.