Jump to content

External domain price list


SoBeIt

Recommended Posts

Ok, I'm stumped............again.....

 

I copy/pasted this....

<center><font color="#F7890C"><strong>{$LANG.domainspricing}</strong></font></center>

<table class="clientareatable" cellspacing="1">
<tr class="clientareatableheading"><td>{$LANG.domaintld}</td><td>{$LANG.domainminyears}</td><td>{$LANG.domainsregister}</td><td>{$LANG.domainstransfer}</td><td>{$LANG.domainsrenew}</td></tr>
{foreach key=num item=tldpricelist from=$tldpricelist}
<tr class="clientareatableactive"><td>{$tldpricelist.tld}</td><td>{$tldpricelist.period}</td>
<td>{$tldpricelist.register}{$currencysymbol}{$tldpricelist.register} {$currency}</td>
<td>{$tldpricelist.transfer}{$currencysymbol}{$tldpricelist.transfer} {$currency}</td>
<td>{$currencysymbol}{$tldpricelist.renew} {$currency}</td></tr>
{/foreach}
</table>

From the domainchecker.tpl to try to move the table onto the homepage.tpl but it's a no go!

 

MYSQL no where on the domainchecker.tpl is there a database connect line, and no where in the homepage.tlp is there a database connect line, AND no where in the header.tpl is there a database connect line, AAANNNNDDDD no where in index.php and domainchecker.php is there a database connect line.... SO what all these DO have in common...? The ioncube loader....IS this the database connect you speak of!?! Sheeesh! LOL

 

Doesn't seam so simply anymore!

 

Can someone PLEASE explain and tell us HOW it can be done instead of just pokin fun at us newbs...?

 

Thank you.

Link to comment
Share on other sites

I hope it fits in here ;)

 

We have our domain price list on a separate server. So it's not sharing any hardware or software with the WHMCS installation. I therefore copied the config file from the WHMCS installation to the second server and included it our PHP file about domainname registrations.

 

I allowed the second server to connect to the database on the WHMCS server (via mySQL) and opened up the firewall to allow mySQL connections from this one host only (security reasons).

 

The following code allthough far from optimized ( so don't flame ;) ) allowed us to show domainname prices from the WHMCS database so any changes to the domain pricing are instantly visible on our domainname registration page.

 

Happy playing :)

 

Code below:

 

<TABLE cellSpacing="1" cellPadding="2" width="75%" align="center" bgColor="#cccccc" border="0">

<tr bgColor="#efefef">

<td><div align="center"><strong>Extension</strong></div></td>

<td><div align="center"><strong>Registration<br />Period</strong></div></td>

<td><div align="center"><strong>New<br /> Registration</strong></div></td>

<td><div align="center"><strong>Renewal</strong></div></td>

<td><div align="center"><strong>Transfer</strong></div></td>

<td><div align="center"><strong>DNS<br />Management</strong></div></td>

<td><div align="center"><strong>E-mail<br />forwarding</strong></div></td>

<td><div align="center"><strong>ID Protection</strong></div></td>

</tr>

 

<?php

 

// Background color 1 and 2

$kleur1 = "#eeeeee";

$kleur2 = "#cccccc";

 

// counter to help determine which background color to use

$i = 1;

require "../configuration.php";

$link = mysql_connect($db_host, $db_username ,$db_password) or die("Unable to connect to database: " . mysql_error());

@mysql_select_db($db_name) or die( "Unable to select database");

// Formulate Domeinnaam tarieven Query

$query = sprintf("SELECT * FROM `tbldomainpricing` ORDER by `order` ASC",

mysql_real_escape_string($extension),

mysql_real_escape_string($registrationperiod),

mysql_real_escape_string($register),

mysql_real_escape_string($transfer),

mysql_real_escape_string($renew),

mysql_real_escape_string($dnsmanagement),

mysql_real_escape_string($emailforwarding),

mysql_real_escape_string($idprotection)

);

 

// Perform Query

$result = mysql_query($query);

 

// Check result

// This shows the actual query sent to MySQL, and the error. Useful for debugging.

