Squidge 101 Newbie Poster

XAMPP site have anything to say about it?
Alas no.

I have done a lot of searching via google, but nothing has fixed the issue

Squidge 101 Newbie Poster

Hi all,

I am in need of assistance.
I am trying to configure PEAR with XAMPP 1.8.0 on Win 7 64Bit.

I download the go-pear.phar (http://pear.php.net/manual/en/installation.getting.php) and ran the instructions.
Updated my env path. All looked ok.

Tried to run pear help and i get nothing, no error, not a snip.

Uninstalled XAMPP, ran CCleaner, rebooted, removed and env path that was changed. Rebooted.

Reinstalled XAMPP, rebooted (see where this is going?), redownloaded go-pear.phar.

Reran it, rebooted, re ran pear help still nothing

I have tried this in different combinations, and cannot for the life of me see what i am doing wrong.

I have had PEAR configured and working before, i had to rebuild my OS so i lost it a while back.

Can anyone help out?

Squidge 101 Newbie Poster

have a look on scribe

Squidge 101 Newbie Poster

Marty i run Win 7, but opted for XAMPP over IIS, less confirguration for intial setup

Squidge 101 Newbie Poster

But it still isn't saving the question. Any ideas what I may be doing wrong. Any help would be appreciated.

Are you getting an error?

Have you dumped the POST data to make sure this is populated as you expect?

Have you tested your SQL strings?

Squidge 101 Newbie Poster

Are you getting an error?

Have you tried it without the mysql connection?

Squidge 101 Newbie Poster
 if($row['banned'] == '1') {
header( 'http://www.awsomechat.comuv.com/ban/userbanned.php' );
} elseif ($row['banned'] == '2'){
header( 'http://www.awsomechat.comuv.com/ban/userbanned.php' );
}

Should these not read

header('location : http://www.awsomechat.comuv.com/ban/userbanned.php' );

&& ( :) )

header('location : http://www.awsomechat.comuv.com/ban/userbanned.php' );
Squidge 101 Newbie Poster

It certainly is possible. You would put your host details instead of LOCALHOST.

Unless you are setting up a secure connection i would export your db from the host, and import it locally.

That way you remove any risk

Squidge 101 Newbie Poster

Ok, so i appricate this is solved, but i though i would follow up:

compact small autoload snippet:

spl_autoload_extensions(".php");
spl_autoload_register();

However this will only function if your namespace follows a directory structure. I came across this on DreaminCode as i was looking for a very simple __autoload

Here is both the files, with the folder they are in in the head:

load_headScript.php:

<?php
// root: -> /classLib/load/load_headScript.php :
spl_autoload_extensions(".php");
spl_autoload_register();

use classLib\database\database_Connection as DB; // import namespace for code reuse

class load_headScript
{

    public function headLoad()
    {

        $sql = "SELECT scriptCode FROM head_scripts WHERE active != '0'";
        $stmt = DB::get()->prepare($sql);
        $stmt->execute();
        $stmt->setFetchMode(PDO::FETCH_ASSOC);

        while($row = $stmt->fetch())
        {
            print "<script type='text/javascript'>";
            print $row['scriptCode'];
            print "</script>";
        }
    }

}
?>

database_Connection.php

<?php
// root -> /classLib/dataBase/database_Connection.php:

namespace classLib\database; // declare namespcae

class database_Connection {
/**
* @var PDO The database link.
*/

    protected static $dbLink;

    /**
    * Returns an open PDO object. This object will be shared
    * among all who call this method, so that you don't have
    * to be creating multiple connections to MySQL in the
    * same request.
    * @return PDO
    */

    public static function get()
    {
        if(self::$dbLink == null)
        {
            $dns = 'mysql:host=localhost;dbname=roundth4_rtb2';
            self::$dbLink = new \PDO($dns, 'root', '');
            self::$dbLink->exec("SET NAMES 'utf8'");
            self::$dbLink->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
        }
        return self::$dbLink;
    }

    /*
    * We don't want this class to be able to spawn objects.
    * By making these two methods private, we effectively
    * prevent that from happening.
    */

    private function __construct() {
        return false;
    }

    private function __clone() { …
Squidge 101 Newbie Poster

they have different precedence.

True. && is before and - || is before or

:)

Squidge 101 Newbie Poster

I thought session_start() had to be the first line before any output?

**Note:

To use cookie-based sessions, session_start() must be called before outputing anything to the browser. **

PHP.net

Squidge 101 Newbie Poster

i have started using Netbeans. Very nice and easy to use. Best of all its free!!

I have also used Dreamweaver CS5.5 and 6

Squidge 101 Newbie Poster

i would suggest sanitising the data before doing anything, be it before the class, or passing the data to a function with in the class

Squidge 101 Newbie Poster

@Atli

You have been a great help.

All though you say an __autoloader would be overkill, it would be handy to know how to use, so i think i will look into that one also.

Squidge 101 Newbie Poster

??Global namespace??

Squidge 101 Newbie Poster

@Atli
Thank you, still had that line commented out :)

