Hi everyone. Here is my problem. I am using a code-snipplet (after many failed attempts to make my own) and my problem is that the script says that there is no table in my db, but the table is there. Please tell my that im retarded and that i just missed something like that u cant use this on an mysql-server?
The errormessage that I get is "No such table db|1"
Here is the code:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <dbi>
public plugin_init()
{
//Create a connection
new Sql:mysql = dbi_connect("localhost", "root", "", "mysql")
//If the connection is less than 1, it is bad
if (mysql < SQL_OK) {
new err[255]
new errNum = dbi_error(mysql, err, 254)
server_print("error1: %s|%d", err, errNum)
return 1
}
server_print("Connection handle: %d", mysql)
//Do a select query
new Result:res = dbi_query(mysql, "SELECT * FROM db")
//If the query is greater than 0, you got a handle to the result set
if (res <= RESULT_NONE) {
new err[255]
new errNum = dbi_error(mysql, err, 254)
server_print("error3: %s|%d", err, errNum)
return 1
}
server_print("Result handle: %d", res)
//Loop through the result set
while (res && dbi_nextrow(res)>0) {
new qry[32]
//Get the column/field called "keyname" from the result set
dbi_result(res, "id", qry, 32)
server_print("result: %s", qry)
}
//Free the result set
dbi_free_result(res)
}
and my database looks like this
Code:
-- phpMyAdmin SQL Dump
-- version 2.6.1
-- http://www.phpmyadmin.net
--
-- Värd: localhost
-- Skapad: 03 juli 2007 kl 04:22
-- Serverversion: 4.1.9
-- PHP-version: 4.3.10
--
-- Databas: `mysql`
--
CREATE DATABASE `mysql` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE mysql;
-- --------------------------------------------------------
--
-- Struktur för tabell `db`
--
CREATE TABLE `db` (
`Host` char(60) character set latin1 collate latin1_bin NOT NULL default '',
`Db` char(64) character set latin1 collate latin1_bin NOT NULL default '',
`User` char(16) character set latin1 collate latin1_bin NOT NULL default '',
`Select_priv` enum('N','Y') NOT NULL default 'N',
`Insert_priv` enum('N','Y') NOT NULL default 'N',
`Update_priv` enum('N','Y') NOT NULL default 'N',
`Delete_priv` enum('N','Y') NOT NULL default 'N',
`Create_priv` enum('N','Y') NOT NULL default 'N',
`Drop_priv` enum('N','Y') NOT NULL default 'N',
`Grant_priv` enum('N','Y') NOT NULL default 'N',
`References_priv` enum('N','Y') NOT NULL default 'N',
`Index_priv` enum('N','Y') NOT NULL default 'N',
`Alter_priv` enum('N','Y') NOT NULL default 'N',
`Create_tmp_table_priv` enum('N','Y') NOT NULL default 'N',
`Lock_tables_priv` enum('N','Y') NOT NULL default 'N',
PRIMARY KEY (`Host`,`Db`,`User`),
KEY `User` (`User`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Database privileges';
-- --------------------------------------------------------