if (!$result) {

$message = 'Invalid query: ' . mysql_error() . "\n";

$message .= 'Whole query: ' . $query;

die($message);

}

mysql_free_result($result);

mysql_close($link);

 

while ($tld = mysql_fetch_assoc($result)) {

 

// Attempting to print $result won't allow access to information in the resource

// One of the mysql result functions must be used

// See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc.

 

do {

// Set the row background color

$bg_kleur = ( $i % 2 == 0 ) ? $kleur1 : $kleur2;

//

// print TLD

//

if ( $tld['extension'] ) {

echo "<tr>";

echo "<td style=\"background-color: " . $bg_kleur . "\">";

echo $tld[extension];

echo "</td>";

}

//

// print registration period per tld

//

echo "<td align=\"right\"style=\"background-color: " . $bg_kleur . "\">";

if ( $tld['registrationperiod'] ) {

echo $tld['registrationperiod']." year";

} else { echo " "; }

echo "</td>";

//

// print TLD New registration price

//

echo "<td align=\"right\"style=\"background-color: " . $bg_kleur . "\">";

if ( $tld['register'] ) {

printf ('€ %01.2f', $tld['register']);

} else { echo " "; }

echo "</td>";

//

// print TLD renewal price

//

echo "<td align=\"right\"style=\"background-color: " . $bg_kleur . "\">";

if ( $tld['renew']) {

printf ('€ %01.2f', $tld['renew']);

} else { echo " "; }

echo "</td>";

//

// print TLD Transfer price

//

echo "<td align=\"right\"style=\"background-color: " . $bg_kleur . "\">";

if ( $tld['transfer'] > "0" ) {

printf ('€ %01.2f', $tld['transfer']);

} else { echo " "; }

echo "</td>";

//

// print TLD DNS Management price

//

echo "<td align=\"center\"style=\"background-color: " . $bg_kleur . "\">";

if ( $tld['dnsmanagement'] ) {

echo "Yes"; //$tld['dnsmanagement'];

} else { echo " "; }

echo "</td>";

//

// print TLD emailforwarding price

//

echo "<td align=\"center\"style=\"background-color: " . $bg_kleur . "\">";

if ( $tld['emailforwarding'] ) {

echo "Yes"; // $tld['emailforwarding'];

} else { echo " "; }

echo "</td>";

//

// print TLD idprotection price

//

echo "<td align=\"center\"style=\"background-color: " . $bg_kleur . "\">";

if ( $tld['idprotection']) {

echo "Yes";// $tld['idprotection'];

} else { echo " "; }

echo "</td></tr>";

// Increment counter to determine row background color

$i++;

} while ($tld = mysql_fetch_assoc($result));

}

 

?>

 

</table>

Link to comment
Share on other sites

I'm getting an error...

 

Warning: mysql_fetch_array(): 3 is not a valid MySQL result resource in /home/user/public_html/test.php on line 49

 

line #49 is....

 

