Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-29-2012, 07:15 PM   PM User | #16
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,653
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Post the code you have in use.
Fou-Lu is offline   Reply With Quote
Old 09-29-2012, 07:24 PM   PM User | #17
Ctechinfo
New Coder

 
Join Date: Sep 2012
Posts: 88
Thanks: 3
Thanked 3 Times in 3 Posts
Ctechinfo is an unknown quantity at this point
PHP Code:
<?php

$bValues 
= array(
    
'Compaq' => &$modelscompaq,
    
'HP' => &$modelshp,
    
'Compaq/HP' => &$modelsboth,
);
// Referencing was used since I don't know if these exist, but now I don't need to bother with 
// an isset check.
?>
<?php

$aFiltered 
array_filter($bValuescreate_function ('$a''return !empty($a);'));
if (empty(
$aFiltered))
{
    print 
'<i>No Data Available</i>';
}
else
{
    foreach (
$bValues AS $name => $value)
    {
        
printf('<b>%s</b> - <i>%s</i><br />' PHP_EOLucwords($name), $value); 
    }
};
?>
Ctechinfo is offline   Reply With Quote
Old 09-29-2012, 07:38 PM   PM User | #18
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,653
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
This doesn't match the code I previously posted.
That foreach is iterating all records of $bValues. It should be iterating each record of $aFiltered.
Fou-Lu is offline   Reply With Quote
Old 09-29-2012, 07:48 PM   PM User | #19
Ctechinfo
New Coder

 
Join Date: Sep 2012
Posts: 88
Thanks: 3
Thanked 3 Times in 3 Posts
Ctechinfo is an unknown quantity at this point
Quote:
Originally Posted by Fou-Lu View Post
This doesn't match the code I previously posted.
That foreach is iterating all records of $bValues. It should be iterating each record of $aFiltered.


I need to do some serious file cleaning too much of the same stuff of various age and edits

Thanks
Ctechinfo is offline   Reply With Quote
Old 12-24-2012, 03:58 AM   PM User | #20
Ctechinfo
New Coder

 
Join Date: Sep 2012
Posts: 88
Thanks: 3
Thanked 3 Times in 3 Posts
Ctechinfo is an unknown quantity at this point
Another stage of the redevelopment of this site. I had an idea a while ago that I had inquired about on the phpBB forum, as this idea has to do with connecting to my forum to other pages...

I have pages on the site that have missing bits of information (or in some cases wrong info). I have a section in my forum that contains topics for each page, which are connected to the webpages with links (i.e. Page X has a "discuss this page" link) that points to the apprporiate topic/thread.

I know this will be coded completely wrong but it will get the idea across to build from...

PHP Code:
<?php
$variable_word 
"Random_Word"//
//Check if topic exists in database. If topic exists echo the t_id.
$sql "SELECT * FROM `phpbb_topics` WHERE `topic_title = `$variable_word && constant_word LIMIT 1";

echo 
'<a href="/forum/viewtopic.php?t_id=$row['t_id']">Discuss This Page</a>.';
?>
Ctechinfo is offline   Reply With Quote
Old 12-28-2012, 09:30 AM   PM User | #21
rajdeep01
New Coder

 
Join Date: Dec 2012
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
rajdeep01 can only hope to improve
When writing classes in PHP, you can save time and speed up your scripts by working with object properties directly, rather than writing naive setters and getters. In the following example, the dog class uses the setName() and getName() methods for accessing the name property.

class dog {
public $name = '';

public function setName($name) {
$this->name = $name;
}

public function getName() {
return $this->name;
}
}
rajdeep01 is offline   Reply With Quote
Old 12-28-2012, 01:42 PM   PM User | #22
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,653
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Quote:
Originally Posted by Ctechinfo View Post
Another stage of the redevelopment of this site. I had an idea a while ago that I had inquired about on the phpBB forum, as this idea has to do with connecting to my forum to other pages...

I have pages on the site that have missing bits of information (or in some cases wrong info). I have a section in my forum that contains topics for each page, which are connected to the webpages with links (i.e. Page X has a "discuss this page" link) that points to the apprporiate topic/thread.

I know this will be coded completely wrong but it will get the idea across to build from...

