Jump to content

[SOLVED] header and messages


richarro1234

Recommended Posts

Hey there,

im trying to make it so that i can echo a message after a succesful SQL query, without having to load a new page.

 

So the query can be run and if it works it will echo a successful msg, but if it fails it will echo a msg (that isnt the mysql error:)

 

Here is the code:

$query = mysql_query("DELETE FROM <tablename> WHERE id = '$padid'");
header ("echo: testing?");
die();

 

thats the sort of thing i would like, how would i go about doin that please?

 

Thanks

Rich

Link to comment
Share on other sites

$query = mysql_query("DELETE FROM <tablename> WHERE id = '$padid'");
or die(mysql_error());  
echo "Success!";

 

Is that what you want? If there was an error and it wasn't put in it will output the error, but if the query was successful it will go onto the echo and echo "Success"

Link to comment
Share on other sites

yea thats what i want and it works great, thanks.

but is there anyway of choosing where it echo's as all the code is at the top of my page and i would like it to echo near the bottom of my page?

 

Thanks

Well, I guess you could just move the echo to wherever you want. Because if there is an error it won't get anywhere past the or die() line.

Link to comment
Share on other sites

yea but its for a certain function.

 

Here is the code for that bit:

...some site code above here....
if ($_GET['action'] == 'delete') {

$padid = ($_GET['padid']);

$query = mysql_query("SELECT * from richspri_social.padposts WHERE id = '$padid'");
while ($pad = mysql_fetch_array($query)) {

if (strtoupper($pad['posterid']) != strtoupper($urid)) {
header ("Location: $page&error=5");
die();
}
$there = "yes";
}

if ($there == FALSE) {
header ("Location: $page&error=6");
die();
}

$query = mysql_query("DELETE FROM richspri_social.padposts WHERE id = '$padid'");
echo "Success!";

}
....rest of the site code....

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.