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
https://forums.phpfreaks.com/topic/145146-solved-header-and-messages/
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"

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.

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

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.