PHP Code:
<?php
$variable_word 
"Random_Word"//
//Check if topic exists in database. If topic exists echo the t_id.
$sql "SELECT * FROM `phpbb_topics` WHERE `topic_title = `$variable_word && constant_word LIMIT 1";

echo 
'<a href="/forum/viewtopic.php?t_id=$row['t_id']">Discuss This Page</a>.';
?>
That's not completely wrong. If you are hooking into another app's DB, so long as the structure is correct that what you want(ish) to do. The query itself is wrong, you want to use SELECT t_id, topic_title FROM phpbb_topics WHERE topic_title IN ('$variable_word', 'constant_word') LIMIT 1. If these are searching on partials, you can use the LIKE syntax instead of equality/IN syntax. MySQL's wildcard characters are % for many, and _ for a char (so typically only % is used). If you can try to avoid wildcarding the beginning of a match since you cannot index it if you do.

Quote:
Originally Posted by rajdeep01 View Post
When writing classes in PHP, you can save time and speed up your scripts by working with object properties directly, rather than writing naive setters and getters. In the following example, the dog class uses the setName() and getName() methods for accessing the name property.

class dog {
public $name = '';

public function setName($name) {
$this->name = $name;
}

public function getName() {
return $this->name;
}
}
Aside from being completely off-topic, this is also the worst piece of advice I've ever heard. PHP is datatype weak; you cannot control a variable at a datatype level. If you allow public access to a variable that is an object type, you must then use an instanceof check any time you want to operate with it. Always create modifiable properties as protected or lower scope.
Fou-Lu is offline   Reply With Quote
Old 12-28-2012, 02:53 PM   PM User | #23
Ctechinfo
New Coder

 
Join Date: Sep 2012
Posts: 88
Thanks: 3
Thanked 3 Times in 3 Posts
Ctechinfo is an unknown quantity at this point
Quote:
That's not completely wrong. If you are hooking into another app's DB, so long as the structure is correct that what you want(ish) to do. The query itself is wrong, you want to use SELECT t_id, topic_title FROM phpbb_topics WHERE topic_title IN ('$variable_word', 'constant_word') LIMIT 1. If these are searching on partials, you can use the LIKE syntax instead of equality/IN syntax. MySQL's wildcard characters are % for many, and _ for a char (so typically only % is used). If you can try to avoid wildcarding the beginning of a match since you cannot index it if you do.
Thanks for the advice. The way things are setup. The webpages are motherboard codenames. The discussion threads are titled "board_codename Motherboard" so the return on the webpage would be just the one topic hence the limit 1 bit.
Ctechinfo is offline   Reply With Quote
Old 02-15-2013, 08:17 AM   PM User | #24
Ctechinfo
New Coder

 
Join Date: Sep 2012
Posts: 88
Thanks: 3
Thanked 3 Times in 3 Posts
Ctechinfo is an unknown quantity at this point
Time to think seriously about database(s).. While I havent done too much with migrating to a fully database driven site I have setup a non-forum database for one section of the site. I have been pondering the idea of switching over from a files/folders (hard coded) setup to a database driven setup for a while but haven't taken the plunge yet, mainly due to the old saying "if it ain't broke, don't fix it", well for the most part the hard coding is working out but no I am having to move pages, and even though the site is getting no real human interaction, I would like to get to a final format that wont trip up google, etc...

for an example:
http://www.mysite.com/boards/manufacturer/codname.php
is the current format of the links to the motherboards.

due to miguided information or new information for currently "unknown" boards the pages are getting shuffled around.

What I was thinking of as a new method of pages is like similar to forums:
http://www.mysite.com/viewboard.php?b_id=n (where n would be the id number from the database) so that when a page move the link would remain the same.