while ($tld = mysql_fetch_assoc($result)) {

 

It says:

 

// Attempting to print $result won't allow access to information in the resource

// One of the mysql result functions must be used

// See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc.

 

And I've tried the different combos but still got errors...

 

I googled it and am thinking the line isn't written correctly....

 

Any ideas...?

 

Thanks!

Link to comment
Share on other sites

I ran the errant line in myphpadmin and got this:

 

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'while ($tld = mysql_fetch_array($result, MYSQL_BOTH))' at line 1

 

So it's a version issue? I'm on mysql 5.

 

Hmmm....

Link to comment
Share on other sites

I'm stumped!

 

I've even tried creating a simple table of mysql query results with:

 

while($row = mysql_fetch_array($result))

 

...and no matter what the...

 

while ($tld = mysql_fetch_assoc($result))

 

...line is, I get...

 

supplied argument is not a valid MySQL result resource

 

Does ANYONE have any ideas?

 

Thanks!

Link to comment
Share on other sites

ok....nevermind!

 

I started from scratch makin a table from a mysql database, and got it to work.

 

Here's my code:

{php}
mysql_connect("localhost", "user", "password") or die(mysql_error());
mysql_select_db("dbname") or die(mysql_error());
$result = mysql_query("SELECT * FROM tbldomainpricing")
or die(mysql_error());  
echo "<table width='500' border='0'>";
echo "<tr>
<th>TLD</th>
<th>Min. Years</th>
<th>Register</th>
<th>Transfer</th>
<th>Renew</th>
</tr>";
while($row = mysql_fetch_array($result)){
echo "<tr><td>"; 
echo $row['extension'];
echo "</td><td>"; 
echo $row['registrationperiod'];
echo "</td><td>"; 
echo "$";
echo $row['register'];
echo "</td><td>";
echo "$";
echo $row['transfer'];
echo "</td><td>";
echo "$";
echo $row['renew'];
echo "</td></tr>";
} 
echo "</table>";
{/php}

 

This is REAL basic, so you could expand off of it...

 

Enjoy!

Link to comment
Share on other sites

Hi,

 

we are running it on PHP 5.0.4 with mySQL 4.1.x

Did you copy and paste it correctly as I took the code from our php source file.

 

for an sample output have a look at http://internet.dutch-net.nl/Domeinnaam/index.php

 

Our configure command for php on Linux is:

'./configure' '--prefix=/usr' '--datadir=/usr/share/php5' '--mandir=/usr/share/man' '--bindir=/usr/bin' '--libdir=/usr/lib64' '--includedir=/usr/include' '--with-_lib=lib64' '--sysconfdir=/etc/php5/apache2' '--with-config-file-path=/etc/php5/apache2' '--with-config-file-scan-dir=/etc/php5/conf.d' '--with-exec-dir=/usr/lib64/php5/bin' '--enable-magic-quotes' '--enable-libxml' '--enable-session' '--with-pcre-regex' '--enable-xml' '--enable-simplexml' '--enable-spl' '--enable-safe-mode' '--enable-sigchild' '--disable-debug' '--enable-memory-limit' '--enable-inline-optimization' '--disable-rpath' '--with-apxs2=/usr/sbin/apxs2' '--disable-all' '--disable-cli' '--enable-calendar' '--with-gd' '--with-zlib' '--with-jpeg-dir=/usr/lib' '--enable-gd-native-ttf' '--with-ttf' '--with-png' '--with-freetype-dir=/usr/lib' '--with-iconv' '--enable-gd-imgstrttf' '--with-t1lib'

Link to comment
Share on other sites

Ooooopssss

 

I think I have located the problem:

 

Please put a remark // before the following two lines starting with mysql_free and mysql_close

 

mysql_free_result($result);

mysql_close($link);

 

while ($tld = mysql_fetch_assoc($result)) {

 

 

and add copies of these lines (without the remarks) just after these two lines but before ?>

} while ($tld = mysql_fetch_assoc($result));

}

 

?>

 

sorry for the error and the inconvenience

Link to comment
Share on other sites

I don't understand what you're saying... could you post the code?

This is what I have, what I understand you want me to do...

 

// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
//mysql_free_result($result);
//mysql_close($link);

} while ($tld = mysql_fetch_assoc($result));
}

// Attempting to print $result won't allow access to information in the resource
// One of the mysql result functions must be used
// See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc.

