Jump to content

Lassie

Members
  • Posts

    390
  • Joined

  • Last visited

Everything posted by Lassie

  1. I get no error message and no output. The shortcode itself displays and thats it. If I access business-directory.php in a browser an error, undefined function get-option() is encountered.
  2. I am working on a wordpress project and one of the plugins I would like to use uses shortcode. I have not come across this before and I'm not sure if this is php or wordpress issue. The wordpress forum has to date not replied. Given that the shortcode is supposed to call the scripts I'm wondering if ther eis anothe rway to initiate the scripts. The plugin is business directory and the instal says to insert in the deisred location the following shortcode [bizdir_directory] The code is in a directory - business-directory The intial file is business-directory.php which needs a config file I have put the code for these below <?php /* Plugin Name: Business Directory Plugin URI: http://businessdirectory.squarecompass.com/ Description: The Business Directory plugin for Wordpress is an easy way to host a free directory page for your readers, affiliates, advertisers, community, club members, etc. Allow them to submit a simple advertisement listing for themselves on your blog. Version: 0.7.1 Beta Author: Square Compass Author URI: http://squarecompass.com */ require_once('config.php'); //Load Biz-Directory Config File /* * Add functions */ //Add Actions add_action('wp_head','bizdir_js_header'); //Add Listing Form Header Ajax Call add_action('admin_menu','bizdir_navigation'); //Add Directory Tab in the menu add_action('admin_print_scripts','bizdir_js_admin_header'); //Add Ajax to the admin side add_action('wp_ajax_bizdir_edit_listing','bizdir_edit_listing' ); add_action('wp_ajax_bizdir_update_listing','bizdir_update_listing' ); add_action('wp_ajax_bizdir_show_manager_home','bizdir_show_manager_home' ); add_action('wp_ajax_bizdir_change_listing_status','bizdir_change_listing_status' ); add_action('wp_ajax_bizdir_delete_listing','bizdir_delete_listing' ); //Add Short Code add_shortcode("bizdir_addform","bizdir_addform_shortcode"); //Add ShortCode for "Add Form" add_shortcode("bizdir_directory","bizdir_directory_shortcode"); //Add ShortCode for "Directory" //Register Hooks register_activation_hook(__FILE__,'bizdir_install'); //Do Actions do_action("activate_business-directory/business-directory.php"); /* * Insatllation Script */ function bizdir_install() { global $wpdb; global $bizdir_version; //The Listings table is where all the user imputed data is stored switch($bizdir_version) { //Determine the proper update/add script case "0.5 Beta": case "0.6 Beta": case "0.7 Beta": case "0.7.1 Beta": if($wpdb->get_var("show tables like '".BIZDIRDBTABLE."'") != BIZDIRDBTABLE) { $sql = "CREATE TABLE ".BIZDIRDBTABLE." ( listing_id int(11) NOT NULL AUTO_INCREMENT, date_created datetime NULL DEFAULT NULL, status tinyint(1) DEFAULT '0' NOT NULL, name varchar(100) NULL DEFAULT NULL, email varchar(100) NULL DEFAULT NULL, company_name varchar(100) NULL DEFAULT NULL, company_keywords varchar(100) NULL DEFAULT NULL, company_description text NULL DEFAULT NULL, company_url varchar(100) NULL DEFAULT NULL, company_email varchar(100) NULL DEFAULT NULL, company_phone varchar(100) NULL DEFAULT NULL, company_street1 varchar(100) NULL DEFAULT NULL, company_street2 varchar(100) NULL DEFAULT NULL, company_city varchar(100) NULL DEFAULT NULL, company_state varchar(100) NULL DEFAULT NULL, company_zip varchar(100) NULL DEFAULT NULL, company_country varchar(100) NULL DEFAULT NULL, PRIMARY KEY (listing_id) );" ; require_once(ABSPATH.'wp-admin/includes/upgrade.php'); dbDelta($sql); } break; } add_option("bizdir_version",$bizdir_version); } /* * Set Header for Ajax calls */ function bizdir_js_header() { wp_print_scripts(array('sack'));//Include Ajax SACK library // Define custom JavaScript function ?> <script type='text/javascript' src='<?=BIZDIRCALLBACK?>main.js'></script> <script> function bizdir_add_listing(name,email,cName,description,keywords,website,cEmail,phone) { //Add Form Ajax Call //Deactivate submit button and display processing message document.getElementById('bizdir_submit').disabled = true; var submit_message = document.getElementById('bizdir_submit_message'); submit_message.className = "bizdir_message"; submit_message.innerHTML = "Submitting Form, Please Wait..."; //Clear inputs with Auto Text var all_inputs = document.getElementsByTagName('input'); for(var i=0;i<all_inputs.length;i++) bizdir_clearAutofill(all_inputs[i].id,all_inputs[i].getAttribute('bizdir_autofill')); var all_textareas = document.getElementsByTagName('textarea'); for(var i=0;i<all_textareas.length;i++) bizdir_clearAutofill(all_textareas[i].id,all_textareas[i].getAttribute('bizdir_autofill')); //Build SACK Call var mysack = new sack("<?=BIZDIRCALLBACK?>requests.php"); mysack.execute = 1; mysack.method = 'POST'; mysack.setVar("action","AddListing"); mysack.setVar("name",document.getElementById("bizdir_name").value); mysack.setVar("email",document.getElementById("bizdir_email").value); mysack.setVar("cName",document.getElementById("bizdir_cName").value); mysack.setVar("description",document.getElementById("bizdir_description").value); mysack.setVar("keywords",document.getElementById("bizdir_keywords").value); mysack.setVar("website",document.getElementById("bizdir_website").value); mysack.setVar("cEmail",document.getElementById("bizdir_cEmail").value); mysack.setVar("phone",document.getElementById("bizdir_phone").value); mysack.setVar("street1",document.getElementById("bizdir_street1").value); mysack.setVar("street2",document.getElementById("bizdir_street2").value); mysack.setVar("city",document.getElementById("bizdir_city").value); mysack.setVar("state",document.getElementById("bizdir_state").value); mysack.setVar("zip",document.getElementById("bizdir_zip").value); mysack.setVar("country",document.getElementById("bizdir_country").value); mysack.onError = function() { alert('An ajax error occured while adding your listing. Please reload the page and try again.') }; mysack.runAJAX();//excecute return true; } function bizdir_search_listings() { //Search Ajax Call var search_term = document.getElementById('bizdir_search_term'); if(search_term.value == "" || search_term.value == null) return; //Deactivate submit button and display processing message document.getElementById('bizdir_search').disabled = true; var submit_message = document.getElementById('bizdir_messages'); submit_message.className = "bizdir_message"; submit_message.innerHTML = "Searching Listings, Please Wait..."; //Build SACK Call var mysack = new sack("<?=BIZDIRCALLBACK?>requests.php"); mysack.execute = 1; mysack.method = 'POST'; mysack.setVar("action","SearchListings"); mysack.setVar("searchTerms",search_term.value); mysack.onError = function() { alert('An ajax error occured while searching. Please reload the page and try again.') }; mysack.runAJAX();//excecute return true; } function bizdir_change_listings_page(offset) { //Jump to the appropriate page in the directory Ajax Call //Build SACK Call var mysack = new sack("<?=BIZDIRCALLBACK?>requests.php"); mysack.execute = 1; mysack.method = 'POST'; mysack.setVar("action","ChangePage"); mysack.setVar("offset",offset); mysack.onError = function() { alert('An ajax error occured. Please reload the page and try again.') }; mysack.runAJAX();//excecute return true; } </script> <? } /* * Navigation */ function bizdir_navigation() { add_menu_page( "Biz-Directory Manager", "Business Directory", 8, __FILE__, "bizdir_show_manager", "http://businessdirectory.squarecompass.com/wp-content/themes/thematic/images/mini_bd_icon.png" ); } /* * Add Form Script */ function bizdir_addform_shortcode($atts) { extract(shortcode_atts(array('width'=>'100%'),$atts)); return "<link rel='stylesheet' href='".BIZDIRCALLBACK."main.css' type='text/css' media='screen'/>". "<hr/>". bizdir_addform($width). "<a href='http://businessdirectory.squarecompass.com/' target='_blank' class='bizdir_notes_grey'>Powered by Business Directory for Wordpress</a>". "<hr/>"; } /* * Directory Script */ function bizdir_directory_shortcode($atts) { //get attributes extract(shortcode_atts(array('width'=>'100%','name'=>'Business Directory'),$atts)); //display Listings return "<link rel='stylesheet' href='".BIZDIRCALLBACK."main.css' type='text/css' media='screen'/>". "<form name='search' onSubmit='bizdir_search_listings(); return false;'>". "<b>Search the $name:</b> ". "<input type='text' id='bizdir_search_term'/>". "<input type='submit' id='bizdir_search' value='Search'/> ". "<div style='display:inline;' id='bizdir_messages'> </div>". "</form>". "<hr/>". "<div id='bizdir_directory' style='width:$width'>".bizdir_directory()."</div>". "<a href='http://businessdirectory.squarecompass.com/' target='_blank' class='bizdir_notes_grey'>Powered by Business Directory for Wordpress</a>". "<hr/>" ; } /* * Listing Manager */ function bizdir_show_manager() { echo " <link rel='stylesheet' href='".BIZDIRCALLBACK."main.css' type='text/css' media='screen'/> <div id='wpbody'> <div class='wrap'> <a href='http://businessdirectory.squarecompass.com/documentation/' target='_blank'>Business Directory Help/Documentation</a> <hr/> <div id='bizdir_messages'></div> <div id='bizdir_manager'>".bizdir_manager_home()."</div> <div> </div> <a href='http://businessdirectory.squarecompass.com/' target='_blank' class='bizdir_notes_grey'>Powered by Business Directory for Wordpress</a> </div> "; } //Display manager function bizdir_js_admin_header() { //Set Ajax Calls for manager wp_print_scripts(array('sack')); //use JavaScript SACK library for Ajax ?> <script type='text/javascript' src='<?=BIZDIRCALLBACK?>main.js'></script> <script type="text/javascript"> function bizdir_edit_listing(id) { clearMessage(); //Build SACK Call var mysack = new sack("<? bloginfo( 'wpurl' ); ?>/wp-admin/admin-ajax.php"); mysack.execute = 1; mysack.method = 'POST'; mysack.setVar("action","bizdir_edit_listing"); mysack.setVar("listing_id",id); mysack.onError = function() { alert('An ajax error occured while processing your request. Please reload the page and try again.') }; mysack.runAJAX();//excecute return true; } function bizdir_update_listing(status) { clearMessage(); //Disable buttons and display message document.getElementById('bizdir_save').disabled = true; var save_approve = document.getElementById('bizdir_save_approve') if(save_approve != null) save_approve.disabled = true; document.getElementById('bizdir_cancel').disabled = true; var submit_message = document.getElementById('bizdir_submit_message') submit_message.className = "bizdir_message"; submit_message.innerHTML = "Submitting..."; //Build SACK Call var mysack = new sack("<? bloginfo( 'wpurl' ); ?>/wp-admin/admin-ajax.php"); mysack.execute = 1; mysack.method = 'POST'; mysack.setVar("action","bizdir_update_listing"); if(status == "approve") mysack.setVar("status",1); mysack.setVar("listing_id",document.getElementById("bizdir_listing_id").value); mysack.setVar("name",document.getElementById("bizdir_name").value); mysack.setVar("email",document.getElementById("bizdir_email").value); mysack.setVar("cName",document.getElementById("bizdir_cName").value); mysack.setVar("description",document.getElementById("bizdir_description").value); mysack.setVar("keywords",document.getElementById("bizdir_keywords").value); mysack.setVar("website",document.getElementById("bizdir_website").value); mysack.setVar("cEmail",document.getElementById("bizdir_cEmail").value); mysack.setVar("phone",document.getElementById("bizdir_phone").value); mysack.setVar("street1",document.getElementById("bizdir_street1").value); mysack.setVar("street2",document.getElementById("bizdir_street2").value); mysack.setVar("city",document.getElementById("bizdir_city").value); mysack.setVar("state",document.getElementById("bizdir_state").value); mysack.setVar("zip",document.getElementById("bizdir_zip").value); mysack.setVar("country",document.getElementById("bizdir_country").value); mysack.onError = function() { alert('An ajax error occured while updating the listing. Please reload the page and try again.') }; mysack.runAJAX();//excecute return true; } function bizdir_show_manager_home() { clearMessage(); //Build SACK Call var mysack = new sack("<? bloginfo( 'wpurl' ); ?>/wp-admin/admin-ajax.php"); mysack.execute = 1; mysack.method = 'POST'; mysack.setVar("action","bizdir_show_manager_home"); mysack.onError = function() { alert('An ajax error occured while processing your request. Please reload the page and try again.') }; mysack.runAJAX();//excecute return true; } function bizdir_change_status(id,status) { clearMessage(); //Build SACK Call var mysack = new sack("<? bloginfo( 'wpurl' ); ?>/wp-admin/admin-ajax.php"); mysack.execute = 1; mysack.method = 'POST'; mysack.setVar("action","bizdir_change_listing_status"); mysack.setVar("listing_id",id); mysack.setVar("status",status); mysack.onError = function() { alert('An ajax error occured while processing your request. Please reload the page and try again.') }; mysack.runAJAX();//excecute return true; } function bizdir_delete_listing(id) { clearMessage(); if(confirm('Are you sure you want to delete this listing? This listing will be perminantly removed.')) { //Build SACK Call var mysack = new sack("<? bloginfo( 'wpurl' ); ?>/wp-admin/admin-ajax.php"); mysack.execute = 1; mysack.method = 'POST'; mysack.setVar("action","bizdir_delete_listing"); mysack.setVar("listing_id",id); mysack.onError = function() { alert('An ajax error occured while processing your request. Please reload the page and try again.') }; mysack.runAJAX();//excecute } return true; } </script> <? } The config file is [code] <? $bizdir_relative = "wp-content/plugins/business-directory/"; define('BIZDIRPATH',ABSPATH.$bizdir_relative); define('BIZDIRRELATIVEPATH',"/".$bizdir_relative); define('BIZDIRCALLBACK',get_option("siteurl").BIZDIRRELATIVEPATH); define('BIZDIRDBTABLE',$wpdb->prefix."biz_listings"); define('PERPAGE',30); //Variables $bizdir_version = "0.7.1 Beta"; //Require Scripts require_once('functions.php'); //Load Biz-Directory Functions Library File [/code]
  3. Ok thanks I will work on that.
  4. Thanks. I have tried restructuring the code but when I do my xml is not generated. The page is a custom wordpress page that has to use a template at the top of the script. If i dont include the the page cant be found it seems. I have also tried just echo out to the browser but again this fails. I know the buffer idea is lazy but i cant see anther way. Would you have any more pointers please.
  5. Ok. I can get some .doc to upload. I will refine the array. Thanks guys
  6. I have a page that I want to output xml rss data. I have used output buffering but still get header already sent error. I tried changing the logic so that page output was at the end but that esulted in no xml. Can anyone advise how to organise this code to avoid the problem. <?php ob_start(); /* Template Name: Feed */ ?> <?php get_header();?> <div id="leftnav"> <?php include (TEMPLATEPATH . '/sidebar1.php'); ?> <div id="right_pan"> </div> </div> <div id="rightnav"> <?php include (TEMPLATEPATH . '/sidebar2.php'); ?> </div> <div id="content"> <p> New Submissions Feed </p> <?php require_once '../Pos/RssFeed.php'; require_once '../Pos/MysqlImprovedConnection.php'; require_once '../Pos/MysqlImprovedResult.php'; try { $xml = new Pos_RssFeed('localhost', 'xxxx', 'xxxx', 'xxxx'); $xml->setFeedTitle('Authorbank New Submissions'); $xml->setFeedLink('http://www.example.com/oop_news.xml'); $xml->setFeedDescription('New Authors and New writing for Publishers.'); $xml->setLastBuildDate(true); // $xml->setFilePath('oop_news.xml'); $xml->setItemTitle('WorkingTitle'); $xml->setItemDescription('BriefDescription'); $xml->setItemPubDate('updated'); $xml->setTable('book'); $xml->setItemLinkURL('http://www.example.com/detail.php'); // $xml->setItemLink('url'); $result = $xml->generateXML(); if ($result) { ob_end_flush(); header('Content-Type: text/xml'); echo $result; } else { echo 'Error'; } } catch (Exception $e) { echo $e->getMessage(); } ?> </div> <?php get_footer();?>
  7. Thanks. Still no joy. print_r ($_FILES) showsthe following Array ( [image] => Array ( [name] => Kevin_Read_Me.doc [type] => application/vnd.ms-word [tmp_name] => C:\PROGRA~1\EASYPH~1\\tmp\php4D.tmp [error] => 0 => 19456 ) ) 50.0KB
  8. Thanks. I modfied the code as follows but still fails condition Any thoughts appreciated. // create an array of permitted MIME types $permitted = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png','application/msword/doc'); // check that file is of an permitted MIME type foreach ($permitted as $type) { if ($type == $_FILES['image']['type']||$type == $_FILES['application/msword']['type']) { $typeOK = true; break;
  9. I have a simple upload program designed to upload images that I want to be able to alos upload word docs. I have amended my permitted array to include doc type but the upload is refused. Should i be using something else in my permitted array? <?php /* Template Name: registration */ ?> <?php get_header();?> <div id="leftnav"> <?php include (TEMPLATEPATH . '/sidebar1.php'); ?> <div id="right_pan". </div> </div> <div id="rightnav"> </div> <div id="content"> <p>Upload Book details - Simple version</p> <?php get_currentuserinfo(); global $current_user; if (isset($current_user)){ echo $current_user->user_login; } // define a constant for the maximum upload size define ('MAX_FILE_SIZE', 51200 ); if (array_key_exists('upload', $_POST)) print_r($_FILES); { // define constant for upload folder define('UPLOAD_DIR', 'C:/upload_test/'); // replace any spaces in original filename with underscores // at the same time, assign to a simpler variable $file = str_replace(' ', '_', $_FILES['image']['name']); // convert the maximum size to KB $max = number_format(MAX_FILE_SIZE/1024, 1).'KB'; echo $max; // create an array of permitted MIME types $permitted = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png','image/doc'); // begin by assuming the file is unacceptable $sizeOK = false; $typeOK = false; // check that file is within the permitted size if ($_FILES['image']['size'] > 0 && $_FILES['image']['size'] <= MAX_FILE_SIZE) { $sizeOK = true; } // check that file is of an permitted MIME type foreach ($permitted as $type) { if ($type == $_FILES['image']['type']) { $typeOK = true; break; } } if ($sizeOK && $typeOK) { switch($_FILES['image']['error']) { case 0: //take user name or id from session variable //$username = $_SESSION['first_name']; // if the user's subfolder doesn't exist yet, create it if (!is_dir(UPLOAD_DIR.$current_user->user_login)) { mkdir(UPLOAD_DIR.$current_user->user_login); } // check if a file of the same name has been uploaded // check if a file of the same name has been uploaded. if it has timestamp duplicate if (!file_exists(UPLOAD_DIR.$current_user->user_login.'/'.$file)) { // move the file to the upload folder and rename it $success = move_uploaded_file($_FILES['image']['tmp_name'], UPLOAD_DIR.$current_user->user_login.'/'.$file); } //timestamp duplicate else{ $success = move_uploaded_file($_FILES['image']['tmp_name'], UPLOAD_DIR.$current_user->user_login.'/'.time().$file); } if ($success) { $result = "$file uploaded successfully"; } else { $result = "There was an error uploading $file. Please try again."; } break; case 3: $result = "There was an error uploading $file. Please try again."; default: $result = "System error uploading $file. Contact webmaster."; } } elseif ($_FILES['image']['error'] == 4) { $result = 'No file selected'; } else { $result = "$file cannot be uploaded. Maximum size: $max. Acceptable file types: gif, jpg, png, doc."; } } // if the form has been submitted, display result if (isset($result)) { echo "<p>$result</p>"; } ?> <h2>Upload Your Book File</h2> <div style="text-align: center"> <table width = \"390\" border = 0 align="left"> <tr><td> <form action="" method="post" enctype="multipart/form-data" name="uploadImage" id="uploadImage"> <fieldset> <legend>Upload Your Book Synopsis</legend> <p> <label for="image">Upload image:<em class="required">(only jpg,gif,png,doc.Max size 50kb)</em></label> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo MAX_FILE_SIZE; ?>" /> <input type="file" name="image" id="image" /> </p> <p> <input type="submit" name="upload" id="upload" value="Upload" /> </p></fieldset> </form> </td></tr></table> </div> <?php get_footer();?>
  10. I think its wrapped in another class because the code is part of a series of exercices building a script to access the db, otput an xml file and subsequently create an RSS feed. Being new to oop I follow what you say but how to test a row is returned?
  11. phpinfo() shows error_reporting=2039 display_errrors=on
  12. display_errors=on error_reporting=23*9 sorry this is form memory as I am not at my test machine right now.
  13. display errors == on and error_reporting = E_All & E_NOtice & E_Strict enabled in php.ini ?
  14. Have done , but no change ?
  15. Thanks error reporting is on but still blank screen. echo Hello world test shows classes loading. ?
  16. I am trying to learn oop and am using David Powers Php Object Orientated solutions. Unfortunately, I cant send this to him and need some pointers. I am trying to establish a database connection using classes. I have php5.1.1 and mysql 5.0.7 On connecting I get a blank screen and no error messages. Any ideas to solve this appreciated. test script <?php require_once '../Pos/MysqlImprovedConnection.php'; require_once '../Pos/MysqlImprovedResult.php'; try { $conn = new Pos_MysqlImprovedConnection('localhost', 'mike', 'j345', 'blog'); $result = $conn->getResultSet('SELECT * FROM blog'); foreach ($result as $row) { foreach ($row as $field => $value) { echo "$field: $value<br />"; } echo '<br />'; } } catch (RuntimeException $e) { echo 'This is a RuntimeException: ' . $e->getMessage(); } catch (Exception $e) { echo 'This is an ordinary Exception: ' . $e->getMessage(); } ?> classes ** * A wrapper class for connecting to MySQL with MySQL Improved * * Apart from the constructor and destructor, this has only one method: * getResultSet(), which returns a Pos_MysqlImprovedResult object. * * @package Pos * @author David Powers * @copyright David Powers 2008 * @version 1.0.0 */ class Pos_MysqlImprovedConnection { /** * MySQLi connection * * @var mysqli Database connection using MySQL Improved. */ protected $_connection; /** * Creates a database connection using MySQL Improved. * * @param string $host Database server name. * @param string $user Database user account. * @param string $pwd User account password. * @param string $db Name of database to connect to. */ public function __construct($host, $user, $pwd, $db) { $this->_connection = @new mysqli($host, $user, $pwd, $db); if (mysqli_connect_errno()) { throw new RuntimeException('Cannot access database: ' . mysqli_connect_error()); } } /** * Submits query to database and returns result as Pos_MysqlImprovedResult object. * * @param string $sql SQL query. * @return Pos_MysqlImprovedResult Result of query. */ public function getResultSet($sql) { $results = new Pos_MysqlImprovedResult($sql, $this->_connection); return $results; } /** * Closes the database connection when object is destroyed. * */ public function __destruct() { $this->_connection->close(); } } [code] <?php /** * A wrapper class for mysqli::query() to implement the Iterator and Countable interfaces. * * Submits a MySQLi query and makes the mysqli_result object iterable and countable. * * @package Pos * @author David Powers * @copyright David Powers 2008 * @version 1.0.1 */ class Pos_MysqlImprovedResult implements Iterator, Countable { /** * Stores value of current element. * * @var mixed */ protected $_current; /** * Stores current element key. * * @var int */ protected $_key; /** * Determines whether a current element exists. * * @var bool */ protected $_valid; /** * Stores the database result. * * @var mysqli_result */ protected $_result; /** * Uses a MySQLi connection to submit a query and stores the result in the $_result property. * * @param string $sql SQL query. * @param mysqli $connection MySQLi connection to database. */ public function __construct($sql, $connection) { if (!$this->_result = $connection->query($sql)) { throw new RuntimeException($connection->error . '. The actual query submitted was: ' . $sql); } } /** * Gets next row from database result and increments key. * */ public function next() { $this->_current = $this->_result->fetch_assoc(); $this->_valid = is_null($this->_current) ? false : true; $this->_key++; } /** * Returns value of current element. * * @return mixed */ public function current() { return $this->_current; } /** * Returns key of current element. * * @return int */ public function key() { return $this->_key; } /** * Determines whether there is current element. * * @return bool */ public function valid() { return $this->_valid; } /** * Moves to first row of database result. * */ public function rewind() { if (!is_null($this->_key)) { $this->_result->data_seek(0); } $this->_key = 0; $this->_current = $this->_result->fetch_assoc(); $this->_valid = is_null($this->_current) ? false : true; } /** * Returns number of rows in database result. * * @return int */ public function count() { return $this->_result->num_rows; } }
  17. Thanks. Must have a blind spot
  18. I have an error message an am unsure how to reslove the issue. The code i am using works fine on one local machine but not on my server (self hosted) Any pointers on where to look to fix this is very welcome. The error is Warning: require_once() [function.require-once]: URL file-access is disabled in the server configuration in W:\www\wordpress\wp-content\themes\custom1\author.php on line 64 Warning: require_once(http://localhost/wordpress/wp-content/themes/custom1/mysql_connect2.php) [function.require-once]: failed to open stream: no suitable wrapper could be found in W:\www\wordpress\wp-content\themes\custom1\author.php on line 64 Fatal error: require_once() [function.require]: Failed opening required 'http://localhost/wordpress/wp-content/themes/custom1/mysql_connect2.php' (include_path='.;/usr/local/PHP/includes;/usr/local/PHP/pear;/home/admin/www/plugins/pear/PEAR') in W:\www\wordpress\wp-content\themes\custom1\author.php on line 64
  19. I am trying to adapt wordpress 2.7 to my purposes,pricipally a cms rather than blog. I have created several pages with individual templates that work fine, however the last page i have created concerning an upload program, ignores a call to the wp footer function. I had a similar problem when creating another template which ignored all wp function calls and gave an error undefined function get_header(). I am wondering debug this. Any help appreciated although I realise its not a strict php question, the wp forum is not responding. the code for the page in question <?php /* Template Name: registration */ ?> <?php get_header();?> <div id="leftnav"> <?php include (TEMPLATEPATH . '/sidebar1.php'); ?> <div id="right_pan". </div> </div> <div id="rightnav"> </div> <div id="content"> <p>Simple Upload following registration</p> <?php get_currentuserinfo(); global $current_user; if (isset($current_user)){ echo $current_user->user_login; } // define a constant for the maximum upload size define ('MAX_FILE_SIZE', 51200); if (array_key_exists('upload', $_POST)) { // define constant for upload folder define('UPLOAD_DIR', 'C:/upload_test/'); // replace any spaces in original filename with underscores // at the same time, assign to a simpler variable $file = str_replace(' ', '_', $_FILES['image']['name']); // convert the maximum size to KB $max = number_format(MAX_FILE_SIZE/1024, 1).'KB'; // create an array of permitted MIME types $permitted = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png'); // begin by assuming the file is unacceptable $sizeOK = false; $typeOK = false; // check that file is within the permitted size if ($_FILES['image']['size'] > 0 && $_FILES['image']['size'] <= MAX_FILE_SIZE) { $sizeOK = true; } // check that file is of an permitted MIME type foreach ($permitted as $type) { if ($type == $_FILES['image']['type']) { $typeOK = true; break; } } if ($sizeOK && $typeOK) { switch($_FILES['image']['error']) { case 0: //take user name or id from session variable //$username = $_SESSION['first_name']; // if the user's subfolder doesn't exist yet, create it if (!is_dir(UPLOAD_DIR.$current_user->user_login)) { mkdir(UPLOAD_DIR.$current_user->user_login); } // check if a file of the same name has been uploaded // check if a file of the same name has been uploaded. if it has timestamp duplicate if (!file_exists(UPLOAD_DIR.$current_user->user_login.'/'.$file)) { // move the file to the upload folder and rename it $success = move_uploaded_file($_FILES['image']['tmp_name'], UPLOAD_DIR.$current_user->user_login.'/'.$file); } //timestamp duplicate else{ $success = move_uploaded_file($_FILES['image']['tmp_name'], UPLOAD_DIR.$current_user->user_login.'/'.time().$file); } if ($success) { $result = "$file uploaded successfully"; } else { $result = "There was an error uploading $file. Please try again."; } break; case 3: $result = "There was an error uploading $file. Please try again."; default: $result = "System error uploading $file. Contact webmaster."; } } elseif ($_FILES['image']['error'] == 4) { $result = 'No file selected'; } else { $result = "$file cannot be uploaded. Maximum size: $max. Acceptable file types: gif, jpg, png."; } } // if the form has been submitted, display result if (isset($result)) { echo "<p>$result</p>"; } ?> <h1>Upload Your Timeshare Photos</h1> <div style="text-align: center"> <table width = \"390\" border = 0 align="left"> <tr><td> <form action="" method="post" enctype="multipart/form-data" name="uploadImage" id="uploadImage"> <fieldset> <legend>Upload images for your timeshare</legend> <p> <label for="image">Upload image:<em class="required">(only jpg,gif,png.Max size 50Kb)</em></label> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo MAX_FILE_SIZE; ?>" /> <input type="file" name="image" id="image" /> </p> <p> <input type="submit" name="upload" id="upload" value="Upload" /> </p></fieldset> </form> </td></tr></table> <?php get_footer();?>
  20. At present the errors are title.inc fails to open the file ie no such file exits and in the header there is a parse error on line 12 trying to echo the $description this is a link to my test site http:217.46.159.226/ab_dev/
  21. Ok this is the header function i include title.inc at the top. title.inc determines the page title we are on and the opens the relevant meta data file. This is where i need help to build the path to open the file and read the variables so they can be put in the meta tags. Header function do_html_header() { include ('./includes/title.inc.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Authorbank<?php if (isset($title)) echo"&#8218;{$title}";?></title> <meta name="description"content=<?php echo{'$description'};?>/> <meta name="keywords"content=<?php echo{'$keywords'};?>/> <link href="/authorbank/includes/layout.css" media="screen" rel="stylesheet" type="text/css" /> <link href="/authorbank/includes/menu.css" media="screen" rel="stylesheet" type="text/css />" <?php } Title.inc.php <?php $title = basename($_SERVER['SCRIPT_NAME'], '.php'); $title = str_replace('_', ' ', $title); if ($title == 'index') { $title = 'home'; } $title = ucwords($title); //Build file path $path = './metadata/'; $path = $path.$title; //Read contents of file $data=fopen($path.$title,'r') or die('Cant open file'); $theData = fread($data,filesize($myFile)); fclose($data); ?> The meta data is in ./metadata/home.php for the first page. <?php $description="Authorbank Connecting Authors with Publishers"; $keywords="publishing, Finding a Publisher, Getting Published,writers, authors, submitting a book proposal"; ?>
  22. Right. see what u mean.However my include call is within the function so shouldnt that make the variables available in the function?
  23. I want to include variable mata data im my header by including the varaiablee from a page specific file. in the header i include a file to determine the page title and by passing this as a variable include the relevant page specific information. How do I write the include and echo the varaibles? The include include('./metadata/$title_metadata.php'); Header function <?php function do_html_header() { include ('./includes/title.inc.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Authorbank<?php if (isset($title)) echo"&#8218;{$title}";?></title> <meta name="description"content=<?php echo"{$description};?>/> <meta name="keywords"content=<?php echo"{$keywords}";?>/> <link href="/authorbank/includes/layout.css" media="screen" rel="stylesheet" type="text/css" /> <link href="/authorbank/includes/menu.css" media="screen" rel="stylesheet" type="text/css />" <?php } title.inc.php [code] <?php $title = basename($_SERVER['SCRIPT_NAME'], '.php'); $title = str_replace('_', ' ', $title); if ($title == 'index') { $title = 'home'; } $title = ucwords($title); include ('./metadata/$title_metadata.php') ?> meta data [code] <?php $description="Authorbank Connecting Authors with Publishers"; $keywords="publishing, Finding a Publisher, Getting Published,writers, authors, submitting a book proposal"; ?> [/code] [/code]
  24. Thanks. Spaces before doc type? Not clear what you mean here.Can you elaborate please?
×
×
  • 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.