php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36576 Mysql access denied
Submitted: 2006-03-01 18:33 UTC Modified: 2006-03-02 15:27 UTC
From: jndavs at netscape dot net Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 5.1.2 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jndavs at netscape dot net
New email:
PHP Version: OS:

 

 [2006-03-01 18:33 UTC] jndavs at netscape dot net
Description:
------------
Windows XP
PHP 5.1.2
Apache 2.0.55
Mysql 5.0.18

I wrote some code using mysquli() to connect to a Mysql database and list the contents of a table:

	$host = "localhost";
	$user = "root";
	$pass = "password";
	$db = "database";
   
	$mysqli = new mysqli($host, $user, $pass, $db);

	$query = "SELECT * FROM table";

This worked fine, outputting the expected table data.


I added some code to insert data into the table utilising a form:

	<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
	data: <input type="text" name="data"><br />
	<input type="submit" name="submit">
	</form>

	$query = "INSERT INTO table (data) VALUES ('$data')";
    
	$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());

This resulted in an error message when the submit button was clicked: "You don't have permission to access /< on this server."

So I stripped out the form code, hard coded the data to be inserted in the table and re executed the query:

	// Data to be inserted into database
	$data = "dummy";	
	
	$query = "INSERT INTO table ( data ) VALUES ('$data')";
    
	// execute query
	$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
    
and was rewarded with the following Mysql message: "Access denied for user 'ODBC'@'localhost' (using password: NO)"

Any idea what's causing this?


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-01 19:53 UTC] bjori@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Erhm. Are you mixing ext/mysql and ext/mysqli.. ..and OO and procedural?
If I understand you correctly you have one file where you connected to the mysql database just fine - then completly diffrent file which doesnt even try to connect?

No bug here..
 [2006-03-02 15:27 UTC] jndavs at netscape dot net
Please ignore my last email, I've discovered what was wrong -

the insert query should have read

$result = $mysqli->query($query) or die ("Error in query: $query. ".$mysqli->error);

Thanks for pointing me in the right direction
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Dec 07 04:00:01 2025 UTC