Member Offer
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

A way of extracting db-info from another server

Discussion in 'Website Design Forum:' started by Kevin, Aug 16, 2011.

  1. Kevin

    Kevin Senior Member

    So I have an ajax script that extracts the 6 most recent urls from a database and puts them in image tags, in the sidebar. It connects to the db-server by calling it 'localhost' and works fine when it runs on a page on my server.

    Now, I want to have that script run in the sidebar of a tumblelog. But it won't run because it can't connect to the database because of that 'localhost'. I tried Google and turns out I had to replace it by the ip of my server. I tried it, but it won't let me because my hosting is on a share IP.

    Soooo... I need a way of accessing those 6 urls from the tumblr-server (by modifying my current script). Or a way of saving the most recent urls to a text file, that I can then process from the tumblr-server (probably through javascript because PHP doesn't work).

    function freshpics(){	var ajax = createREQ();	var rand = parseInt(Math.random()*99999999);	var url = "" + rand;		ajax.onreadystatechange = function(){		var status = ajax.responseText.substr(0,2);		var tekst = ajax.responseText.substr(3);				if(ajax.readyState == 4 && status == "OK"){			document.getElementById("pictures").innerHTML = tekst;		} else if(ajax.readyState == 4 && status != "OK"){			document.getElementById("pictures").innerHTML = "<p>Foto's konden niet ingeladen worden</p>";		}	}"GET", url);	ajax.send(null);	}
    The important part of the PHP
    $dbserver = "localhost"; $user = "deb36814_kevin"; $passwd = "***";$dbnaam = "deb36814_weeds";$query = "SELECT id,src from pictures ORDER BY id DESC LIMIT 6";$link = new mysqli($dbserver, $user, $passwd, $dbnaam);
  2. Sunburn

    Sunburn Active Member

  3. Jazajay

    Jazajay Active Member

    Hi Kevin,
    I'm pretty sure thats a no go due to the joys of XSS attacks. IE may not like it to much. Could be wrong as I've never needed to do it but I know I've had problems in the past with IE and AJAX due to a http issue.

Share This Page