SoBeIt Posted May 16, 2008 Share Posted May 16, 2008 Hi, Is it possible to include the domain pricing table outside of WHMCS and still have the extensions and pricing automatically update? 0 Quote Link to comment Share on other sites More sharing options...
dutchnet Posted May 16, 2008 Share Posted May 16, 2008 Sure it can be done just allow your site to connect to the mysql server your WHMCS is running on and with a small script you can then display the data form the databases from within WHMCS on your site. 0 Quote Link to comment Share on other sites More sharing options...
NoDoze Posted May 22, 2008 Share Posted May 22, 2008 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. 0 Quote Link to comment Share on other sites More sharing options...
dutchnet Posted May 22, 2008 Share Posted May 22, 2008 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> 0 Quote Link to comment Share on other sites More sharing options...
NoDoze Posted May 25, 2008 Share Posted May 25, 2008 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! 0 Quote Link to comment Share on other sites More sharing options...
NoDoze Posted May 25, 2008 Share Posted May 25, 2008 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.... 0 Quote Link to comment Share on other sites More sharing options...
NoDoze Posted May 25, 2008 Share Posted May 25, 2008 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! 0 Quote Link to comment Share on other sites More sharing options...
NoDoze Posted May 25, 2008 Share Posted May 25, 2008 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! 0 Quote Link to comment Share on other sites More sharing options...
dutchnet Posted May 25, 2008 Share Posted May 25, 2008 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' 0 Quote Link to comment Share on other sites More sharing options...
NoDoze Posted May 25, 2008 Share Posted May 25, 2008 Yup! I'm on php 5.X and mysql 5.X ...which is why I got the errors I think... 0 Quote Link to comment Share on other sites More sharing options...
dutchnet Posted May 25, 2008 Share Posted May 25, 2008 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 0 Quote Link to comment Share on other sites More sharing options...
NoDoze Posted May 26, 2008 Share Posted May 26, 2008 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 { 0 Quote Link to comment Share on other sites More sharing options...
NoDoze Posted May 26, 2008 Share Posted May 26, 2008 Oh...forgot....I need dollars, not euros... How would I change that? Thanks! 0 Quote Link to comment Share on other sites More sharing options...
NoDoze Posted May 26, 2008 Share Posted May 26, 2008 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! 0 Quote Link to comment Share on other sites More sharing options...
dutchnet Posted May 26, 2008 Share Posted May 26, 2008 Glad it worked out for you, again sorry for my stupid mix-up 0 Quote Link to comment Share on other sites More sharing options...
othellotech Posted May 27, 2008 Share Posted May 27, 2008 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 0 Quote Link to comment Share on other sites More sharing options...
dutchnet Posted May 27, 2008 Share Posted May 27, 2008 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 // 0 Quote Link to comment Share on other sites More sharing options...
mattpark Posted June 2, 2008 Share Posted June 2, 2008 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); ?> 0 Quote Link to comment Share on other sites More sharing options...
pol1967 Posted June 9, 2008 Share Posted June 9, 2008 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 0 Quote Link to comment Share on other sites More sharing options...
mcpacific Posted May 11, 2009 Share Posted May 11, 2009 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: id extension dnsmanagement emailforwarding idprotection eppcode autoreg order The fields "registration period", "register", "transfer", and "renew" don't seem to be in that table anymore... 0 Quote Link to comment Share on other sites More sharing options...
mcpacific Posted May 11, 2009 Share Posted May 11, 2009 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! 0 Quote Link to comment Share on other sites More sharing options...
Chinmi Posted May 17, 2009 Share Posted May 17, 2009 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? 0 Quote Link to comment Share on other sites More sharing options...
anderssk Posted May 28, 2009 Share Posted May 28, 2009 Just looking for that answer too 0 Quote Link to comment Share on other sites More sharing options...
NoDoze Posted December 15, 2009 Share Posted December 15, 2009 Can anyone help us here!?! 0 Quote Link to comment Share on other sites More sharing options...
NoDoze Posted December 16, 2009 Share Posted December 16, 2009 http://forum.whmcs.com/showthread.php?p=133604#post133604 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.