DanArosa Posted January 7, 2008 Share Posted January 7, 2008 Hi, I'm a graphic design student and have no PHP experience, however, I need to incorporate a guestbook into my Flash website. I downloaded a customisable guestbook and customised it to fit in with my site, but it doesn't work, could someone have a look at the PHP for me and see if that's where I'm going wrong. Thanks in anticipation of your help, dan Quote Link to comment Share on other sites More sharing options...
revraz Posted January 7, 2008 Share Posted January 7, 2008 You may have to post this in the 3rd party scripts section, but if you can explain what you mean by "doesn't work" and post the code, we may be able to help. Quote Link to comment Share on other sites More sharing options...
DanArosa Posted January 7, 2008 Author Share Posted January 7, 2008 Hi, By doesnt work, I mean it posts no results back to the guestbook. The guestbook can be seen at www.thismeatisfresh.com, then by clicking on book of meat link at top right corner. Here is the script: <?php //---------------------------------------------- DO NOT CHANGE FOLLOWING (UNLESS U KNOW WHAT UR DOING) -------------------// if(isset($_POST['name'])){ //retrieve variables $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $date = date("Y-m-d"); } //create connection to the database $conn = mysql_connect($host, $username, $password) or die("could not connect to server"); $select_db = mysql_select_db($db,$conn); if(isset($_POST['name'])){ //insert entry into guest book $insertSQL = "INSERT INTO guestbook_tbl (Name, Email, Message, Date) VALUES ('$name', '$email', '$message', '$date')"; $rs = mysql_query($insertSQL,$conn); if($rs){ //insertion was successful now lets send back to flash all entries in the database in XML Format retrieveData(); }else{ echo '&entryadded=FAIL&'; exit(); } }else{ retrieveData(); } function retrieveData(){ global $conn; //get entries from guestbook $selectSQL = "SELECT * FROM guestbook_tbl ORDER BY ID DESC"; $rs = mysql_query($selectSQL,$conn); //generate the xml file echo "<?xml version=\"1.0\"?>\n"; echo "<entries>\n"; while($row = mysql_fetch_assoc($rs)){ echo "<log>\n"; echo "<name>".$row['Name']."</name>\n"; echo "<email>".$row['Email']."</email>\n"; echo "<date>".$row['Date']."</date>\n"; echo "<message>".$row['Message']."</message>\n"; echo "</log>\n"; } #now lets end the xml file echo "</entries>\n"; #close the mySQL connection mysql_close($conn); } ?> Thanks for the reply, dan Quote Link to comment Share on other sites More sharing options...
DanArosa Posted January 7, 2008 Author Share Posted January 7, 2008 Just realised I posted the password can give this to anyone who needs to have a look though. Dan Quote Link to comment Share on other sites More sharing options...
revraz Posted January 7, 2008 Share Posted January 7, 2008 Remove your login details from the post (but not the script). Change (in two places) $rs = mysql_query($insertSQL,$conn); to $rs = mysql_query($insertSQL,$conn) or die ("Error in query: $insertSQL " . mysql_error()); And post the error. Quote Link to comment Share on other sites More sharing options...
DanArosa Posted January 7, 2008 Author Share Posted January 7, 2008 Thanks, I'll try that now Dan Quote Link to comment Share on other sites More sharing options...
DanArosa Posted January 7, 2008 Author Share Posted January 7, 2008 Hi, could only find it in one place, It's not to replace this line as well is it? $rs = mysql_query($selectSQL,$conn); Thanks again, dan Quote Link to comment Share on other sites More sharing options...
revraz Posted January 7, 2008 Share Posted January 7, 2008 $rs = mysql_query($selectSQL,$conn) or die ("Error in query: $selectSQL " . mysql_error()); Hi, could only find it in one place, It's not to replace this line as well is it? $rs = mysql_query($selectSQL,$conn) or die ("Error in query: $selectSQL " . mysql_error()); ; Thanks again, dan Quote Link to comment Share on other sites More sharing options...
DanArosa Posted January 7, 2008 Author Share Posted January 7, 2008 Hi, Changed that, do I need to upload it to my server or can I test it in Dreamweaver? Thanks, Dan Quote Link to comment Share on other sites More sharing options...
revraz Posted January 7, 2008 Share Posted January 7, 2008 You would have to upload it, unless you can parse PHP in Dreamweaver. Upload it with another name if you want to keep your original in tact. Quote Link to comment Share on other sites More sharing options...
DanArosa Posted January 7, 2008 Author Share Posted January 7, 2008 Ok thanks, I've tried it and at http://www.thismeatisfresh.com/process.php it shows this message: &entryadded=FAIL& Dan Quote Link to comment Share on other sites More sharing options...
revraz Posted January 7, 2008 Share Posted January 7, 2008 Verify the table name is guestbook_tbl and there is a field named ID in that table. Quote Link to comment Share on other sites More sharing options...
DanArosa Posted January 7, 2008 Author Share Posted January 7, 2008 I've checked those and both are correct. Cheers, Dan Quote Link to comment Share on other sites More sharing options...
revraz Posted January 7, 2008 Share Posted January 7, 2008 The flash is probably posting to the other name. I would say rename your other file and name the new one what it should be. Quote Link to comment Share on other sites More sharing options...
DanArosa Posted January 7, 2008 Author Share Posted January 7, 2008 Cool, I've done that and realised I had the database name wrong in the login details so changed that too. Now at http://www.thismeatisfresh.com/process.php Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/.hesta/graphikdzine/thismeatisfresh.com/process.php on line 56 Thanks, Dan Quote Link to comment Share on other sites More sharing options...
revraz Posted January 7, 2008 Share Posted January 7, 2008 Something is still wrong with the connection, try this code and put your connection parameters up top. <?php //put your connection info up here $name = "Test"; $email = "Email@email.com"; $message = "Message"; $date = date("Y-m-d"); //create connection to the database $conn = mysql_connect($host, $username, $password) or die("could not connect to server"); $select_db = mysql_select_db($db,$conn); $insertSQL = "INSERT INTO guestbook_tbl (Name, Email, Message, Date) VALUES ('$name', '$email', '$message', '$date')"; $rs = mysql_query($insertSQL,$conn) or die ("Error in query: $insertSQL. " . mysql_error()); if($rs){ echo "ADDED"; }else{ echo 'FAILED' .mysql_error(); exit(); } ?> Quote Link to comment Share on other sites More sharing options...
DanArosa Posted January 7, 2008 Author Share Posted January 7, 2008 I've done that, and now at http://www.thismeatisfresh.com/process.php there is the message: ADDED does that help at all? Thanks for your time, sorry this is taking a while, Dan Quote Link to comment Share on other sites More sharing options...
revraz Posted January 7, 2008 Share Posted January 7, 2008 Means it works without Flash. I don't know enough about Flash to help you with why it doesn't work in your Flash form. If you look at the DB via MyPHPAdmin (or any other tool), do you now see entries in the table? Quote Link to comment Share on other sites More sharing options...
DanArosa Posted January 7, 2008 Author Share Posted January 7, 2008 1 Test Email@email.com Message 2008-01-07 2 Test Email@email.com Message 2008-01-07 3 Test Email@email.com Message 2008-01-07 4 Test Email@email.com Message 2008-01-07 5 Test Email@email.com Message 2008-01-07 6 Test Email@email.com Message 2008-01-07 7 Test Email@email.com Message 2008-01-07 8 Test Email@email.com Message 2008-01-07 I'm seeing this yeah, is that right, I presume it is? Dan Quote Link to comment Share on other sites More sharing options...
revraz Posted January 7, 2008 Share Posted January 7, 2008 Yep, so your flash page should show that in the bottom window if a new person signs it. Quote Link to comment Share on other sites More sharing options...
DanArosa Posted January 7, 2008 Author Share Posted January 7, 2008 That's great thanks, I've tried it and it hasn't shown up for me, maybe just a delay, does it show up for you? Cheers, Dan Quote Link to comment Share on other sites More sharing options...
revraz Posted January 7, 2008 Share Posted January 7, 2008 It doesn't, shouldn't be any delay at all, DB write is instant. Quote Link to comment Share on other sites More sharing options...
DanArosa Posted January 7, 2008 Author Share Posted January 7, 2008 Ah right, I'll look into this then. Thanks so much for your help and time, it really is appreciated. email me if you ever want a logo for anything you're working on free of charge. Best Regards, Dan Quote Link to comment Share on other sites More sharing options...
revraz Posted January 8, 2008 Share Posted January 8, 2008 If you want, paste your mysql table layout as well. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.