Squidge 101 Newbie Poster

Still couldnt get it to work with the __construct

So i have changed to this:

public function nav($table, $live, $loc) {
        /**
         * nav returns multiple records from the specified table with conditions
         * @param string $table Table name
         * @param array $live Set in DB condition to show page 1 = Live, 0 = Not Live
         * @return array $loc Set in DB shows location of page in Nav 1 = Top, 0 = Side
         */
        $tableConfig = array(
                'content' => array(
                'id' => PDO::PARAM_INT,
                'title' => PDO::PARAM_STR,
                'content' => PDO::PARAM_STR,
                'live' => PDO::PARAM_INT,
                'loc' => PDO::PARAM_INT,
                'keywords' => PDO::PARAM_STR,
                'metaDesc' => PDO::PARAM_STR
            )
        );


        $dsn = new crud('USER', 'PASSWORD', $tableConfig);
        $nav = $dsn->getRecords($table, array('live' => $live, 'loc' => $loc));
        $result = count($nav);
        $cnt = 0;
        $navKey = '<nav><ul>';
        while ($cnt < $result) {
            foreach ($nav[$cnt] AS $key => $value) {
                if (is_numeric($key)) {
                    unset($key, $value);
                } else {

                    if ($key != 'id' && $key != 'content' && $key != 'live' && $key != 'keywords' && $key != 'metaDesc') {
                        if ($key == 'title') {
                            $navKey .= '<li><a href="#">' . $value . '</a></li>';
                        }
                    }
                    unset($key, $value);
                }
            }
            $cnt++;
        }
        // Facebook include and G+1 code -> see main code page -> put into sep include files for ease of modification
        $navKey .= '</ul></nav>';
        unset($dsn);

        return $navKey;
    }

And this works. Think i will just have to work back to see where the annoying issue lays.

@Pritaeas -> many thanks for your assistance good sir.

Squidge 101 Newbie Poster

Pritaeas i really apprciate your assistance on this.

$tableConfig is from an included file containing a multi dimensional array:

$tableConfig = array(       
    'staff' => array(
        'id' => PDO::PARAM_INT,
        'drv_name' => PDO::PARAM_STR,
        'added' => PDO::PARAM_STR,
        'blurb' => PDO::PARAM_STR,
        'image' => PDO::PARAM_STR,
        'live' => PDO::PARAM_INT
    ),
    'content' => array(
        'id' => PDO::PARAM_INT,
        'title' => PDO::PARAM_STR,
        'content' => PDO::PARAM_STR,
        'live' => PDO::PARAM_INT,
        'loc' => PDO::PARAM_INT,
        'keywords' => PDO::PARAM_STR,
        'metaDesc' => PDO::PARAM_STR
    )
);

I have manually entered the $username & $passwd, but it still does not display

Squidge 101 Newbie Poster

I am getting an empty array:

Array()
Squidge 101 Newbie Poster

I think i am missing the point, i have tried this, but still nothing is output:

public function nav($table, $live, $loc) {
        /**
         * nav returns multiple records from the specified table with conditions
         * @param string $table Table name
         * @param array $live Set in DB condition to show page 1 = Live, 0 = Not Live
         * @return array $loc Set in DB shows location of page in Nav 1 = Top, 0 = Side
         */

        $nav = $this->dsn->getRecords($table, array('live' => $live, 'loc' => $loc));

        $result = count($nav);
        $cnt = 0;
        $navKey = '<nav><ul>';
        while ($cnt < $result) {
            foreach ($nav[$cnt] AS $key => $value) {
                if (is_numeric($key)) {
                    unset($key, $value);
                } else {

                    if ($key != 'id' && $key != 'content' && $key != 'live' && $key != 'keywords' && $key != 'metaDesc') {
                        if ($key == 'title') {
                            $navKey .= '<li><a href="#">' . $value . '</a></li>';
                        }
                    }
                    unset($key, $value);
                }
            }
            $cnt++;
        }
        // Facebook include and G+1 code -> see main code page -> put into sep include files for ease of modification
        $navKey .= '</ul></nav>';
        unset($dsn);

        return $navKey;
    }
Squidge 101 Newbie Poster

What was expecting is the following:

$top was meant to hold teh content of the class function nav, 'content' is the table name with 1,1 being the location and status if the page is live.

The function itself works well as a stand alone function, but i wanted to put it into a class so it can be reused.

Squidge 101 Newbie Poster

