Jump to content

probably a really easy newbie question: overriding SQL returns for testing..


suranyu

Recommended Posts

Wow, am I glad I found this forum!  :D I spent the past few hours trying to modify a PHP/mySQL script in order to test it. What this script does is basically look up a mySQL database (based on ip2nation) to find out what country and currency the IP address belongs to. This is the code sample:

 

$sql = 'SELECT  c.country, c.curr_code FROM  ip2nationcountries c, ip2nation i WHERE  i.ip < INET_ATON("24.24.24.24") AND c.code = i.country ORDER BY  i.ip DESC LIMIT 0,1';

        $countryName = $db->get_sql_row($sql);

 

I tested the code in PHPmyAdmin and it returns 2 rows:

 

country ------- curr_code (row names)

United States ------- USD (actual values)

 

So basically 2 variables, United States and USD. Now comes the problem, in order to test the script for several countries, I need to be able to "override" the result in the PHP script

 

I tried to do that by commenting out the part that returns the result from the mySQL query and modifying it with the following style, but I think I'm doing something wrong:

 

### $countryName = $db->get_sql_row($sql); ###

$countryName = "United States USD";

 

Is there any way that I can temporarily override the result returned by mySQL and "fake it" so to say? I understand the mySQL query returns 2 rows, so how would I go about overriding 2 rows?

 

I hope this makes sense ...you're all my last hope.

 

:shrug::rtfm::wtf:

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.