By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,028 Members | 1,784 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,028 IT Pros & Developers. It's quick & easy.

Notice: Undefined variable: db_host in C:\wamp\www\cbmall\index.php on line 7

P: n/a
Notice: Undefined variable: db_host in C:\wamp\www\cbmall\index.php on line 7

Notice: Undefined variable: db_user in C:\wamp\www\cbmall\index.php on line 7

Notice: Undefined variable: db_pass in C:\wamp\www\cbmall\index.php on line 7

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\wamp\www\cbmall\index.php on line 7
Error connecting to database server: Access denied for user 'ODBC'@'localhost' (using password: NO)



index.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // Setup some variables
  3. include_once( "admin/settings.inc.php" );
  4.  
  5.  
  6. // make the database connection
  7. $db            = mysql_connect( $db_host, $db_user, $db_pass ); # or die "Could not make connection to database server\n";
  8. if ( ! $db ) {
  9.     print "Error connecting to database server: ".mysql_error();
  10.     exit;
  11. }
  12. mysql_select_db($db_name);
  13.  
  14. // grab the template...
  15. $fh = fopen( 'templates/main.html', 'r' );
  16. $content = '';
  17. while( ! feof($fh) ) { 
  18.     $content .= fgets($fh);
  19. }
  20. fclose($fh);
  21. preg_match_all( "/\{Category: (.*?)\}/i", $content, $replacement_fields, PREG_SET_ORDER );
  22.  
  23. $content = str_replace( '{COUNT_ALL}', get_count_all(), $content );
  24. foreach ( $replacement_fields as $category ) { 
  25.     $repl_string = "{Category: $category[1]}";
  26.     $replacement = get_category_html($category[1]);
  27.     $content = str_replace( $repl_string, $replacement, $content );
  28. }
  29. print $content;
  30. exit;
  31.  
  32. function get_count_all() { 
  33.    global $db;
  34.    $sth = mysql_query("SELECT COUNT(*) as c FROM cb_urls");
  35.    $r = mysql_fetch_array($sth);
  36.    mysql_free_result($sth);
  37.    return $r['c'];
  38. }
  39.  
  40. function get_category_html( $category_name ) {
  41.     global $db;
  42.  
  43.    $count_all = 0;
  44.    $sql = mysql_query("SELECT COUNT(*) as c FROM cb_urls WHERE category LIKE '".addSlashes($category_name)."%'");
  45.    $r = mysql_fetch_array($sql);
  46.    mysql_free_result($sql);
  47.    $count_all = $r['c'];
  48.  
  49.     $sql = "SELECT DISTINCT(category) AS c FROM cb_urls WHERE category LIKE '".addSlashes($category_name)."%'";
  50.     $sth = mysql_query($sql,$db);
  51.     $ret_string = '                                          <P ALIGN=LEFT><B><FONT SIZE="-1" FACE="Verdana,Tahoma,Arial,Helvetica">'.$category_name.' ('.$count_all.')<BR></FONT></B>' . "\n";
  52.     while( $res = mysql_fetch_array($sth) ) { 
  53.       $sth2 = mysql_query("SELECT COUNT(*) as cnt FROM cb_urls WHERE category='".addSlashes($res[c])."'");
  54.       $r = mysql_fetch_array($sth2);
  55.       mysql_free_result($sth2);
  56.         $nameA = split("::",$res[c]);
  57.         $name = $nameA[1];
  58.         if ( $name ) { 
  59.             $ret_string .= '                                             <A HREF="search.php?keywords='.urlencode($res[c]).'" onMouseOver="window.status=\''.addSlashes($name).'\'; return true;" onMouseOut="window.status=\'\'; return true;"><FONT SIZE="-2" FACE="Verdana,Tahoma,Arial,Helvetica">'.$name.' ('.$r[cnt].')</FONT></A>'."\n";
  60.             $ret_string .= '                                             <FONT SIZE="-2" FACE="Verdana,Tahoma,Arial,Helvetica"></FONT>'."\n";
  61.         }
  62.     }
  63.    mysql_free_result($sth);
  64.     return $ret_string;
  65. }
  66. ?>
  67.  
settings.inc.php
Expand|Select|Wrap|Line Numbers
  1. <?
  2.  
  3. // Setup variables
  4.  
  5.  
  6. // Database
  7. $db_host = 'localhost'; // the host where your database server is running
  8. $db_name = 'cbmall'; // the name of the database
  9. $db_user = 'root'; // the username for connecting to the database
  10. $db_pass = '696969'; // the password for connecting to the database
  11.  
  12. // Clickbank ID
  13. $cb_user = 'Clickb'; // your clickbank affiliate id
  14.  
  15. // full url path to the script file - include trailing slash
  16. $path = 'http://localhost/cbmall/';
  17.  
  18. //  full url path to your XML file
  19. $xmlfeed = 'http://localhost/cbmall/xml/marketplace_feed_v1.xml';
  20.  
  21. // Admin password - change to whatever you want
  22. $adminpsd = '696969';
  23.  
  24.  
  25.  
  26. // PROBLEMS? Make sure ALL settings are 100% accurate.
  27.  
  28.  
  29. ?>
  30.  
Nov 23 '10 #1
Share this Question
Share on Google+
1 Reply


100+
P: 1,059
on settings.inc.php

use
<?php

?>


instead of
<?

?>


it will solve your problem
Nov 24 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.