idea in my head for the site database:
b_id = Auto Incremented
Image - (page has a thumnail that can be clicked for a larger view)
codename = Varchar(50) -> (haven't encoutered any that are that long but some do have dashes in them)
Real Name = Varchare(50) -> (haven't encoutered any that are that long but some do have dashes in them)
chipset - Ultimately it would be cool to have this setup as a sub-table that has (but part of that problem is some of the chipset series names cover 30 different chipsets):
Chipset Name (for instance Intel Bearlake Chipset)
North Bridge -
South Bridge -
Socket/Slot
Bus Speed - AMD uses MT/s, Intel uses mainly MHz/GHz (but IIRC there are some w/DMI that uses MT/s)
RAM - Number & Types of Slots/Sockets | RAM Speed | Maximum (most of the newer boards list x for 32-b and x for 64-bit, whereas older boards list just one maximum)
Audio - Type of audio (integrated HD audio, external only, etc) | brand of CODEC
[b]Video[b] - Type of video (like the audio there are diffent setups) [For some odd reason I have been listing with the video specs as an example PCI Express x16 Graphic Cards, but in reality if your techie enough to look for technical specs your gonna figure it out by the expansion slot list]
Expansion slots - A breakdown of the expansion slots on the board
[b]Part Number(s) - Various formats (some 5421-0679, D9999-8888, 666666-222)
Additional Images - For instance if a front panel pinout is availible, or a pic of the codename, etc. (would be super cool to have it expandable if more then one extra image was availbie), this is listed as text link to the image, but the description text changes based on what the type of image is.
Models Found in - a breakdown by sytem series/models
Compaq - Models
Compaq/HP - Models
HP - Models
Documentation - A breakdown of what is availible for manuals, maintenance guides, or parts info (Quick Reference Guides)
Retail Boad info -
This is an MSI/Microstar MS-7612 motherboard.
Retail Link Here
Retal Link2 Here (if availible)
biosver - effects the branding of the BIOS branding in the caution message. "The bios program has been altered to an HP specific version. It is not recommended to flash back to the original. If anyone does this successfully please notify us by <a href="">email</a>." Would be super cool to have is setup so that I could plug in Compaq, HP, or Compaq/HP and have the a/an accoringly instead of having to put in a Compaq, an HP, or an HP or Compaq.
Update - This is information that replaces the caution message if somebody has flashed the BIOS back to the retail version.
Notes - This is for extra information that has been found like if there is a known discrepency like if HP lists the board as being from x manufacturer but the information points to another, etc.
Forum/Discussion Link - Link to a thread in the forum to discuss the board (for filling in the blanks essentially).


Most all the current formating, etc has been previosly discussed in this thread.. No I am not asking for you to do this for me, just brainstorming and hoping for guidance as I have never tackled a project like this..
Ctechinfo is offline   Reply With Quote
Old 02-15-2013, 08:31 AM   PM User | #25
Ctechinfo
New Coder

 
Join Date: Sep 2012
Posts: 88
Thanks: 3
Thanked 3 Times in 3 Posts
Ctechinfo is an unknown quantity at this point
And in a corresponding idea/project. I am getting to the point I need to build a database for my own personal server that I will be able to collect information that I have found and have it searchable by vaious terms..

Like for instance, PCB: FAB I have seen several different boards that have this marking, but there are differenc configuratiions, part numbers, etc. And there are several boards that have been previously unverifyably listed as a particular retail board like on ebay, but the information dechipered from the picture leads to another model, etc.

Along the same premise as the above post this database would need to be much more detaied. so that I could collect tid bits such as common markings, etc. so that at some point I can piece together reliable information..

Having a interface page to use for search and enter data would be much nicer then looking though a phpMyAdmin interface..
Ctechinfo is offline   Reply With Quote
Old 03-04-2013, 06:54 AM   PM User | #26
Ctechinfo
New Coder

 
Join Date: Sep 2012
Posts: 88
Thanks: 3
Thanked 3 Times in 3 Posts
Ctechinfo is an unknown quantity at this point
Quote:
Originally Posted by Ctechinfo View Post
Another stage of the redevelopment of this site. I had an idea a while ago that I had inquired about on the phpBB forum, as this idea has to do with connecting to my forum to other pages...

I have pages on the site that have missing bits of information (or in some cases wrong info). I have a section in my forum that contains topics for each page, which are connected to the webpages with links (i.e. Page X has a "discuss this page" link) that points to the apprporiate topic/thread.

I know this will be coded completely wrong but it will get the idea across to build from...

PHP Code:
<?php
$variable_word 
"Random_Word"//
//Check if topic exists in database. If topic exists echo the t_id.
$sql "SELECT * FROM `phpbb_topics` WHERE `topic_title = `$variable_word && constant_word LIMIT 1";

echo 
'<a href="/forum/viewtopic.php?t_id=$row['t_id']">Discuss This Page</a>.';
?>
So I finally got around to trying this out, on my local machine/test server.
Quote:
Parse error: syntax error, unexpected 't_id' (T_STRING) in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\ctechinfoNEW\templates\board.tpl on line 232
PHP Code:
       <p align="left"><b> - </b>       <?php
//Check if topic exists in database. If topic exists echo the t_id.
SELECT t_idtopic_title FROM phpbb_topics WHERE topic_title IN ('$variable_word''Motherboard'LIMIT 1"; // This select line is line 232

echo '<a href="
/forum/viewtopic.php?t_id=$row['t_id']">Discuss This Page</a>.';
?>. </p>
The above codeblock is in the .tpl file and I put the $variable_word variable info in the sample board page that connects to the .tpl file in order to create the page.

I do not know if I am simply missing backticks (or whatever these (`) are called). or missing brackets. But I also need to extend the code with an else statement:

PHP Code:
else {
      echo 
"No Discussion topic added yet."

Or have an insert script to automatically add the topic information as a new thread.
At the top of the .tpl file I did add
PHP Code:
<?php
define
('IN_PHPBB'true);
define('ROOT_PATH'"/forum");

if (!
defined('IN_PHPBB') || !defined('ROOT_PATH')) {
    exit();
}

$phpEx "php";
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH ROOT_PATH '/';
include(
$phpbb_root_path 'common.' $phpEx);

$user->session_begin();
?>
as mentioned to do on the phpBB site.

Thanks
Ctechinfo is offline   Reply With Quote
Old 03-20-2013, 08:20 PM   PM User | #27
Ctechinfo
New Coder

 
Join Date: Sep 2012
Posts: 88
Thanks: 3
Thanked 3 Times in 3 Posts
Ctechinfo is an unknown quantity at this point
PHP Code:
<?php 
if (isset($manual)) { 
   echo 
'<a href='."$manual".'>Motherboard Manual</a>'
} elseif (isset(
$quickref)) { 
   echo 
'<a href='."$quickref".'>Quick Reference Guide</a>'
} elseif (isset(
$msgs)) {
    echo 
'<a href='."$msgs".'>Maintenance/Service Guide</a>';
} elseif (isset(
$quickspecs)) {
    echo 
'<a href='."$quickspecs".'>Quick Specs</a>';
} else {
    echo 
"No Documentation Availible";
}
if (isset(
$manual2)) {
    echo 
'<br /><a href='."$manual2".'>Motherboard Manual</a>';
}
?>
Trying to do more with less code is the premice. The dilema with this block of code. Some of the pages have more then one manual availible, or have a manual, AND a Quick Reference Guide or a Quickspec Sheet.

Trying to get the code to function as:
Link 1
Link 2

Without adding another 10 lines of code to get the desired result.

PHP Code:
<?php 

$cValues 
= array( 
    
$manual => 'Motherboard Manual'
    
$quickref => 'Quick Reference Guide'
    
$quickspecs => 'Quick Specs'
); 
// Referencing was used since I don't know if these exist, but now I don't need to bother with  
// an isset check. 
?> 
<?php 

$aFiltered 
array_filter($cValuescreate_function ('$a''return !empty($a);')); 
if (empty(
$aFiltered)) 

    print 
'<i>No Data Available</i>'

else 

    foreach (
$cValues AS $name => $value
    { 
        
printf('<a href="%s">%s</a><br />' PHP_EOLucwords($name), $value);  
    } 
};
?>
but its throwing an error: Notice: Undefined variable: manual in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\ctechinfoNEW\templates\board.tpl on line 174. But that $manual variable worked with the old code (and linked properly). Its also printing/outputting links for all three vaiables given..

Code:
<p align="left">
<b>Documentation:</b><br />
<br />
<b>Notice</b>:  Undefined variable: manual in <b>C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\ctechinfoNEW\templates\board.tpl</b> on line <b>174</b><br />
 
<a href="">Motherboard Manual</a><br />
<a href=""ftp://ftp.compaq.com/pub/supportinformation/papers/335683_rev002_us.pdf"">Quick Reference Guide</a><br />
<a href=""http://h18000.www1.hp.com/products/quickspecs/11632_na/11632_na.HTML"">Quick Specs</a><br />
 </p>
The idea here is if there is only one piece of documentation there is only one link, if there is more then the the code produces more..
Ctechinfo is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:20 AM.


Advertisement
Log in to turn off these ads.