Is this a MySQL problem?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
MikeFuller
Forum Newbie
Posts: 5
Joined: Wed Jul 12, 2006 9:25 am

Is this a MySQL problem?

Post by MikeFuller »

Pimptastic | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello everyone! I have been developing a simple messageboard for the company I work at. However, there is a problem!!!! I enter the new users data and call up this script to enter it into the database:

Code: Select all

echo "Please wait, entering user ".$username." into our database <br>";
			//Connect to the server and select the correct database
			$linkID = @mysql_connect()
						or die(mysql_error());
			if($linkID){
			  echo "Connected to the database..";
			}
			
			@mysql_select_db("messages") or die("Could not connect to the database");
			//Insert the user data into the database if the user doesn't exist already
			$query = "INSERT INTO users SET username ='$username',password='$password'";

I am pretty sure the code is correct, but after I hit 'Submit', the page takes about a minute to load and it doesn't execute anything after the first line of the code, the echo statement. I am using Apache 1.3.35, PHP 4.4.2, and MySQL 4.1.20. I have both the Apache and PHP installed and configured correctly, and MySQL is supported automatically by PHP (or so I have heard). If anyone can help me with this, I'd appreciate it very much!!!


Thank you,

Mike


Pimptastic | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

First off, remove the @ symbols. This is usually always bad practice.

Run the scirpt again after doing this and see if you receieve any errors
MikeFuller
Forum Newbie
Posts: 5
Joined: Wed Jul 12, 2006 9:25 am

Post by MikeFuller »

I do get errors, and they are:

Code: Select all

Warning: mysql_connect(): Lost connection to MySQL server during query in c:\apache\apache\htdocs\new user.php on line 17

Fatal error: Maximum execution time of 30 seconds exceeded in c:\apache\apache\htdocs\new user.php on line 17
Line 17 is:

Code: Select all

$linkID = mysql_connect()
						or die(mysql_error());
Thanks for the tip about the @! And thanks for the hint about the

Code: Select all

and

Code: Select all

tags!

I have no clue as to why it looses the connection to the MySQL server.. Could it be because I haven't specified the host, username, and password in my connect statement?

Mike
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

MikeFuller wrote:Could it be because I haven't specified the host, username, and password in my connect statement?
COuld well be...try it and see what happens
MikeFuller
Forum Newbie
Posts: 5
Joined: Wed Jul 12, 2006 9:25 am

Post by MikeFuller »

No luck.. I tried putting in the connection information but it gives me the same error. Perhaps I made a mistake in setting MySQL up.. It IS supported automatically with my version of PHP/Apache, right? Or is there anything I have to do after setting it up to make it work?

Mike
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You haven't gotten any fatal error meassages about calls to undefined functions, so your PHP install is supporting mysql. Have you logged in to mysql using a db management utility (like phpMyAdmin)? Have you had a look at the user permissions for the user you are connecting to the DB with?
Post Reply