Pritaeaes,

I am not sure i understand your second comment?

The content is a table, but also column within the same name table. Not sure why, but this was how it was put together.

Squidge 101 Newbie Poster

@phorce,

This my declaration:

$navigationTop = new navigation('user_1', 'password_1', $tableConfig);

$top = $navigationTop->nav('content', 1, 1);
Squidge 101 Newbie Poster

Good afternoon all.

I have built the below class, and seem to have a problem where nothing is being displayed:

<?php

include_once '../include/tableStructure.php';
include 'crud.php'; //<- class by pritaeas

class navigation {

    public $dsn;

    public function __construct() {
        $this->dsn = new crud($username, $passwd, $tableConfig);
    }

    public function nav($table, $live, $loc) {
        /**
         * nav returns multiple records from the specified table with conditions
         * @param string $table Table name
         * @param array $live Set in DB condition to show page
         * @return array $loc Set in DB shows location of page in Nav
         */
        $nav = $this->dsn->getRecords($table, array('live' => $live, 'loc' => $loc));

        $result = count($nav);
        $cnt = 0;
        echo '<nav><ul>';
        while ($cnt < $result) {

            foreach ($nav[$cnt] AS $key => $value) {
                if (is_numeric($key)) {
                    unset($key, $value);
                } else {

                    if ($key != 'id' && $key != 'content' && $key != 'live' && $key != 'keywords' && $key != 'metaDesc') {
                        if ($key == 'title') {
                            echo '<li><a href="#">' . $value . '</a></li>';
                        }
                    }
                    unset($key, $value);
                }
            }
            $cnt++;
        }
        // Facebook include and G+1 code -> see main code page -> put into sep include files for ease of modification
        echo '</ul></nav>';
        unset($dsn);
    }

//    protected function sideNav($loc = 0, $live = 0) {
//        
//    }
}

The class uses the crud class by pritaeas. Any help is greatly appreciated.

Squidge 101 Newbie Poster

So it would appear to not be a PHP issue?

Squidge 101 Newbie Poster

Do you have any rewrite rules setup?

If not, i am not surprised, the page willl need to be called with the file extension

Squidge 101 Newbie Poster

Welcome to PHP.

Firstly get yourself an IDE, there are many threads on this forum dicussing the pros and cons of different ones. Have a play with them, and find one you are comfortable with.

Either go down the route of installing Apache & MySQL, or install XAMPP or WAMPP. Very straight forward to use. I am on a windows/linux dual boot system and opted for XAMPP (Apache Friends).

XAMPP under windows can be installed with Apache & MySQL as services, although the current model does have a glitch in it. So avoid this. All this means is you will manually have to start MySQL and Apache Server.

Find some easy tutorials to start with so you get a basic understanding. Avoid PHP & MySQL, as MySQL is depreciated. Either opt for MySQLi (good for both types of coding), or opt for PDO (OOP only).

Happy coding :):)

Squidge 101 Newbie Poster

Nor the full error

Squidge 101 Newbie Poster

For this you would need to use a javascript call.

http://www.w3schools.com/js/js_popup.asp

Squidge 101 Newbie Poster

Some hosts remove access to the php.ini file.
Try creating one in the root of your domain folder and using phpinfo() to see if this new file is picked up.

If it is not, contact you hosting company, or move hosts, or use ini_set(?) <- cant remember fully

Squidge 101 Newbie Poster

Have you tried sending a single email? where $to is a set email address (your own for example).

Have you dumpped your $_GET variable to make sure it is being populated?

Squidge 101 Newbie Poster

Start a new thread.

STOP BRINGING OLD THREADS BACK TO LIFE!!!!

Squidge 101 Newbie Poster

Where is the code for send.php or is that what gistfile1.txt is?

This part:

// get meessage to send
$message = $_GET['message'];

// loop through names / emails on index form
for ($x=0; $x<count($_GET); $x++)
{
if ($_GET["mail_$x"])
{
// mail setup
$to = $_GET["mail_$x"];
$subject = "News From Tap ";
$body = "Dear " . $_GET["name_$x"] . "
\n\n $message \n\n Josh \n\n Tap ";
mail($to, $subject, $body, $headers );
}
}

You seem to be using multiple $_GET, but you have one that has an additional space:

Line 16 from Index.php:

 echo "<input type = 'checkbox' name = 'mail_ ".$mailcount++." ' value 

