php - What are some reasons that I might be getting "0 rows affected" on this query? -
backstory:
i'm trying create wordpress theme , working on setup part of theme. i've installed wordpress , mysql database on running named testdb
. have file setup.php
looks
<?php error_reporting(-1); ini_set('display_errors', 'on'); $con = mysqli_connect('localhost', 'testadmin', 'something'); if ($con->connect_error) { die("connection failed: " . $conn->connect_error); } echo "<p>connected localhost successfully</p>"; if ($con->select_db("testdb")) { echo ("<p>connected database</p>"); } else { die($con->error); } if ($con->query("create table mems (id mediumint not null auto_increment primary key, name varchar (50), title varchar (20), bio varchar (500), sord int, picfn varchar (100))") === true) { echo("<p>created table team members.</p>"); } else { die($con->error);; } $con->close(); ?>
which failing on table creation part, output is
connected localhost successfully
connected database
create command denied user 'testadmin'@'localhost' table 'mems'
i assumed privileges problem, went mysql command line , ran
grant on testdb.* 'testadmin'@'localhost';
which outputs
query ok, 0 rows affected (0.03 sec)
i checked show databases;
indeed database testdb
there, , checked select user mysql.user;
user testadmin
there. know password correct.
so problem?
if mems
table exists, fail.
there's if not exists
clause check see if exists already.
create [temporary] table [if not exists] tbl_name [(create_definition,...)] [table_options] [partition_options] select_statement
[]
optional
Comments
Post a Comment