Jump to content

Sucssful database entry message


crawlerbasher

Recommended Posts

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

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.
}
?>

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.