do {

Link to comment
Share on other sites

ok I think I figured it out...

 

<TABLE cellSpacing="1" cellPadding="2" width="500" align="center" bgColor="#cccccc" border="0">
<tr bgColor="#efefef">
<td><div align="center"><strong>Extension</strong></div></td>
<td><div align="center"><strong>Registration<br />Period</strong></div></td>
<td><div align="center"><strong>New<br /> Registration</strong></div></td>
<td><div align="center"><strong>Renewal</strong></div></td>
<td><div align="center"><strong>Transfer</strong></div></td>
</tr>

<?php

// Background color 1 and 2
$kleur1 = "#eeeeee";
$kleur2 = "#cccccc"; 

// counter to help determine which background color to use
$i = 1; 
require "configuration.php";
$link = mysql_connect($db_host, $db_username ,$db_password) or die("Unable to connect to database: " . mysql_error());
@mysql_select_db($db_name) or die( "Unable to select database");
// Formulate Domeinnaam tarieven Query
$query = sprintf("SELECT * FROM `tbldomainpricing` ORDER by `order` ASC",
mysql_real_escape_string($extension),
mysql_real_escape_string($registrationperiod),
mysql_real_escape_string($register),
mysql_real_escape_string($transfer),
mysql_real_escape_string($renew)
);

// Perform Query
$result = mysql_query($query);

// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
//mysql_free_result($result);
//mysql_close($link);

//while ($tld = mysql_fetch_assoc($result)) {

// Attempting to print $result won't allow access to information in the resource
// One of the mysql result functions must be used
// See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc.

do {
// Set the row background color
$bg_kleur = ( $i % 2 == 0 ) ? $kleur1 : $kleur2;
//
// print TLD
//
if ( $tld['extension'] ) {
echo "<tr>";
echo "<td align=\"center\" style=\"background-color: " . $bg_kleur . "\">";
echo $tld[extension];
echo "</td>";
}
//
// print registration period per tld
//
echo "<td align=\"center\" style=\"background-color: " . $bg_kleur . "\">";
if ( $tld['registrationperiod'] ) {
echo $tld['registrationperiod']." year";
} else { echo " "; }
echo "</td>";
//
// print TLD New registration price
//
echo "<td align=\"center\" style=\"background-color: " . $bg_kleur . "\">";
if ( $tld['register'] ) {
printf ('$ %01.2f', $tld['register']);
} else { echo " "; }
echo "</td>";
//
// print TLD renewal price
//
echo "<td align=\"center\" style=\"background-color: " . $bg_kleur . "\">";
if ( $tld['renew']) {
printf ('$ %01.2f', $tld['renew']);
} else { echo " "; }
echo "</td>";
//
// print TLD Transfer price
//
echo "<td align=\"center\" style=\"background-color: " . $bg_kleur . "\">";
if ( $tld['transfer'] > "0" ) {
printf ('$ %01.2f', $tld['transfer']);
} else { echo " "; }
echo "</td>";
// Increment counter to determine row background color
$i++;
} while ($tld = mysql_fetch_assoc($result));

mysql_free_result($result);
mysql_close($link);

?>


</table>

 

Works now for me, and is in dollars...

 

So now we have two codes here if anyone wants and independent domain price chart. hehe

 

Good work everyone!

Link to comment
Share on other sites

and if you add ...

// show_all = 0 for first period only, 1 for all periods
$show_all = 1;
$previous_tld = "";

before the do loop

 

and

       if ( $tld[extension] != $previous_tld || $show_all == 1 )
       {

immediately after if ( $tld['extension'] )

 

and

               if ( $tld['registrationperiod'] > 1)
               {
                       echo "s";
               }

after the echo of "year"

 

and finally

}
$previous_tld = $tld[extension];

before the } while

 

then you can optionally show only the first price (makes the table much smaller) and correctly puralise years as appropriate :)

Link to comment
Share on other sites

Hi Othello,

 

thanks for the additional code. I liked it but ran into some problems with the output of the TLD extension so I modified the code a bit:

 

The new code to output the extension of the TLD is now:

//
// print the TLD
//
         if ( $tld['extension'] ) {
            echo "<tr>";
            echo "<td style=\"background-color: " . $bg_kleur . "\">";
            if ( $tld[extension] != $previous_tld || $show_all == 1 ) {
              echo $tld[extension];
            } else {
               echo " ";
            }
            echo "</td>";

//
// print registration period of the tld
//

Link to comment
Share on other sites

Updated with the above changes:

 

<?php

// Background color 1 and 2
$kleur1 = "#eeeeee";
$kleur2 = "#cccccc"; 

// counter to help determine which background color to use
$i = 1; 
require "/PATHTOYOURWHMCSINSTALL/configuration.php";
$link = mysql_connect($db_host, $db_username ,$db_password) or die("Unable to connect to database: " . mysql_error());
@mysql_select_db($db_name) or die( "Unable to select database");
// Formulate Domeinnaam tarieven Query
$query = sprintf("SELECT * FROM `tbldomainpricing` ORDER by `order` ASC",
mysql_real_escape_string($extension),
mysql_real_escape_string($registrationperiod),
mysql_real_escape_string($register),
mysql_real_escape_string($transfer),
mysql_real_escape_string($renew)
);

// Perform Query
$result = mysql_query($query);

// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
//mysql_free_result($result);
//mysql_close($link);

//while ($tld = mysql_fetch_assoc($result)) {

// Attempting to print $result won't allow access to information in the resource
// One of the mysql result functions must be used
// See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc.
// show_all = 0 for first period only, 1 for all periods
$show_all = 0;
$previous_tld = "";

do {
// Set the row background color
$bg_kleur = ( $i % 2 == 0 ) ? $kleur1 : $kleur2;
//
// print TLD
//
if ( $tld['extension'] ) 
       if ( $tld[extension] != $previous_tld || $show_all == 1 )
       {
{
echo "<tr>";
echo "<td align=\"center\" style=\"background-color: " . $bg_kleur . "\">";
echo $tld[extension];
echo "</td>";
}
//
// print registration period per tld
//
echo "<td align=\"center\" style=\"background-color: " . $bg_kleur . "\">";
if ( $tld['registrationperiod'] ) {
echo $tld['registrationperiod']." Year";
               if ( $tld['registrationperiod'] > 1)
               {
                       echo "s";
               }
} else { echo " "; }
echo "</td>";
//
// print TLD New registration price
//
echo "<td align=\"center\" style=\"background-color: " . $bg_kleur . "\">";
if ( $tld['register'] ) {
printf ('£%01.2f', $tld['register']);
} else { echo " "; }
echo "</td>";
//
// print TLD renewal price
//
echo "<td align=\"center\" style=\"background-color: " . $bg_kleur . "\">";
if ( $tld['renew']) {
printf ('£%01.2f', $tld['renew']);
} else { echo " "; }
echo "</td>";
//
// print TLD Transfer price
//
echo "<td align=\"center\" style=\"background-color: " . $bg_kleur . "\">";
if ( $tld['transfer'] > "0" ) {
printf ('£%01.2f', $tld['transfer']);
} else { echo " "; }
echo "</td>";
// Increment counter to determine row background color
$i++;
}
$previous_tld = $tld[extension];
} while ($tld = mysql_fetch_assoc($result));

mysql_free_result($result);
mysql_close($link);

?>

Link to comment
Share on other sites

W3C Markup Validation Service (Failed validation),

Example errors:

--------------------------------------------------------------------

Line 119, Column 342: document type does not allow element "tr" here.

Line 119, Column 681: document type does not allow element "tr" here.

Line 119, Column 1021: document type does not allow element "tr" here.

--------------------------------------------------------------------

Solution?

 

Thanks

Link to comment
Share on other sites

  • 11 months later...

This seems to no longer work with Version 4. Anyone have an idea what table the domain prices are now actually stored? tbldomainpricing only has the following fields now:

 

  1. id
  2. extension
  3. dnsmanagement
  4. emailforwarding
  5. idprotection
  6. eppcode
  7. autoreg
  8. order

 

The fields "registration period", "register", "transfer", and "renew" don't seem to be in that table anymore...

Link to comment
Share on other sites

Ok I found the table. It appears pricing has been completely restructured. Each domain has 3 entries in the tblpricing table, each with types "domainregister", "domaintransfer", and "domainrenew". The actual prices for each category are now spread over (up to) 10 columns, with fields "msetupfee", "qsetupfee", "ssetupfee", "asetupfee", "bsetupfee", "monthly", "quarterly", "semiannually", "annually", and "biennially" (each representing years 1 through 10, respectively). 0.00 occupies corresponding fields out of range for the particular domain (such as domains that can only be registered for one year).

 

One field (column) is called "relid", which seems to correspond to the "id" field in the tbldomainpricing table.

 

So it seems like a complicated query is now in order, but I suspect someone out there can come up with the appropriate query string!

Link to comment
Share on other sites

la_rollin you're on a roll! That's pertty much what I figured out but I am not good enough to figure out the coding for it, anyone willing to give it a shot? I am trying to output the domain prices from the whmcs database on my home page, is this possible?

Link to comment
Share on other sites

  • 2 weeks later...
  • 6 months later...

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated