Author Topic: Using the MegaZine with a PHP and MySQL database  (Read 2898 times)

carmonkeycasino

  • Newbie
  • *
  • Posts: 12
Using the MegaZine with a PHP and MySQL database
« on: March 10, 2009, 05:32:26 pm »
Hi, i'm looking for some help, basically i want to create the Megazine by outputting it's XML through PHP, my info from the MySQL database should be called and displayed on each page. What i'm getting at the moment is the info from the database just displayed on its own without any line breaks, also the book does'nt appear on the browser at all, any advice  ??? . The code looks like this:

Code: [Select]
<?php require_once('Connections/connection.php'); ?>

<?php

if (!function_exists("GetSQLValueString")) {

function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  if (
PHP_VERSION 6) {
    
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}

mysql_select_db($database_connectDB$connectDB);
$getReviewsQuery "SELECT * FROM horror_reviews ORDER BY USER_ID ASC LIMIT 1";
$getReviewsQueryRecordset mysql_query($getReviewsQuery$connectDB) or die(mysql_error());


//header("Content-type: text/xml");
$xml_output "<?xml version=\"1.0\" encoding=\"utf-8\"?>
\n";
$xml_output .= "<!DOCTYPE book SYSTEM \"http://megazine.mightypirates.de/megazine.dtd\">\n";


while ($row = @ mysql_fetch_array($getReviewsQueryRecordset)) {
$xml_output .= "<book pageoffset=\"2\" bggradient=\"false\" bgcolor=\"0xFFFFFF\" navigation=\"false\" openhelp=\"true\" pagenumbers=\"false\" startpage=\"2\">\n";
$xml_output .= "<chapter foldfx=\"1\">\n";
$xml_output .= "<page stiff=\"true\">".$row['BOOK']."</page>\n";
$xml_output .= "<page>".$row['REVIEW']."</page>\n";
$xml_output .= "<page></page>\n";
$xml_output .= "<page stiff=\"true\"></page>\n";
$xml_output .= "</chapter>\n";
$xml_output .= "</book>\n";
}

// These are closing tags

$xml_output .= "</chapter>\n";
$xml_output .= "</book>";

echo $xml_output;

mysql_free_result($getReviewsQueryRecordset);
?>

Someone helped me alot with this code so if somebody could explain a solution in the simplest terms possible it would be great  :) .

Thanks in advance.

kopitejay

  • Support
  • Jr. Member
  • *****
  • Posts: 37
Re: Using the MegaZine with a PHP and MySQL database
« Reply #1 on: March 11, 2009, 12:26:06 am »
I'm not a full PHP programmer but it looks as though your code only creates an XML object and outputs the result onto the webpage. There is no code in there that links to a Flash movie. If you are to link your XML to a MegaZine flash movie, I believe you have to pass the XML to the movie and make that movie visible on the web page.

You might want to go back to the person who helped you with the PHP code and ask them how to link it in with a Flash movie.

Cheers
Jay

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1989
  • MegaZine3 Developer
    • MegaZine3
Re: Using the MegaZine with a PHP and MySQL database
« Reply #2 on: March 11, 2009, 03:02:04 pm »
From what I see the code looks pretty much ok - I'm assuming you link said php file as the xml source?

When you open the "XML" (i.e. the php page) in the browser, does it display correctly (except for no line breaks but that shouldn't matter)? Have you tried validating it?

For debugging, if you are not doing so anyway, try using an unmodified version as it comes with the releases, and open the console by pressing the # key and see if any errors are being displayed.
For the Snark was a Boojum, you see.

Before you ask a question
          After you get an answer
  • please document your problem with the answer in the Project Wiki. (e.g. in the FAQs)
  • help others out if you can, by answering their questions on the forum.

carmonkeycasino

  • Newbie
  • *
  • Posts: 12
Re: Using the MegaZine with a PHP and MySQL database
« Reply #3 on: March 18, 2009, 09:02:48 pm »
Firstly, thanks to both of you for trying to help, i really really appreciate it.

Florian i'm not sure exactly what you meant when you said:

From what I see the code looks pretty much ok - I'm assuming you link said php file as the xml source?

Do you mean that i have to link the PHP file somewhere in the ActionScript code.

Also when i open the PHP page in my browser, the text from the title and and the review fields of my database are displayed correctly, its just that the book is nowhere to be seen. The only thing on the browser is the text at the top and a white background.

Sorry if i'm not being clear or descriptive enough.

Thanks again for all your help, you are truly legends.  ;)

