crawlerbasher Posted February 7, 2007 Share Posted February 7, 2007 At the moment I've manage to sucssefuly manage to get my script to work in submiting information and storing it on the database. And it comes up with a 1 to say its been done. My questions is, how do I go about setting up a more persional message when its uploaded the information to the database? This below is the script that produces the 1 message. // Start Database Entry include("config.php"); if ($action == "post") { $level = $_POST['level']; $items = $_POST['items']; $rank = $_POST['rank']; $hq = $_POST['hq']; $hq2 = $_POST['hq2']; $hq3 = $_POST['hq3']; $ingredients = $_POST['ingredients']; $crystal = $_POST['crystal']; $sub_craft = $_POST['subcraft']; $conn = mysql_connect($host, $username, $password); mysql_select_db($database, $conn); $sql = "INSERT INTO FFXI_Guild_Cooking values ('', '$items', '$crystal', '$ingredients', '$hq', '$hq2', '$hq3', '$rank', '$level', '$sub_craft')"; $result = mysql_query($sql, $conn) or die(mysql_error()); echo $result; // Trying to work on a methed to produce a result saying its been sucsses full or not. } // end Database entry Crawlerbasher Link to comment https://forums.phpfreaks.com/topic/37497-sucssful-database-entry-message/ Share on other sites More sharing options...
Balmung-San Posted February 7, 2007 Share Posted February 7, 2007 Do a test on result: <?php if($result)//this works, as 1 = true { echo "Personalized message" } ?> And nobody does cooking in FFXI. Well, nobody except me anyways. :'( Link to comment https://forums.phpfreaks.com/topic/37497-sucssful-database-entry-message/#findComment-179328 Share on other sites More sharing options...
obsidian Posted February 7, 2007 Share Posted February 7, 2007 As Balmung-San mentioned, it's a matter of keeping track of the result. when you run mysql_query(), it returns a result if successful, and otherwise, it returns a boolean FALSE. So, just do something like this: <?php if (!mysql_query($sql, $conn)) { // Error encountered, show custom error message } else { // Successfully inserted! Show custom success message. } ?> Link to comment https://forums.phpfreaks.com/topic/37497-sucssful-database-entry-message/#findComment-179334 Share on other sites More sharing options...
crawlerbasher Posted February 7, 2007 Author Share Posted February 7, 2007 And nobody does cooking in FFXI. Well, nobody except me anyways. I do. Anyway I'm not just adding cooking, but all the guild. BTW Thank You. Its worked out fine. BTW I'm guessing that I could had somthing like <?php if ($result == "1") { echo "congratulations"; } else if ($result == "0"} echo "I'm sorry" } ?> And that should work for if it fails too? Link to comment https://forums.phpfreaks.com/topic/37497-sucssful-database-entry-message/#findComment-179337 Share on other sites More sharing options...
Balmung-San Posted February 7, 2007 Share Posted February 7, 2007 Actually, I would use: <?php if(!$result) { echo "I'm sorry"; } else { echo "congratulations"; } ?> Since the result may be higher then one, but a failure will always be false. Link to comment https://forums.phpfreaks.com/topic/37497-sucssful-database-entry-message/#findComment-179343 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.