I am working on a script, and for whatever reason PHP cant write/read MySQL. I know that the database is connected because I had it print if it connected successfully and it does. I also selected the right databse. I tried running the quarry that I am using in phpMyAdmin and it works just fine there. It doesnt give me any errors but instead just doesnt have any results.
Here is the code from my login.php file (I removed the login boxes to make sure the problem wasnt in the $_POST):
login.php (quick login test)
<?php
//Include the includes/Connect to DB
define('158', TRUE );
require_once('header.inc.php');
//Login variables
$username = 'test';
$password = 'test';
//$login =sprintf("SELECT * FROM Users WHERE username = '%s' ",
//mysql_real_escape_string($username));
$login = sprintf("SELECT * FROM Users WHERE username = '%s' AND password = '%s'",
mysql_real_escape_string($username),
mysql_real_escape_string($password));
$SQLlogin = mysql_query($login);
$userdata = mysql_fetch_array($SQLlogin);
echo $userdata['id'];
?>
Header requires dbConnect.php which connects to MySQL, so here is my dbConnect.php (and this works just fine I think):
<?php
//prevent direct access
if(!defined('158')){die('Access Denied');}
//database options
$serverData = array(
'server' => 'localhost',
'sqluser' => '*******',
'sqlpass' => '*******'
) ;
//connect to database
$sqlConnect = mysql_connect($serverData['server'], $serverData['sqluser'], $serverData['sqlpass']);
if (!$sqlConnect) {
die('Could Not Connect');
}
else {
echo 'connection successful';}
mysql_select_db('********_UPortal', $sqlConnect);
?>
Thanks

New Topic/Question
Reply



MultiQuote






|