Hi to all in PHP-land.
I having a problem getting my PHP script to access my database, and so I have thrown myself upon the mercy of this forum for some aid. Any help would be greatly appreciated.
The Question:
This may be a stupid question, but are there any considerations when using 'connect_mysql_db' from a script that begins with a 'session_start()' command? In my defence, I am still learning to crawl as far as PHP is concerned, let alone walk. However, it seems that this might be the problem in my script (listed below for reference).
Flash, PHP and MySQL versions:
Flash 8, PHP 4.4.2 and MySQL 5.0.19-Debian_2 on remote host.
Background:
I am trying to make a 'change password script' (with a single input text field (the input's 'var' name is 'pass'), a dynamic text field with 'var' name 'status' and submit button in a Flash movie. On clicking the submit button, the var 'pass' should be sent to the PHP script. It seems that this part is working. I have run the Flash Actionscript and PHP through the debuggers and they say that the syntax is fine.
The Scripts:
I am sending a variable from Flash called 'pass' to change the user's password.
The mysql_connect.php script referred to below is just the values of of the host, database, username and password in the following format;
<?php
$DBhost = "local host";
$DBuser = "username";
$DBpass = "password";
$DBName = "db name";
?>
- The main script (copied and pasted):
<?php
ob_start();
session_start();
include('../templates/mysql_connect.php');
$pass=$_POST['pass'];
if ($pass){
@mysql_connect($DBhost,$DBuser,$DBpass);
@mysql_select_db("$DBName");
$query = "UPDATE members SET userpassword=$pass WHERE username={$_SESSION['username']}";
$result = @mysql_query($query);
if (mysql_affected_rows() == 1) {
print "_root.status=Password changed&_root.checklog=1";
exit();
} else {
print "_root.status=Password could not be updated&_root.checklog=2";
}
}
else {
print "root.status=Problem connecting to database&root.checklog=3";
}
ob_end_flush();
?>
I know that it is most probably something small. As I have said, any help would be immensely appreciated.
Thank you for your time and have a good day.