What is replacement syntax for: "Deprecated: mysql_pconnect(): The mysql extension is deprecated"

Hi Experts,
I am new to php and mySQL.

I am using Dreamweaver CS6 with Apache/2.4.9 (Win64) PHP/5.5.12 and MySQL  5.6.17.
When I run the webpage I receive this error:
"Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\wamp\www\holland2\Connections\holland.php on line 9".

It seems mysql_pconnect() needs to be replaced with mysqli or PDO syntax after php 5.0.
The syntax needs to be replaced in 2-3 lines in index.php and holland.php.
Apparently my versions of php and mySQL are mismatched.

Both files are attached, as well as the screen with the error.
Can you please show me the full replacement lines of code?

Thanks so much,
Lbiederman
Lbiederman-php-error.zip
Larry BiedermanSoftware EngineerAsked:
Who is Participating?
 
Dave BaldwinFixer of ProblemsCommented:
Since I believe we're the top (by points) PHP experts here...  we'd recommend PHP.  And MySQL.  But the only thing you should use Dreamweaver for is the text and graphic display layout.  When you start programming in PHP, I suggest you close Dreamweaver and use a code editor like Notepad++ http://notepad-plus-plus.org/ , HTML-Kit http://www.chami.com/ , PSPad http://www.pspad.com/ , or any of a dozen other non-WYSIWYG programs.  Bluefish http://bluefish.openoffice.nl/index.html is available on all platforms.

I spend most days editing my main customer's site that he and his crew have 'designed' in Dreamweaver.  While they have good graphic and color sense, they are not good technically, not even with HTML.  In addition to doing the PHP programming, I also clean up their layout code because they do almost everything from 'design' view and never seen their technical problems.   I use HTML-Kit for programming and page layout and PSPad for a variety of odd tasks including creating new SQL inserts for their databases.  They rely extensively on me to take care of things and I have never owned a copy of Dreamweaver.  I did show one client how to use 'code' mode in his copy one day.
0
 
Dave BaldwinFixer of ProblemsCommented:
Yes, that is correct.  http://php.net/manual/en/function.mysql-pconnect.php  Except that it is not your program version but your code that is out of date.  And you can not simply replace the PHP code because the newer version, mysqli or PDO, requires a little different syntax and functions.
0
 
Dave BaldwinFixer of ProblemsCommented:
Every function that starts with 'mysql_' must be changed.  Fortunately, there are not really a lot of them in those files.  Also, 'get_magic_quotes_gpc' might fool you because since PHP 5.4, it always returns false because 'magic_quotes_gpc' were removed with PHP 5.4.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
Ray PaseurCommented:
It's a frequent question, hence this article that explains the situation and the way forward.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/PHP_Databases/A_11177-PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html

BTW, there is almost never a need for pconnect() functions in PHP scripts.  The environment is usually set up and taken down for each web page request.
0
 
Larry BiedermanSoftware EngineerAuthor Commented:
Thank you both for replying. However, I have read many such articles, but, being new to php, am still clueless as to what the EXACT..... syntax should be.

Here is the 'bad' code in holland.php.  Can you re-write it?

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_holland = "localhost";
$database_holland = "holland";
$username_holland = "root";
$password_holland = "";
$holland = mysql_pconnect($hostname_holland, $username_holland, $password_holland) or trigger_error(mysql_error(),E_USER_ERROR);
?>

Can you do same for index.php?

NOTE:  I didn't manually write code.  Ir was generated by Dreamweaver CS6 when I created a recordset.
Should I be using a different version of either MySQL or php so compatible code is auto generated?

Again, Thanks much!
-Larry
0
 
Dave BaldwinFixer of ProblemsCommented:
You probably need to use a different editor.  Your versions of PHP and MySQL are pretty current but Dreamweaver is not generating compatible code.  Most PHP programmers do not use Dreamweaver because the code it generates is not what they need.  Most used a colorized code / text editor.
0
 
Ray PaseurCommented:
what the EXACT..... syntax should be...
The exact syntax is given in the article.  Exact!  You can copy and install the code snippets from the article and run them on your own server.  Suggest you put aside pconnect() functions - we don't do that in PHP scripts that generate web pages.

Good text editors (Google 'em) include Textpad, Textmate, Textwrangler, Sublime, Notepad++.  Your best choice will depend on your workstation operating system and your work flow.  I agree with Dave - get rid of Dreamweaver.  It generates some of the most incomprehensibly bad PHP code I've ever seen.
0
 
Larry BiedermanSoftware EngineerAuthor Commented:
Dear Experts,
Sorry for delayed response, I have been ill past week.  Back at it now!

Ray, I will look at the syntax in article - thanks!

Ray & Dave,
I'm a very experienced VB6, and .net programmer (also Access, MsSQL, MySQL databases),
but obviously new at php and only basic web sites.

I need to write a web app involving databases. A moderate sized project over next 6 months.
What language and app would you suggest learning/using?

After this, will award all points.
Thanks much,
Larry
0
 
Larry BiedermanSoftware EngineerAuthor Commented:
Fellows,
I have downloaded notepad++.
Thanks for all the advice.  I am going through the lynda.com training now.
I have VS.net 2013 and the current Infragistics addon objects for ASP,
If php is that much better, will pursue it.

Ray, after reading your articles, I am still not able to replace the syntax.
Again, can you rewrite the small code block with new syntax, or is that too much work?

Still can't make this work.
Thanks much, Larry
0
 
Larry BiedermanSoftware EngineerAuthor Commented:
Still can't make it work.
Any help with converting my syntax?
-Thanks, Larry
0
 
Ray PaseurCommented:
"Converting syntax" is a professional job -- one that would be paid.  There are many of us here at E-E with "hire me" buttons in our profiles.  I'll sign off on this question now, but with a gentle recommendation that you might consider.  Learn about Laravel.  It's really head-and-shoulders above working with the native PHP language, and once you understand the framework, you will never go back.  It will take a month or so to get deep enough into Laravel to appreciate its amazing power.  Trust me -- it will be a month well-invested!
0
 
Larry BiedermanSoftware EngineerAuthor Commented:
OK thanks for lots of good advise.  I'll look elsewhere for the solution to the actual question.

-Larry
0
 
Larry BiedermanSoftware EngineerAuthor Commented:
Hi Moderator - Please change the points to 200 for Ray and 300 for Dave, and grade to B.
Although I did NOT get an answer to the question, I did receive much great info.

-Larry
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.