Although i had to remove self::$dbLink->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); as this was throwing:

Fatal error: Class 'organization\projectname\database\PDO' not found in G:\xampp_server\htdocs\classDrv_rtb\class\scripts\dbconnection.php on line 31

Squidge 101 Newbie Poster

Tried the above and it kicks out this error

Fatal error: Class 'organization\projectname\database\Database' not found in G:\xampp_server\htdocs\classDrv_rtb\class\scripts\headScripts.php on line 17

This is the code of the script:

<?php
use organization\projectname\database\Database as DB;
#require("dbCon.php");

class headScript
{
    public function headLoad()
    {
        /*$cxn = new dbConnection;

        $cxn = $cxn->pdo();

        $stmt = $cxn->prepare("SELECT scriptCode FROM head_scripts WHERE active != '0'");*/

        $sql = "SELECT scriptCode FROM head_scripts WHERE active != '0'";

        $stmt = DB::get()->prepare($sql);

        $stmt->execute();
        $stmt->setFetchMode(PDO::FETCH_ASSOC);

        while($row = $stmt->fetch())
        {
            print "<script type='text/javascript'>";
            print $row['scriptCode'];
            print "</script>";
        }
    }
}
?>
Squidge 101 Newbie Poster

Thank you both for your suggestions. I will try this when i amhome and post back:-)

Squidge 101 Newbie Poster

Ok, following from my previous thread (now resolved) i want to convert and use namespace.

headScript.php:

<?php

class headScript
{
    public function connection()
    {
        try
        {
            $dbh = new PDO("mysql:host=localhost;dbname=roundth4_rtb2", 'root', ''); // Dev
            return $dbh;
        }
        catch(PDOException $e)
        {
            echo "Error :- " . $e->getMessage();
            die();
        }
    }

    public function headLoad()
    {
        $cxn = $this->connection()->prepare("SELECT scriptCode FROM head_scripts WHERE active != '0'");

        $cxn->execute();
        $cxn->setFetchMode(PDO::FETCH_ASSOC);

        while($row = $cxn->fetch())
        {
            print "<script>";
            print $row['scriptCode'];
            print "</script>";
        }
    }
}
?>

I'd like to remove the connection function and put this in its own file, then using namespace to pull this in. That way i have one file which can be called via namespace and i can use this function.

Am I thinking this is possible when it is not?

I have tried a few things but cant seem to get it to work.

Can anyone offer assistance?

Squidge 101 Newbie Poster

Every programmer should know the difference between Google and Forums... -__-

+10 :)

Squidge 101 Newbie Poster

If yoyu are starting, i would suggest not jumping feet first in to an "advanced website".

For tutorials, google is your friend:Click Here

Squidge 101 Newbie Poster

Have you tried to count the actual records that the query returns as I suggested in my next post? Or have you tried to test the query in phpmyadmin?

:) i had a darn typo in my table name!!! @broj1 thanks for your assistance.

Squidge 101 Newbie Poster

@broj1,

Sorry was a typo :(

It is as you have put where active != 0 in my script.

Just cant figure out why it is not showing the damn thing

Squidge 101 Newbie Poster

Many thanks Dani :-)

Squidge 101 Newbie Poster

seems to have taken affect :)

Squidge 101 Newbie Poster

Hi all,

Hoping you can assist. I am probably starring at the darn thing but i cannot see the wood through the trees :)

class headScript
{
    public function connection()
    {
        try
        {
            $dbh = new PDO("mysql:host=localhost;dbname=xxx", 'xxx', 'xxx'); // Dev         
            return $dbh;
        }
        catch(PDOException $e)
        {
            echo "Error :- " . $e->getMessage();
            die();
        }
    }   


    public function headLoad()
    {

        $cxn = $this->connection()->prepare("SELECT scriptCode FROM head_scrips WHERE active = '0'");

        $cxn->execute();
        $cxn->setFetchMode(PDO::FETCH_ASSOC);

        print "<script>";
        while($row = $cxn->fetch())
        {
            print $row['scriptCode'];
        }
        print "</script>";

    }


}

I have this basic class, it will get all active scripts from the database.

I am using this to relay hte data to the page head:

$scriptOut = new headScript;
print $scriptOut->headLoad();