This should be:

 echo "<input type = 'checkbox' name = 'mail_".$mailcount++." ' value 

Note the removal of the additional spacing between mail_ " as this will bugger your $_GET from your if ($_GET["mail_$x"]).

Also the same for this line in Index.php:

<input type = 'hidden' name='name_ ".$namecount++."' value = 

Additional spacing -> beware of those

Squidge 101 Newbie Poster

To be honest there are a lot of books out there, although there are also a lot of very helpful tutorials.

It sounds like a cop out but this goolge search:

https://www.google.co.uk/search?client=ubuntu&channel=fs&q=php+oop+for+beginners&ie=utf-8&oe=utf-8&gl=uk&redir_esc=&ei=g9aYUejdOImAOP-dgYAO

Has a lot they you may find very helpful and easy to follow.

As you are starting out, i would shy away from MySQL completely unless you decide to use a PDO wrapper.

If you do get stuck then by almeans drop a thread. The DaniWeb community is second to none when it comes to help and assistance.

Good luck, and happy coding.

Squidge 101 Newbie Poster

You need to change to either procedual and carry on using MySQL or change to PDO or MySQLi.

You cannot use OOP with MySQL, this has been covered on a few other threads previously.

Change the usage and you will be fine

Squidge 101 Newbie Poster

A sample of PDO/MySQL connection with exception catch

try {
    $conn = new PDO('mysql:host=HOST;dbname=DATABASE_NAME', $username, $password);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
    echo 'ERROR: ' . $e->getMessage();
}
Squidge 101 Newbie Poster

MySQL is not capable of OOP unless you use the PDO wrapper. So you will need to change either to using PDO with MySQL, or go to MySQLi OOP.

Is your DBConnector actually returning a live connection? WHat is the content of that Class?

Squidge 101 Newbie Poster

Can you confirm are you using ZF or ZF2?

Also there must be more to the error.

How have you set the error handling?

Squidge 101 Newbie Poster

Why are you using $arr, your variable is, as Diafol has pointed out -> $xml

Squidge 101 Newbie Poster

Would you mind posting how it was solved?

Would be helpful for when peopl search. Thanks.

Squidge 101 Newbie Poster

try '$current'

Squidge 101 Newbie Poster

This is a simple javascript (sorry diafol :))
http://www.htmlgoodies.com/beyond/javascript/article.php/3902606/How-To-Use-JavaScript-To-Auto-Submit-Dropdowns-With-No-Submit-Button.htm?myfield=Tea

That will auto submit the form.

Then you would cpature this choice and select and display the data relevent to the choice

Squidge 101 Newbie Poster

Or "Terminal" :)

Squidge 101 Newbie Poster

2 ways really

1 is java, that would be an onEvent()

or via a form, user selects the drop down, submits and shazam.

Squidge 101 Newbie Poster

This has been done time and time again.

Have you tried using the search function in the forum?

There are plenty of examples

Squidge 101 Newbie Poster

Please show your code.

I do not understand how you expect people to assist in "connecting the two" if you do not show the code to start with

Squidge 101 Newbie Poster

I think you variable for the values needs to be in single quotes

$parsedArray[20]

Should be:

'$parsedArray[20]'
Squidge 101 Newbie Poster

@AHarrisGsy,

So many thanks. Thought i had removed that :)

SOLVED

Squidge 101 Newbie Poster

Hi all,

I seem to have an issue with my CSS.

The page setup that has the issue is:

<footer>
<section 1></section 1>
<section 2></section 2>
<section 3></section 3>
</footer>

The sections are set to 33% width and floating left. The containing footer does not seem to expand in height:

What it looks like (very rough still)

http://deval.roundthebend.info/about_us.php

Squidge 101 Newbie Poster

Store the data in a database, and use $_GET[] to identify the URL page.

Connect to database and select and echo the $pageTitle

Squidge 101 Newbie Poster

@yy886,

This is part of an upload script i put together and using well:

$mime = array('image/gif', 'image/jpeg', 'image/jpg', 'image/png');
    if (in_array($_FILES['file']['type'], $mime) == FALSE) {
        echo "You are attempting to upload a \"{$_FILES['file']['type']}\" file type. <br/>
            This is not permitted.<br/>";
    } else {

$mime is an array that holds the accepted file types, the $_FILE[]['type'] is then checked to see if the uploaded mime type is allowed. If it is not, it is blocked.

Very similar to pixelsoul's example.

Have you got your mime types correct?

Have you checked your error log?

I would suggest adding a try{} and catch{}, as you may have an exception, or low value warning that is not showing up due to your settings

EDIT pipped by IIM :):)

