Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mysql_connect() does not work

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have Apache and MySQL running on this machine. I can create and view PHP pages correctly. I can also use MySQL with no problems. But when I tried to connect to MySQL by using the mysql_connect() function I recieved this error:

Parse error: parse error in /var/ on line 3

my code looks like this:

<?php
// Connecting, selecting a database
$link = mysql_connect(&quot;localhost&quot;,&quot;user&quot;,&quot;password&quot;) or die($php_errormsg|;
print &quot;connected successfully&quot;;
mysql_select_db(&quot;itcsrdb&quot;) or die(&quot;could not select database&quot;);

// Closing connection
mysql_close($link);
?>

the username and password are correct. I then went to look at my phpinfo.php page that I was told to create when I installed PHP on Apache and in the Configuration Command I found this '--without-mysql'. I then proceeded to go to the php.ini file and could not figure out where to set mysql to 'with' i saw that the mysql.so was commented out (;mysql.so). I uncommented it and still no dice. Can someone please help. Thank You
 
The parse error looks like it's coming from the end of your 'or die()' statement. Unless that's just at typo, you have a pipe-semicolon ending the line instead of a parenthesis-semicolon. ($php_errormsg|; vs ($php_errormsg);

You may be looking at recompiling PHP. If you have the source, use './configure --with-mysql' (and whatever other options...) before you do make; and make install;

Not sure on the recompile, as I've only done it once. When I installed PHP from an RPM, MySQL was enabled by default. Matt
matt@paperlove.org
If I can help, I will.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top