سؤال

I'm getting the following error while connecting to my SQL database:

function mysql_query($query) {
$dbhost = "localhost";
$dbuser = "p39438_***";
$dbpass = "password";
$dbname = "p31417_***";

$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname); }

Using mysql_query gives me this error:

Cannot redeclare mysql_query() in /home/p39438/domains/*/public_html/_/includes/functies.php on line 10

هل كانت مفيدة؟

المحلول

Try mysql_query() not just query(). Also, don't put POST variables directly into a SQL query. That's a very bad idea.

نصائح أخرى

You haven't actually EXECUTED your query:

$sql = "....";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($result);

The function is mysql_query not query. There's a theme with these mysql function names...

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top