Squidge 101 Newbie Poster

have you tried running it?

i think magic quotes is now removed from PHP ( think i read it somewhere):

just checked : http://php.net/manual/en/security.magicquotes.php removed since 5.4.

Squidge 101 Newbie Poster

Your question makes no sense.

Where did the code come from? Was it written by yourself

Squidge 101 Newbie Poster

many thanks

Squidge 101 Newbie Poster

@diafol,

Many thanks for getting back.

D'oH is all i have to say, was staring at it and couldnt see he wood for the trees :)

$x = new timing();
echo $x->now();

Now working thanks :)

Squidge 101 Newbie Poster

I have a very simple class for date display:

class timing {

    public $today;
    public $year;

    function __construct() {
        date_default_timezone_set('GMT');
    }

    function now() {
        return $this->today = date("D j M Y");
    }

    function year() {
        return $this->year = date("Y");
    }

}

I am pulling in using:

$x = new timing();
echo $x->today();

But i get nothing back. What am i missing :'(

Squidge 101 Newbie Poster

When uploading files you also need to declare a "enctype".

Also please show the full error, and the lines of code it will refer to

Squidge 101 Newbie Poster
Squidge 101 Newbie Poster

So what have you done so far?

Squidge 101 Newbie Poster

Storing images in DB is something that has been regularly discussed on DaniWeb.

Personally i would not store the actual image in the DB, only the location and file name.

This is a faster way to pull the images in.

Squidge 101 Newbie Poster

Many thanks pritaeas.

I have opted for the fetchAll, and used the following:

$staff = $dsn->getRecords('staff', array('live' => 0));

$result = count($staff); // ** Count the qty of first stage array
$x = 0;
while ($x < $result) {
    echo '<div class="post-container">';
    foreach ($staff[$x] AS $key => $value) { // ** Step into second stage array
        if (is_numeric($key)) {
            unset($key, $value);
        } else {

            if ($key != 'id' && $key != 'live' && $key != 'added') {
                if ($key == 'image') {
                    echo '<div class="post-thunb"><img src="photos/' . $value . '"/></div>';
                } else {
                    if ($key == 'drv_name') {
                        echo '<h1 class="post-title">' . $value . '</h1>';
                    } else {
                        echo '<div class="post-content">' . $value . '</div>';
                    }
                }
                unset($key, $value);
            }
        }
    }
    echo '</div>';
    $x++;
}
unset($dsn);

Works like a charm. So i have a massive thank you for your CRUD class :)

Squidge 101 Newbie Poster

you have a missing " from your img tag

echo ('<td><img src="photos/image'.$i.' "/></td>');
Squidge 101 Newbie Poster

Ok, for stepping through :

foreach ($memeber[0] AS $key => $value) {
    if (is_numeric($key)) {
        unset($key, $value); // if the key is numerical unset $key and related $value
    } else {
        echo $key, ': ' . $value . '<br>';
    }
}
Squidge 101 Newbie Poster
OH DO I FEEL SHEEPISH

Sorted, many thanks fo ryour input Dani:

print $arr[0]['email'];
Squidge 101 Newbie Poster

Dani,

Many thanks for that, it did start to help but its a multi :(

$tableConfig = array(
    'memeber' => array(
        'user_id' => PDO::PARAM_INT,
        'loginName' => PDO::PARAM_STR,
        'password' => PDO::PARAM_STR,
        'email' => PDO::PARAM_STR
        )    
);

My brain just wont kick in :(

Squidge 101 Newbie Poster

Hi All,

I am using pritaeas found here:
http://www.daniweb.com/web-development/php/code/430455/configurable-table-class

I am pulling in the data and my brain has taken a vacation.

I am using

$arr = $dsn->getRecord('memeber', array('user_id' => 2));

But cannot for the life of me pull the data out.

I get duplication as well from the data:

Array ( [0] => Array ( [user_id] => 2 [0] => 2 [loginName] => UserName [1] => UserName [password] => 30c2927b75d50c71550145ea7aebded6 [2] => 30c2927b75d50c71550145ea7aebded6 [email] => email@hotmail.co.uk [3] => email@hotmail.co.uk ) ) 

Can someone put me straight on this :)