I'm currently working on a script for uploading images as a blob in Mysql.
The script is working but when I connect my own class to go incl uden than does the script halfjes. I can only upload pictures but do not display correctly.
The reason that I connect a class that I have is always changing so I can not all files need to run.
Original connect part of the script:
php:
<?
<? php
$db_host = 'localhost' ; // don't forget to change
$db_user = 'mysql-user' ;
$db_pwd = 'mysql-password' ;
$database = 'test' ;
$table = 'ae_gallery' ;
// use the same name as SQL table
if (! mysql_connect ( $db_host , $db_user , $db_pwd ))
die( "Can't connect to database" );
if (! mysql_select_db ( $database ))
die( "Can't select database" );
?>
The way I have adapted:
php:
This works ... but not quite.<?
//Include Mysql class
include( '../classes/mysql_connect.class.php' );
//Connect to Mysql via class
$connection = new connect_db ();
$connection -> connect ();
$db_host = $connection -> host ; // don't forget to change
$db_user = $connection -> user ;
$db_pwd = $connection -> pwd ;
$database = $connection -> db ;
$table = 'imagegallery' ;
// use the same name as SQL table
$password = '123' ;
// simple upload restriction,
// to disallow uploading to everyone
if (! mysql_connect ( $db_host , $db_user , $db_pwd ))
die( "Can't connect to database" );
if (! mysql_select_db ( $database ))
die( "Can't select database" );
?>
My connect.class:
php:
I think this is a very strange problem because normally works.<?php
class connect_db
{
var $host = "localhost" ;
var $user = "user" ;
var $pwd = "pass" ;
var $db = "database" ;
function connect ()
{
$connection = mysql_connect ( $this -> host , $this -> user , $this -> pwd ) or die ( "Error: " . mysql_error (). " Nr.: " . mysql_errno ());
if( $connection )
{
$select_db = mysql_select_db ( $this -> db ) or die ( "Error: " . mysql_error (). " Nr.: " . mysql_errno ());
}
}
}
?>
Anyone can help?
thank you
Bookmarks