-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
LOL, the OP is using an array of letters and randomly selecting an index/letter. He's not trying to call a function and he's not trying to use variable functions.
-
Did you read the partitioning suggestion?
-
Did you look at the line in your code and try to determine why php thought you were attempting to call a function having a name of the contents of your variable, instead of php treating the variable as an array? Wouldn't that suggest that you need to use array syntax instead of function syntax? The syntax for referencing an array element uses []
-
Please help, need to add 2 more columns to this code
PFMaBiSmAd replied to php-newbies's topic in PHP Coding Help
Untested, but should work (you will need to set the $numCols variable) - {include file='t_javascript_language.tpl'} {set_css} {set_js} <!--<div class="componentheading">{$page_title}</div>--> <div class="adds_man_list"> <span>{$category_pathway}</span> {if $current_category->catname!=""} <div style="border:2px solid #000;"> {include file='elements/display_fields.tpl' position='categoryicon' this_add=$current_category->id} <strong>{$current_category->catname}</strong> <div class="adds_subcat" style="text-align:right;background:#F5F5F5; border:1px solid #FFFFFF; " > {include file='elements/display_fields.tpl' position='categorydetails' this_add=$current_category->id} <span style="font-size:12px;"> {jtext text="ADS_SUBCATEGORIES"}: {$current_category->kids} {jtext text="ADS_ADS"}: {$current_category->nr_ads} <a href="{$current_category->view}" title="{jtext text='ADS_VIEW_LISTINGS'}"> <img src="{$IMAGE_ROOT}view_listings.gif" class="ads_noborder" alt="{jtext text='ADS_VIEW_LISTINGS'}" /> </a> </span> </div> </div> {/if} {if $categories|@count<=0} <h2>{jtext text="ADS_NO_CATEGORIES_DEFINED"}</h2> {/if} <table id="adds_categories" class="ads_table"> <tr> {assign var="col" value="0"} {section name=category loop=$categories} {if $col == $numCols} </tr><tr>{assign var="col" value="0"} {/if} <td width="50%" class="adsman_catcell" valign="top"> <div class="adds_maincat" {if $categories[category]->watchListed_flag}class="cat_watchlist"{/if}> {include file='elements/display_fields.tpl' position='categoryicon' this_add=$categories[category]->id} <a href="{if $categories[category]->kids>0}{$categories[category]->link}{else}{$categories[category]->view}{/if}" > {$categories[category]->catname} </a> {if $categories[category]->is_new} <!--NEW!!--> <img src="{$IMAGE_ROOT}new.png" alt="new ads" /> {/if} <a href="{$categories[category]->view}" title="{jtext text='ADS_VIEW_LISTINGS'}"> <img src="{$IMAGE_ROOT}view_listings.gif" class="ads_noborder" alt="{jtext text='ADS_VIEW_LISTINGS'}" /> </a> {if $is_logged_in} {if $categories[category]->watchListed_flag} <img src="{$IMAGE_ROOT}watchlist.png" width="16"class="ads_noborder" /> {/if} <a href="{$categories[category]->link_watchlist}"> <img src="{$categories[category]->img_src_watchlist}" width="16" class="ads_noborder" title="{if $categories[category]->watchListed_flag}{jtext text='ADS_REMOVE_FROM_WATCHLIST'}{else}{jtext text='ADS_ADD_TO_WATCHLIST'}{/if}"/> </a> {/if} <br /> </div> <div class="adds_subcat" style="background:#F5F5F5; border:1px solid #FFFFFF; " > {include file='elements/display_fields.tpl' position='categorydetails' this_add=$categories[category]->id} <br /> {section name=subcategory loop=$categories[category]->subcategories} {include file='elements/display_fields.tpl' position='categoryicon' this_add=$categories[category]->subcategories[subcategory]->id} <a href="{if $categories[category]->subcategories[subcategory]->kids>0}{$categories[category]->subcategories[subcategory]->link}{else}{$categories[category]->subcategories[subcategory]->view}{/if}">{$categories[category]->subcategories[subcategory]->catname}</a> {if $categories[category]->subcategories[subcategory]->is_new==1} <img src="{$IMAGE_ROOT}new.png" alt="new ads" /> {/if} ({$categories[category]->subcategories[subcategory]->nr_a} {jtext text="ADS_ADS"}) {if $categories[category]->subcategories[subcategory]->watchListed_flag} <img src="{$IMAGE_ROOT}watchlist.png" width="16" class="ads_noborder" /> {/if} {if $is_logged_in} <a href="{$categories[category]->subcategories[subcategory]->link_watchlist}"> <img src="{$categories[category]->subcategories[subcategory]->img_src_watchlist}" width="14" class="ads_noborder" title="{if $categories[category]->subcategories[subcategory]->watchListed_flag}{jtext text='ADS_REMOVE_FROM_WATCHLIST'}{else}{jtext text='ADS_ADD_TO_WATCHLIST'}{/if}"/> </a> {/if} <br /> <p style="margin-left:25px;"> {include file='elements/display_fields.tpl' position='categorydetails' this_add=$categories[category]->id} </p> {/section} </div> </td> {assign var="col" value="`$col+1`"} {/section} {assign var="remainder" value="`$numCols-$col`"} {section name=emptyElement loop=$remainder} <td> </td> {/section} </tr> </table> </div> -
^^^ That will search the include_path first, then will look in the folder where the main requested file is (index.php), then in the current working directory. It will only check the inc folder if the include_path is not set. If you have more than one db.php file present and the first one found is not setting the $db variable, you can get the symptom you have reported. Edit: I would recommend echoing something unique in the 'correct' db.php file so that you know if it is the one that is actually being included.
-
The include_path would only matter if you were using a filename syntax in the include statement that would cause php to search the include_path (any thing that doesn't start with a ./ or ../ or is an absolute file system path or a URL) AND you have multiple different connection scripts that are found in the include_path setting that use a variable other than $db. Your question about if a URL would cause an error doesn't answer the guess that was ventured, are you or are you not using a URL in the include statements? Anyway, you wouldn't get an include error by using a URL if the file was in a public folder and the php settings needed to allow a URL to be used in an include statement are set to on.
-
You haven't shown your subset of code, either, so no one here can possibly help you with what it is you are still doing wrong in it. Best guess, you are using a URL in your include statements, so either the code making the database connection or the code referencing the $db variable have completely different program scopes.
-
Please help, need to add 2 more columns to this code
PFMaBiSmAd replied to php-newbies's topic in PHP Coding Help
See this link for several ways of producing a variable number of columns - http://smarty.incutio.com/?page=SmartyColumnsTutorial The Simpler Solution Using Smarty 2.6 Embedded Math example at the link is probably the best fit (it uses a separate counter to determine when to start/end a row. One theme that is in the examples in that link is to finish the last table row, which could be partial row if there is not exactly enough data (your existing code, as far as I looked at it, also suffers from not completing the last row if there is only one data item in it.) -
You cannot be serious. The error is occuring when sidebar.php is referencing the $db variable, which doesn't exist, when your code on line 3 in sidebar.php is calling the getMenuItems($db) function. Did you even read the first error message? The relevant code is everything from the start of your index.php file through to where you include sidebar.php and then through to at least line 3 in sidebar.php.
-
You would echo/concatenate/implode it (take your pick depending on what you are trying to accomplish.) Why do you want to echo an array like this? There is little practical use to it.
-
That's still not all the code needed to reproduce the problem. You are basically asking someone who is not standing right next to you to tell you what your code is doing without seeing your code. If your new PDO is failing, there would be a fatal runtime error and the remainder of the code wouldn't run. Therefore, either your new PDO statement is not being seen as php code or it is not being executed at all or it is and $db is defined at that point. If it is not defined later, then your code is doing something to it.
-
You still haven't posted the code we would need to see to be able to actually help you with what your code is doing that is server/configuration specific.
-
If an include path was wrong or an included file wasn't present, there would be at least two warning messages. Since notices and fatal errors are being reported, there's a good chance that warnings are enabled and would have been displayed.
-
Please help, need to add 2 more columns to this code
PFMaBiSmAd replied to php-newbies's topic in PHP Coding Help
The following two sections of code are what start a new row and end a row. Since they operate on odd/not-odd (even), you get two categories per row - {if $smarty.section.category.rownum is odd} <tr> {/if} {if $smarty.section.category.rownum is not odd} </tr> {/if} You would need to use the rownum and a modulus operator or a second counter to do a specific number of categories per row (since I don't know anything about smarty's syntax, that is all I can specifically help with.) -
When you post your code, show the opening php tags that are in the files, because that is yet another thing YOUR code could be doing that could allow it to work on one server configuration and not another.
-
Cannot really help you without seeing the code (less any database credentials) that reproduces the error to narrow down the problem from a half-dozen different possibilities to the one that is causing the problem in your code. Where is $db being defined? Where is it being used? Is there any code in between that is un-setting it? How are you including the files that is different between your development system and the live server? Do you have any header redirects that don't have exit; statements after them? Is your code altering the error_reporting/display_errors settings and is hiding information from where the problem first starts? Is output_buffering on or intentionally being used in the code and it is hiding php error messages?
-
You shouldn't have multiple dates (pieces of same meaning data) spread out in columns in each row. It makes any query more complicated. Your table should only have columns for the id, location, and date. You would have multiple rows for each location and a query to get just the rows with dates in the future would be simple.
-
Do you have a session_start() statement in your second piece of code?
-
Warning: mysql_select_db() expects parameter 2 to be resource
PFMaBiSmAd replied to ryanfilard's topic in PHP Coding Help
The code you have posted cannot produce the error you are getting. Either you have more than one default.php file at different paths and you are including/requiring the wrong one or your require_once() statement is actually using a URL and you altered the code for the post or you have some code somewhere that is un-setting the $default variable after the database connection was made or the code you posted is inside of a function definition and you didn't bother to post the actual code. -
Warning: mysql_select_db() expects parameter 2 to be resource
PFMaBiSmAd replied to ryanfilard's topic in PHP Coding Help
The variable $default doesn't exist. What is your code (less any database credentials) in ../Connections/default.php? -
You are looping over an array, starting with an index of zero. Your comparison in the loop condition should just be less-than (not less-than or equal) - for ($i=0; $i<$number; $i++)
-
PHP query always returns a result as interger
PFMaBiSmAd replied to vbcoach's topic in PHP Coding Help
A COUNT query will always return ONE FRICKEN ROW, unless the query failed due to an error of some kind. You must retrieve the row's data and access the count value in order to determine how many matching rows the query found. -
PHP query always returns a result as interger
PFMaBiSmAd replied to vbcoach's topic in PHP Coding Help
The sql statement that is defined in $strCaptainSearch is not shown in that code. If two different people tell you something is not in your post, you should probably believe them. -
PHP query always returns a result as interger
PFMaBiSmAd replied to vbcoach's topic in PHP Coding Help
I don't see any query statement.