Hey...finally figured out how to make desktop apps using php π (excuse any misused terms, i dont really know what to call 'php-gtk' stuff)
but anyways...So is it possible to connect to a mysql db using php-gtk? Right now, I just have a button that calls a function..right now for testing all the function says is:
function login(GtkWindow $wnd, GtkEntry $txtUsername, GtkEntry $txtPassword)
{
$db_user = ""; // Username
$db_pass = ""; // Password
$db_host = ""; // Server Hostname
mysql_connect($db_host, $db_user, $db_pass) or die("cannot connect to db"); // Connects to the database.
// $query="SELECT * FROM `pdem_timesheets`.`tblTimesheet`";
// $result=mysql_query($query)or die("query 8 error");
// $num=mysql_numrows($result);//gets the number of rows of results
//$Phase=mysql_result($result,"1","Date");
//fetch the values from the widgets into variables
$strUsername = $txtUsername->get_text();
$strPassword = $txtPassword->get_text();
//Do some error checking
$errors = null;
if (strlen($strUsername) == 0) {
$errors .= "Username is missing.\r\n";
}
if (strlen($strPassword) == 0) {
$errors .= "No password given.\r\n";
}
if ($errors !== null) {
//There was at least one error.
//We show a message box with the errors
$dialog = new GtkMessageDialog($wnd, Gtk::DIALOG_MODAL,
Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, $errors);
$dialog->set_markup(
"The following errors occured:\r\n"
. "<span foreground='red'>" . $errors . "</span>"
);
$dialog->run();
$dialog->destroy();
} else {
//No error. You would need to hide the dialog now
//instead of destroying it (because when you destroy it,
//Gtk::main_quit() gets called) and show the main window
$wnd->destroy();
}
}
like I said, just for testing. It is an example off the php-gtk documentation page...
I commented out everything that has to do with the mysql_connect, just to test, and un commented one line at a time. It works perfect when everything is commented..and it works when uncommenting until the line with the mysql_connect call....so i figure that is where the error is.
what happens normally: the button is pressed and a msg box will pop up..
what is happening: i ht the button and the program shuts down...i think this is what it does when there is an error in the code...not sure tho
anyone know whats going on? π
thanks!