all groups > flash data integration > december 2005 >
You're in the

flash data integration

group:

MySQL doesn't show the postings!


MySQL doesn't show the postings! Mojy
12/1/2005 8:37:10 PM
flash data integration:
Hello
I've created a simple form in Flash using MySQL with php. I've created tables
in the server, the hosting space for my Web site. Everything looks okay to me
but whenever I test the postings I can not see anything. I'm not sure where
this problem is coming from, PHP or SWF.I just finished a course which included
Flash and databases, so I'm not really very good at it.

I'm also attaching the coding from both PHP and SWF files, hoping that
somebody could help me with. I would appreciate your effort for resolving my
problem.

I also need to mention that the php file called: "record.php", the database
called: mojan_comments and the table created for called: comments

Many thanks in advance.
Mojan






<?php

$connect = mysql_connect("mysql.mynetkeepers.ca","mojan_comments");
$db = mysql_select_db("mojan-comments@mysql.mynetkeepers.ca");

//echo "<pre>";
//print_r($_GET);
//echo "</pre>";

$query = "insert into comments (comments_name,comments_text,comments_date)
values ('".$_GET['name']."','".$_GET['comments']."','".date("Y-d-m")."')";

$result=mysql_query($query,$connect);

?>


Please find below the coding in SWF file:

on(release){
if(name==""){
error="Enter Name!";
}else if(comments==""){
error="Enter Comments!";
}else{
error="Comments have been submitted!";
loadVariables("http://www.mediaxweb.com/record.php",_parent,"GET");
name="";
comments="";
}
}
Re: MySQL doesn't show the postings! Masamune
12/2/2005 12:56:02 AM
Mojan,

Try the following code:


<?php
$host = "mysql.mynetkeepers.ca";
$user = "Your MySQL user name";
$password = "Your MySQL password";
$database = "mojo_comments";

$comments_name = $_POST[comments_name];
$comments_text = $_POST[comments_text];
$comments_date = date("Y-m-d");

$connect = @mysql_connect($host, $user, $password) or die("result=Unable to
connect!");
$db = mysql_select_db($database);

$query = "INSERT INTO comments (comments_name, comments_text, comments_date)
VALUES ('$comments_name', '$comments_text', '$comments_date')";
$result = mysql_query($query,$connect) or
die("result=".mysql_error($connect));
echo "result=OK";
mysql_close($connect);
?>

ActionScript Code:

on (release) {
if (commentsName == "") {
error = "Enter Name!";
} else if (comments == "") {
error = "Enter Comments!";
} else {
var myDataResponse:LoadVars = new LoadVars();
var myData:LoadVars = new LoadVars();
myData.comments_name = commentsName;
myData.comments_text = comments;
myData.sendAndLoad("http://www.mediaxweb.com/record.php", myDataResponse,
"POST");
myDataResponse.onLoad = function() {
if (this.result == "OK") {
error = "Comments have been submitted!";
commentsName = "";
comments = "";
} else {
error = this.result;
}
};
}
}
Re: MySQL doesn't show the postings! Mojy
12/2/2005 5:12:23 PM
Thanks. I'll try it today and will let you know as soon as I get the result.
Appreciate your help.
Re: MySQL doesn't show the postings! Mojy
12/2/2005 5:33:12 PM
Hi,
Unfortunately I tried and not working...
Here is the message that I get while trying to post a message or something:
"No Database Selected"
I checked the AS and seems that we put the "record.php" in there, so how come
it doesn't recognize it?!
Before I was getting a message which saying that "Comments have been
submitted!" but I couldn't see the postings in my database...


Thanks again for looking into this.
Cheers,
Mojan
Re: MySQL doesn't show the postings! Mojy
12/3/2005 12:00:00 AM
Hi Chris,

Actually, I corrected this before uploading the file into the server. It's an
underscore so the database name is correct, mojan_comments!

Here is my Web site, I appreciate if you could check it out yourself. Please
go to the contact page. If needed I can send you the fla and php files.

Thanks again.
Mojan
Re: MySQL doesn't show the postings! Masamune
12/3/2005 1:09:39 AM
Mojan,
The error you were getting was for an incorrect database name.
Change the following line in your PHP code:
$database = "mojo_comments";
should be
$database = "mojan_comments";
Is this an underbar or a hyphen in your db name? In your original post you
had: mojan-comments? This is probably why your original code was not working.

Chris

Re: MySQL doesn't show the postings! Masamune
12/3/2005 10:09:56 AM
Mojan,

I tested the code I posted, and it works on my server. Email me your fla and php files and I'll try to find out what the problem is.

AddThis Social Bookmark Button