carmonkeycasino

  • Newbie
  • *
  • Posts: 12
Re: Using the MegaZine with a PHP and MySQL database
« Reply #4 on: March 18, 2009, 09:12:01 pm »
Heres a screencap of what comes up when i test my PHP code:


Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1989
  • MegaZine3 Developer
    • MegaZine3
Re: Using the MegaZine with a PHP and MySQL database
« Reply #5 on: March 19, 2009, 07:45:12 pm »
The source of that page would be interesting, because if that _is_ the source (and nothing Firefox decided to build from the underlying xml) it won't work.

What I meant earlier was that you use that url in the HTML when specifying the location of the xml, i.e. that you have something like
Code: [Select]
swfobject.embedSWF( ..., { xmlFile : "path/to/your.php", ... }, ...);
For the Snark was a Boojum, you see.

Before you ask a question
          After you get an answer
  • please document your problem with the answer in the Project Wiki. (e.g. in the FAQs)
  • help others out if you can, by answering their questions on the forum.

carmonkeycasino

  • Newbie
  • *
  • Posts: 12
Re: Using the MegaZine with a PHP and MySQL database
« Reply #6 on: March 19, 2009, 07:59:34 pm »
Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE book SYSTEM "http://megazine.mightypirates.de/megazine.dtd">
<book pageoffset="2" bggradient="false" bgcolor="0xFFFFFF" navigation="false" openhelp="true" pagenumbers="false" startpage="2">
<chapter foldfx="1">
<page stiff="true">It</page>
<page>"It" is a story that does take some patience to get into after the initial hook, but afterward, you'll have trouble putting it down. The night I finished it for the first time, I was 200 pages from the end and it was already midnight, but I just had to ke</page>
<page></page>
<page stiff="true"></page>
</chapter>
</book>
</chapter>
</book>

When i view the page source on Firefox it looks like that. Whereabouts would i put that embedSWF line you mentioned, would it be in the PHP file or an ActionScript file. Sorry to be a plague but its not too easy when we're not face-to-face.

Thanks for your patience  ;D

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1989
  • MegaZine3 Developer
    • MegaZine3
Re: Using the MegaZine with a PHP and MySQL database
« Reply #7 on: March 19, 2009, 08:05:29 pm »
Alright, one thing would be to teach your PHP script to wrap txt elements around the text in the pages, so instead of
Code: [Select]
<page stiff="true">It</page>it should read
Code: [Select]
<page stiff="true"><txt>It</txt></page>
You shouldn't need to modify any ActionScript files at all. Just use the HTML file as it comes with the releases and change the embedSWF call as I described (so that the xmlFile variable points to your PHP file).
For the Snark was a Boojum, you see.

Before you ask a question
          After you get an answer
  • please document your problem with the answer in the Project Wiki. (e.g. in the FAQs)
  • help others out if you can, by answering their questions on the forum.

carmonkeycasino

  • Newbie
  • *
  • Posts: 12
Re: Using the MegaZine with a PHP and MySQL database
« Reply #8 on: March 19, 2009, 08:08:49 pm »
Oh i see, thanks for clearing that up, your a legend man.

I'll give it a shot, and i'm sure i'll be back with more problems.

Thanks for your help Florian  :)

carmonkeycasino

  • Newbie
  • *
  • Posts: 12
Re: Using the MegaZine with a PHP and MySQL database
« Reply #9 on: March 26, 2009, 08:30:24 pm »
Hey Florian,

I finally got the database communicating, i took out the extra closing tags that were in the PHP file e.g

Code: [Select]
$xml_output .= "</chapter>\n";
$xml_output .= "</book>";

In the HTML i changed the xmlFile part and finally its communicating, now all i have to do is enable the user to add a review and change the background...any tips  ;D . So i'll be back with more questions, thanks a bunch to kopitejay and particularly Florian  ;)

Thanks