I have problem connecting SQL with php. I don't even get an SQL error, just an ugly PHP error message:
"Warning: mysql_connect(): in C:\wamp\www\guildcreator\include\sql_conn.php on line 19 Call Stack Time Memory Function Location 1 0.0004 252040 {main}( )
..\sub.php:0 2 0.0009 255208 include( 'C:\wamp\www\guildcreator\include\sql_conn.php' ) ..\sub.php:5 3 0.0009 256344 mysql_connect ( )"
At first I thought that I wasn't creating a connection to the server. I tried various different combinations of the same address, with and without the port number. I don't understand why I am getting this error, because if mysql_connect fails I should be seeing the die() message.
I read something about the mysql_ functions being old and unsupported, maybe that's my problem? Any help would be great :-)
Here's the code that I am using:
$hostname = 'lolisrael.co.il:3306';
$sqluser = 'XXXXXX';
$sqlpass = 'XXXXXXXXX';
$link = mysql_connect($hostname, $sqluser, $sqlpass) or die("error zzzzz");
if ($link)
$db = mysql_select_db('_db', $link) or die("no db found");
the submite page for reference:
<?php
if(isset($_POST['free_text']))
{
echo "<p>".$_POST['free_text']."</p>";
include "include/sql_conn.php";
if(isset($db))
{
$free_text = mysql_real_escape_string($_POST['free_text']);
$sql = "INSERT
INTO
orhalimi_test_conn(free_text)
VALUES ('{$free_text}')";
if(mysql_query($sql))
echo "ITS WORK!!!";
}
}
?>
$link = mysql_connect($hostname, $sqluser, $sqlpass) or die("error zzzzz");if PDO is some extantion that need to be install on the server its not possable ..echo mysql_error()after that line and see if it says anything useful. It's probably not the cause of the problem but you shouldn't be usingmysql_functions anymore (they are no longer supported), you should be usingmysqli_functions orPDOinstead.php.inifile but rarely needed.