mysql - php Toolkit rather than a framework -
i want make own php toolkit rather use 1 of many frameworks out there, specially since follow mvc, not i'm looking now. want start basics, , putting in mind oo, want simple php mysql connect in separate file (config.php), query in file (index.php)
i tried this, it's not working. doing wrong?
config.php in root
<?php $dsn = 'mysql:dbname=testdb;host=localhost'; $username = 'root'; $password = 'root'; $dbh = new pdo($dsn, $username, $password); ?>
index.php in root
<html> <body> <form action="" method="post"> <input type="text" name="search" autofocus /> <input type="submit" value="search" /> </form> </body> </html> <?php require_once 'config.php'; $query = "select * table field = '" . $search . "'"; $results = mysql_query($query); while($row = mysql_fetch_array($results)){ ?> <li> <?php echo $row['field']; ?> </li> <?php } ?>
update: please bear me, knowledge on new. thank you.
you mixing mysql_*
, pdo
... write queries in pdo
, rid of mysql_*
business.
Comments
Post a Comment