I am getting the <script> tags rendered but no script

Can you assist?

Squidge 101 Newbie Poster

Hey Mods.

I have changed my avatar 2~3 days ago.

But my old one is still posting when i do things. Why?

Squidge 101 Newbie Poster

'$school_id'"),0, 'logs_id'));

Should this not be 1?

Squidge 101 Newbie Poster

This should help:

RewriteEngine On
RewriteRule ^([^/]*)$ /pages/fetchpage.php?id=$1 [L]

Squidge 101 Newbie Poster

@LastMitch
I am sooooooooooooooo dizzy :)

Squidge 101 Newbie Poster

Copy and paste your backed up schema in to :

[XAMPP_DIR]\mysql\data

Squidge 101 Newbie Poster

Did you backup your data folder before installing XAMPP, as you have stated you had MySQL installed previous before XAMPP.

http://www.daniweb.com/web-development/php/threads/431015/phptriad

Squidge 101 Newbie Poster

There lays your issue. Take a backup of your data folder.

Remove MySQL, and XAMPP (assuming you installed XAMPP). Reboot or use [CCLEANER], reinstall.

(CCleaner is ideal for not having to reboot after uninstalling stuff like this)

Squidge 101 Newbie Poster

You need to use your imagination.

You have clearly stated

actually it is a project work which is to be represented in college.

Squidge 101 Newbie Poster

glad i could help

If its solved, mark it so :)

Squidge 101 Newbie Poster

Trees
Cars
Computers past-> present
Screws

Squidge 101 Newbie Poster

Birds? where they are, what different types with images and search function, with migratory patterns

Squidge 101 Newbie Poster

Really?

Thats is your own thing

Squidge 101 Newbie Poster

i am totaly confused.

Which part are you confised about?

Squidge 101 Newbie Poster

i changed that to "false" and now when i try to login using "root" and "1234" i get the error

Change it back

Squidge 101 Newbie Poster

The ITW file type is primarily associated with 'Icetips Wizard Editor'. (partially encrypted ini file)

Looks like you need a HEXIDECIMAL viewer

Squidge 101 Newbie Poster

that's why im confuse why it is not running

The only thing i can think of is actually running the install on your webhost

Squidge 101 Newbie Poster

Did you have MySQL installed prior to installing this?

Squidge 101 Newbie Poster

I do not beleive you can use mysql_real_escape_string within a SQL statement.

This should be done via to the INSERT statement

Squidge 101 Newbie Poster
$stmt = $pdo->prepare("SELECT * FROM $tbl_name where id= :id AND cls= :cls ORDER BY id DESC");

This is a select statement not an insert. So you would not need the id= :id
$stmt = $pdo->prepare("SELECT * FROM $tbl_name where cls= :cls ORDER BY cls DESC");

$stmt->bindParam(':id', $_GET['id'], PDO::PARAM_INT);

This would need to be changed as you are using POST data

$stmt->bindParam(':cls', $_POST['cls']);

Squidge 101 Newbie Poster

how are you defining the :cls variable?

Is this from $_POST, $_GET data?

Else I do not understand how you expect to use it in your SQL stmt?

Squidge 101 Newbie Poster

Where is the :cls coming from? is this in the url also?

Squidge 101 Newbie Poster

Thanks for that squidge, I will take a look at that. Hopefully it won't take much.

No problem squeak24

Squidge 101 Newbie Poster

The :id is a placer. Using this is more secure, and allows you to clean the data. Because you are GETting data from the URL this could have been altered or used for SQL injection.

So we use a place holder.

You can use the same for name and cls, although this

$stmt->bindParam(':id', $_GET['id'], PDO::PARAM_INT);

is specific to getting the data from the URL

Squidge 101 Newbie Poster
<?php
// Using PDO

$tbl_name = "forum_question";

$pdo = new PDO('mysql:dbname=test;host=localhost', '', ''); // first '' is user, second '' is password
$stmt = $pdo->prepare("SELECT * FROM $tbl_name where id= :id ORDER BY id DESC");
$stmt->bindParam(':id', $_GET['id'], PDO::PARAM_INT);
$stmt->execute();
$stmt->setFetchMode(PDO::FETCH_ASSOC);

?>

Your above SQL using PDO, you would then step through the data or display it with something like:

while($row = $stmt->fetch())
{
    echo $row['TABLE_COLUMN_1'] . " " . $row['TABLE_COLUMN_2'];
}

'

$stmt->bindParam(':id', $_GET['id'], PDO::PARAM_INT);

This sanitises the int PDO::PARAM_INT.

This is order by the id

ORDER BY id

So to do the same using name and class you should be able to do this.