Welcome, Guest. Please login or register.
Did you miss your activation email?
02/07/12, 08:34
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  Server side Scripting and Database Support
| |-+  PHP, Perl, ASP, JSP, CFM (Moderators: Flash-db, Musicman, vesa kortelainen, Ronald Wernecke, Jorge Solis, nothingGrinder)
| | |-+  Login file with PHP, into MySQL database
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: Login file with PHP, into MySQL database  (Read 1882 times)
Jaylada
Seasoned Programmer
***
Posts: 142



View Profile WWW Email
« on: 08/10/09, 00:13 »

I'm having trouble connecting to my database, and these two files are involved.  Can someone check this to see if there is anything obviously wrong with the code.  Any help would be greatly appreciated.

Thanks


_______________dbinfo.php
<?php

define('DBINFO_HOST', 'localhost');
define('DBINFO_USER', 'usr name');
define('DBINFO_PASS', 'password');
define('DBINFO_DATA', 'ODBC DSN name here');

?>

________________________________________file 2
<?php
include 'dbinfo.php';

$connect = mysql_connect(DBINFO_HOST, DBINFO_USER, DBINFO_PASS);
mysql_select_db(DBINFO_DATA, $connect);

function assignImages($uid, $arr)
{
   if($arr == '')
      return;
      
   $arr = explode(',', $arr);
   foreach($arr as $val)
   {
      $sql = 'INSERT INTO user_images (user_id, image) VALUES ("' . $uid . '", "' .  $_POST['hash'] . '-' . $val . '"); ';
      $row = mysql_query($sql);
   }
}

function login($username, $password)
{
   $sql = 'SELECT id FROM user WHERE username = "'. $username .'" AND password =md5("' . $password . '") LIMIT 1';
   $query = mysql_query($sql);
   $row = mysql_fetch_assoc($query);
   $userid = $row['id'];
   $num = mysql_num_rows($query);
   $imgUp = '';
   if(isset($_POST['imgUp']))
      $imgUp = $_POST['imgUp'];
      
   if($num > 0)
   {
      echo '&response=1&msg=SUCCESS&username=' . $username . '&userid=' . $userid;
      assignImages($userid, $_POST['imgUp']);
   } else
      echo '&response=0&msg=FAIL';
}

if(isset($_POST['username']) && isset($_POST['password']))
{
   login($_POST['username'], $_POST['password']);
}else{
   echo '&response=0&msg=NO_INPUT';
}
?>
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6161


View Profile WWW Email
« Reply #1 on: 08/10/09, 02:53 »

if the incredients are ok, you should be able to connect.

Do you have phpMySQL installed?
Are you able to connect there?
Irritating is the odbc-stuff - ther you should have the database name only. No extras like hostname, username or alike, you would use for odbc connect.
This is allready set with connect to the database engine.
Logged

happy flashing
Cool
Ronald
Jaylada
Seasoned Programmer
***
Posts: 142



View Profile WWW Email
« Reply #2 on: 08/11/09, 21:57 »

I don't have any of it set up on my computer with the newer version of the software so I'm doing all the testing Live online.

I'm pretty sure I have the ODBC stuff set up correctly, because I have it working correctly with some Coldfusion code which calls out the all of those hostnames etc
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6161


View Profile WWW Email
« Reply #3 on: 08/11/09, 22:21 »

again - are you able to login with these incredients, when you use phpMyAdmin?

If the incredients are ok, it works.
Logged

happy flashing
Cool
Ronald
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!