Visa ett inlägg
Oläst 2017-09-22, 19:49 #1
Bintang Bintang är inte uppkopplad
Medlem
 
Reg.datum: Dec 2015
Inlägg: 113
Bintang Bintang är inte uppkopplad
Medlem
 
Reg.datum: Dec 2015
Inlägg: 113
Standard MySql-problem på FS Data

Hej,
jag försöker koppla in en MySql-databas via Php, men möts av felmeddelandet:
Unable to select u810820_a: Access denied for user 'u8108201'@'%' to database 'u810820_a'

Men går jag in via PhpMyAdmin eller MySqlWorkbench med samma loginuppgifter går det hur bra som helst.

Någon som tror sig sitta på svaret?

PHP-kod:
<?php

   $dbhost 
'mysql.u8108201.fsdata.se';
   
$dbuser 'u8108201';
   
$dbpass 'X';
   
$base 'u810820_a';

$conn mysql_connect($dbhost$dbuser$dbpass);
if (!
$conn) {
    echo 
"Unable to connect to DB: " mysql_error();
    exit;
}
if (!
mysql_select_db($base)) {
    echo 
"Unable to select u810820_a: " mysql_error();
    exit;
}

$sql "SELECT * FROM states";

$result mysql_query($sql);
if (!
$result) {
    echo 
"Could not successfully run query ($sql) from DB: " mysql_error();
    exit;
}
if (
mysql_num_rows($result) == 0) {
    echo 
"No rows found, nothing to print so am exiting";
    exit;
}
// While a row of data exists, put that row in $row as an associative array
// Note: If you're expecting just one row, no need to use a loop
// Note: If you put extract($row); inside the following loop, you'll
//       then create $userid, $fullname, and $userstatus
while ($row mysql_fetch_assoc($result)) {
    echo 
$row["id"];
}
mysql_free_result($result);
?>
Bintang är inte uppkopplad   Svara med citatSvara med citat