5 Replies - 9516 Views - Last Post: 04 September 2008 - 06:48 PM Rate Topic: -----

#1 foxkj  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 14-August 08

Checking the php, mysqli connection

Post icon  Posted 15 August 2008 - 02:04 PM

So I wrote up a mysli connection - from php - and its not working. in fact, it does nothing. I had the username and password correct, but I changed it just to see if it would "die", but NOTHING happened.
The connection is straight out of a book, so I don't know what else to do with it if it doesn't connect.

Here's the code:

$connection = mysqli_connect("host", "catalogName", "Password") or 
 	die ("couldn't connect with Database");
mysqli_select_db($connection, "catalogName") or
	die ("couldn't select database");



In every example I've seen, this works. But it doesn't work for me.
I'm using Dreamweaver and my host does have the entire mysql, php thing put on it - the database is real and already created.

Is This A Good Question/Topic? 0
  • +

Replies To: Checking the php, mysqli connection

#2 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 4881
  • View blog
  • Posts: 11,272
  • Joined: 16-October 07

Re: Checking the php, mysqli connection

Posted 15 August 2008 - 03:27 PM

From http://us3.php.net/mysqli_connect:
mysqli_connect ($host, $username, $passwd, $dbname)

How do you connect to this using the mysql client?

This post has been edited by baavgai: 15 August 2008 - 03:27 PM

Was This Post Helpful? 0
  • +
  • -

#3 JBrace1990  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 106
  • View blog
  • Posts: 760
  • Joined: 09-March 08

Re: Checking the php, mysqli connection

Posted 15 August 2008 - 04:23 PM

have you added data after it? it's possible you are connected, but the page wouldn't display anything because there's nothing TO display...
Was This Post Helpful? 0
  • +
  • -

#4 foxkj  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 14-August 08

Re: Checking the php, mysqli connection

Posted 15 August 2008 - 06:58 PM

I was thinking about that too...
The problem is, when I change the password, etc. to the wrong one, nothing happens either - the "die" thing doesn't work.

I did add some code to the end that should also show something:

if ($connection) { 
   echo "Cant connect to MySQL Server."; 
} 



Nothing. I even called my hosting company and checked with them. They said nothing was wrong on their end. Am I missing something really small???


Thanks to all who are taking the time to read this and respond!
Was This Post Helpful? 0
  • +
  • -

#5 JoelMMCC  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 1
  • Joined: 04-September 08

Re: Checking the php, mysqli connection

Posted 04 September 2008 - 04:08 PM

View Postfoxkj, on 15 Aug, 2008 - 06:58 PM, said:

I was thinking about that too...
The problem is, when I change the password, etc. to the wrong one, nothing happens either - the "die" thing doesn't work.

I did add some code to the end that should also show something:

if ($connection) { 
   echo "Cant connect to MySQL Server."; 
} 



Nothing. I even called my hosting company and checked with them. They said nothing was wrong on their end. Am I missing something really small???


Thanks to all who are taking the time to read this and respond!


It almost sounds like PHP isn’t even active for the page! Try doing a simple “<?php echo 'Hello, World!'; ?>” by itself on the page.

If that fails, then PHP is either not enabled for that particular domain, or else you’re not saving the file in one of the approved PHP extensions (“*.php”, “*.php4”, “*.php5”, etc.). It won’t work if you save it as “*.htm” or “*.html”. The PHP will simply do nothing, or display as the raw tags.

Do note that Dreamweaver’s own PHP/MySQL Server Model and its Server behaviors do not use mysqli, but rather the older and woefully inferior mysql library. For this reason, I highly recommend not using them, especially with MySQL 5.x (or even 4.1 or greater, for that matter). Unlike mysqli, mysql doesn’t support the enhanced security model of 4.1 and greater, nor the Views and Stored Procedures and Prepared (parameterized) Queries (an important line of defense against SQL Injection attacks!) of MySQL 5+. This means that any Views in your Database will appear under “Tables” instead of “Views,” and any Stored Procedures simply won’t appear at all, in the DW Database tab nor in the Recordset builder.

This remains true even in the latest Adobe DW CS3. In general, Dreamweaver’s support for server technologies is woefully out-of-date — ASP.NET support is still at the ASP.NET 1.0/1.1 level, despite 2.0, 3.0, 3.5, and service packs for all three, have been released since then — and even the 1.0/1.1 support is lacking and majorly inefficient, such as opening a separate connection to the database for every Recordset or similar Server behavior (e.g. Insert Record, Update Record, and Delete Record) on the page!

Macromedia introduced server technologies in DW UltraDev (basically DW3 plus Server Models for ASP Classic, JSP, and Cold Fusion). Since then there have been DW4, Dreamweaver MX (which added ASP.NET and PHP/MySQL), DW MX2004, and DW8 from Macromedia (the latter also sold by Adobe after the merger), and Adobe DW CS3. In all that time, no major functionality improvements have occurred in any of the standard Server Models except for Cold Fusion (which, surprise surprise, was a Macromedia and now Adobe proprietary technology). Macromedia did move to plug an SQL Injection hole in ASP.NET in the DW 8.0.2 update.

PHP/MySQL definitely needs an overhaul to use mysqli. Maybe some third party will write one? Even before PHP/MySQL support was added in DWMX, in the days of DW4, a company named Interakt offered a Server Model called PHakt that added PHP support with much more powerful database support (using ADODB, and thus supporting many more databases than just MySQL, and even giving better MySQL support than the later, Macromedia-standard PHP/MySQL-specific Server Model)! Unfortunately, I believe that Interakt is no more.
Was This Post Helpful? 1

#6 JBrace1990  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 106
  • View blog
  • Posts: 760
  • Joined: 09-March 08

Re: Checking the php, mysqli connection

Posted 04 September 2008 - 06:48 PM

it would be if(!$connection){}
Was This Post Helpful? 1

Page 1 of 1