View Full Version : can I retrieve a value from a mysqldb without opening the db first?
lobaloba9 04-19-2004, 09:10 AM I am writing an affiliate program whereby the affiliate can simply copy and paste a code on his website and that code will automatically retrieve the value of my plans from my db automatically.
I want this because should i change my plans' prices, my affiliates will not need to do any updating of their website as the prices are retrieved from my db.
what language is suitable for this purpose? php possible?
php requires us to open the mysqldb first right? it wouldn't be smart to let outsiders know your mysqldb username and password, so any other solution?
trukfixer 04-19-2004, 09:22 AM you could create a script in php that queries your database on each page load. we did something similar for a client where we created a textads script that he has people run ads on their websites. each time a page is loaded on the client website, it queries OUR client's database for teh correct ad info and updates it accordingly.. so what you wanna do is fairly simple.... I could write the code for you, for a price, or you might be able to find something on a script search...
Bri!
lobaloba9 04-19-2004, 10:54 AM but before you can query the db, you need to open the db right?
and to open the db, you need to add the username and password in your code right? this is the prob.
trukfixer 04-19-2004, 11:03 AM Yeah but that isnt a problem, no one has to know your user name and password. it's set up in a configuration file that no one ever sees. no one will need to know anything other than enough html to copy and paste the html code you give them to run on their website..
everything else would be handled on your website, provided your webhosting can manage php and mysql...
not a problem. :)
the scripts themselves would be about 2,000 lines of code more or less, which would run on your server under your control. the only thing your affiliates would need is a block of html code to insert into their webpages (about 10 lines of html more or less) and would have ZERO access to any sensitive information..
slack 04-19-2004, 02:56 PM You could also just create a new user with its own password and grant read access only to the data you specify. See GRANT:
http://dev.mysql.com/doc/mysql/en/GRANT.html
w3needs 04-19-2004, 03:01 PM These work...you could also...
Everytime you update your plans, have a script to update a text file in you ftp part of your site, or a text file anywhere really. The included script for external site would simple open that file in and print out the data through the browser. This way, no one at all externally can be on the db.
As far as external entry no way is safe, even having a site at all on the net:) But, that is something you can use without at thrills through the grant priveledges. Would be basic and wouldn't hurt, as those users couldn't do anything to the data anyhow...via insert,update,delete or dump calls, as you would limit them to one table with only select priveledges.
Anyhow, the post was just another suggestion:)
Take care.
lucid 04-19-2004, 06:57 PM Why not have a js that can be pulled off your server. The same sort of thing as google adsense.
w3needs 04-19-2004, 11:47 PM ...and the ideas keep coming. I forgot about that too lucid!:)
lobaloba9 04-21-2004, 01:16 AM Originally posted by lucid
Why not have a js that can be pulled off your server. The same sort of thing as google adsense.
yes. THis is exactly the solution i am looking for. do you know of any online resources that might be able to help me with this?
foogee 04-21-2004, 06:18 AM Originally posted by lobaloba9
yes. THis is exactly the solution i am looking for. do you know of any online resources that might be able to help me with this?
All the js file has to do is return a bunch of html inside document.write().
For example make this html document:
<html>
<head>
<title>Untitled</title>
</head>
<body>
<hr>
<script type="text/javascript" src="i.js">
</script>
<hr>
</body>
</html>
and save this in a called i.js file in the same directory as the html:
document.write("<b> This is great </b> <br>")
document.write("<b> and so is this </b> <br>")
If you use css class in the html, your affiliates can customise the look of the html. Also, you can use php on your server to generate the javascript from your database.
There is another, related, method ... you can just declare a bunch of javascript variable in the script which can then be refered to elsewhere in the HTML leaving the the layout completely open for your affiliates.
Of course this does require that your affiliates' website visitors have js enabled browsers.
HTH,
Mike
lobaloba9 04-24-2004, 03:25 AM foogee, your method requires the js file to be in the same directory as the html code. this way, i cannot retrieve generate the data in the js file.
the solution i'm looking for as follows:
- affiliate copy and paste html/js code in his website.
- that code will remotely retrieve prices from my msyql db
- hence, everytime i change the prices, the affiliate need not make any change to the code since the prices will be retrieved from my db.
lucid 04-24-2004, 06:30 AM ofcourse the file doesn't have to be called .js, it can ba a .php which reads the db then outputs document.write('stuff from db');
lobaloba9 04-24-2004, 01:56 PM yes. i know you can use php to read the db and output document.write('stuff from db').
However, that "document.write('stuff from db')" will be in the js file right?
and that js file will be stored in my website directory right?
in that case, how can my affiliate call out to this js file since it is not in the same directory as his html code?
foogee 04-24-2004, 02:17 PM Originally posted by lobaloba9
foogee, your method requires the js file to be in the same directory as the html code.
Actually it can be on another server in another continent, as long as the src part of the javascript tag in the html code is the full URI to the js file.
This is how nearly all affilate ad systems work including google.
Regards,
Mike
another possibility to realize this would be xml-rpc or SOAP ...
just my 2 euro-cents ;)
Michael
lucid 04-24-2004, 06:38 PM just to confirm you could have...
affiliate's html;
<script type="text/javascript" src="http://myhostingdomain.com/i.php">
your i.php;
echo "document.write(\'".$stuff_from_db."\')";
so your affiliate reads the php/js file from your server.
lobaloba9 04-25-2004, 05:58 AM Originally posted by lucid
just to confirm you could have...
affiliate's html;
<script type="text/javascript" src="http://myhostingdomain.com/i.php">
your i.php;
echo "document.write(\'".$stuff_from_db."\')";
so your affiliate reads the php/js file from your server.
ahh... the amazing solution...
thanks everyone for your input!
|