473,472 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

php mySql_connect() function

Claus Mygind
571 Contributor
I am brand new to php and trying to learn this on my own.
I have set up php v5.3.3.0.
I am using Apache 2.2.11.0 and mySQL 5.0

I have successfully run sending an email app which has a contact_form.html, php script, and response.html page. So I think the basic structure is working fine.

When I attempt to run this basic code (my script updatePhpTable.php).
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $user="myUserName";
  3. $password="myPassWord";
  4. $database="myDataBase";
  5. mysql_connect(localhost,$user,$password);
  6. @mysql_select_db($database) or die( "Unable to select database");
  7. mysql_close();
  8. ?>
I get the message.
Fatal error: Call to undefined function mysql_connect() in updatePhpTable.php on line 5

I am not sure why the mysql_connect() function is not working.

I have not set any of the following parameters in the php.ini file.

Expand|Select|Wrap|Line Numbers
  1. ; Default port number for mysql_connect().  If unset, mysql_connect() will use
  2. ; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
  3. ; compile-time value defined MYSQL_PORT (in that order).  Win32 will only look
  4. ; at MYSQL_PORT.
  5. ; http://php.net/mysql.default-port
  6. mysql.default_port =
  7.  
  8. ; Default socket name for local MySQL connects.  If empty, uses the built-in
  9. ; MySQL defaults.
  10. ; http://php.net/mysql.default-socket
  11. mysql.default_socket =
  12.  
  13. ; Default host for mysql_connect() (doesn't apply in safe mode).
  14. ; http://php.net/mysql.default-host
  15. mysql.default_host =
  16.  
  17. ; Default user for mysql_connect() (doesn't apply in safe mode).
  18. ; http://php.net/mysql.default-user
  19. mysql.default_user =
  20.  
  21. ; Default password for mysql_connect() (doesn't apply in safe mode).
  22. ; Note that this is generally a *bad* idea to store passwords in this file.
  23. ; *Any* user with PHP access can run 'echo get_cfg_var("mysql.default_password")
  24. ; and reveal this password!  And of course, any users with read access to this
  25. ; file will be able to reveal the password as well.
  26. ; http://php.net/mysql.default-password
  27. mysql.default_password =
  28.  
as I did not think they needed to be set.
Nov 29 '10 #1

✓ answered by Claus Mygind

Additional research in another forum gave the answer to my question.

http://www.phpfreaks.com/forums/faqc...mysql_connect/

4 2217
Claus Mygind
571 Contributor
Additional research in another forum gave the answer to my question.

http://www.phpfreaks.com/forums/faqc...mysql_connect/
Nov 29 '10 #2
Dormilich
8,658 Recognized Expert Moderator Expert
this should show you that the mysql_* functions are outdated nowadays (even the staff says so). better use PDO or MySQLi (it is not named mysql-improved for no reason).
Nov 30 '10 #3
Claus Mygind
571 Contributor
I am not familiar with PDO? I did see the MySQLi but until your description did not know it stood for "improved".

So I would assume MySQLi would include all deprecated functions in MySQL.dll. I ask this silly question because, I do not see much mention of MySQLi when I am trying to learn PHP. But per your comment I will move to MySQLi, since I am only in the setup phase. Thanks for the tip.
Dec 3 '10 #4
Dormilich
8,658 Recognized Expert Moderator Expert
I ask this silly question because, I do not see much mention of MySQLi when I am trying to learn PHP.
that’s because there are hardly tutorials about PDO and MySQLi. and because old tutorials don‘t get deleted.

if you want a personal recommendation, skip MySQLi and go for PDO. the result handling of PDO is way better than MySQLi’s. additionally, PDO uses Iterators (i.e. you can foreach a PDO result object to get your rows). not to mention MySQLi’s epic fail when it comes to handling of Prepared Statements.
Dec 3 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
5
by: phil_gg04 | last post by:
Dear Javascript Experts, Opera seems to have different ideas about the visibility of Javascript functions than other browsers. For example, if I have this code: if (1==2) { function...
2
by: laredotornado | last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to have my Javascript function execute from the BODY's "onload" method, but if there is already an onload method defined, I would...
2
by: sushil | last post by:
+1 #include<stdio.h> +2 #include <stdlib.h> +3 typedef struct +4 { +5 unsigned int PID; +6 unsigned int CID; +7 } T_ID; +8 +9 typedef unsigned int (*T_HANDLER)(void); +10
8
by: Olov Johansson | last post by:
I just found out that JavaScript 1.5 (I tested this with Firefox 1.0.7 and Konqueror 3.5) has support not only for standard function definitions, function expressions (lambdas) and Function...
3
by: Beta What | last post by:
Hello, I have a question about casting a function pointer. Say I want to make a generic module (say some ADT implementation) that requires a function pointer from the 'actual/other modules'...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
28
by: Larax | last post by:
Best explanation of my question will be an example, look below at this simple function: function SetEventHandler(element) { // some operations on element element.onclick = function(event) {
4
by: alex | last post by:
I am so confused with these three concept,who can explained it?thanks so much? e.g. var f= new Function("x", "y", "return x * y"); function f(x,y){ return x*y } var f=function(x,y){
7
by: VK | last post by:
I was getting this effect N times but each time I was in rush to just make it work, and later I coudn't recall anymore what was the original state I was working around. This time I nailed the...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.