Results 1 to 17 of 17
  1. #1
    Join Date
    May 2002
    Posts
    638

    can I retrieve a value from a mysqldb without opening the db first?

    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?

  2. #2
    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!
    Last edited by trukfixer; 04-19-2004 at 09:29 AM.

  3. #3
    Join Date
    May 2002
    Posts
    638
    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.

  4. #4
    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..

  5. #5
    Join Date
    Oct 2003
    Posts
    124
    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

  6. #6
    Join Date
    Aug 2003
    Location
    PA
    Posts
    110
    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.

  7. #7
    Join Date
    Sep 2003
    Location
    London, UK
    Posts
    188
    Why not have a js that can be pulled off your server. The same sort of thing as google adsense.
    Rob Johnston | LucidUK.com | Rob@LucidUK.com
    Who is Rob? boobear.co.uk
    MSN: msn@luciduk.com | AIM: rob at lucid

  8. #8
    Join Date
    Aug 2003
    Location
    PA
    Posts
    110
    ...and the ideas keep coming. I forgot about that too lucid!

  9. #9
    Join Date
    May 2002
    Posts
    638
    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?

  10. #10
    Join Date
    Sep 2003
    Posts
    126
    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

  11. #11
    Join Date
    May 2002
    Posts
    638
    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.

  12. #12
    Join Date
    Sep 2003
    Location
    London, UK
    Posts
    188
    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');
    Rob Johnston | LucidUK.com | Rob@LucidUK.com
    Who is Rob? boobear.co.uk
    MSN: msn@luciduk.com | AIM: rob at lucid

  13. #13
    Join Date
    May 2002
    Posts
    638
    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?

  14. #14
    Join Date
    Sep 2003
    Posts
    126
    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

  15. #15
    Join Date
    May 2003
    Location
    Bayreuth, Bavaria, Germany
    Posts
    175
    another possibility to realize this would be xml-rpc or SOAP ...
    just my 2 euro-cents

    Michael

  16. #16
    Join Date
    Sep 2003
    Location
    London, UK
    Posts
    188
    just to confirm you could have...
    affiliate's html;
    Code:
    <script type="text/javascript" src="http://myhostingdomain.com/i.php">
    your i.php;
    PHP Code:
    echo "document.write(\'".$stuff_from_db."\')"
    so your affiliate reads the php/js file from your server.
    Rob Johnston | LucidUK.com | Rob@LucidUK.com
    Who is Rob? boobear.co.uk
    MSN: msn@luciduk.com | AIM: rob at lucid

  17. #17
    Join Date
    May 2002
    Posts
    638
    Originally posted by lucid
    just to confirm you could have...
    affiliate's html;
    Code:
    <script type="text/javascript" src="http://myhostingdomain.com/i.php">
    your i.php;
    PHP Code:
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •