Zymic Forums

Webmaster resources

Zymic IRC Server

Chat in real time at irc.zymic.com - Learn More

Welcome

Welcome to the Zymic webmaster forums. Our forums are here to provide people the free ability to discuss a range of websites related topics such as design, development coding and marketing.

In order to post you will need to register for a zymic account or if you already have one simply login by using the form on the left.

left Zymic Webmaster ForumsWeb Design & DevelopmentServer Side ScriptingPHP right
  Reply to this topic Start new topic
left right
Unit158
post Aug 3 2012, 03:57 PM
Post #1


Newbie
*

Group: Members
Posts: 14
Joined: 21-January 12
Member No.: 226,854



CODE
$name = "****";
$password = "****";
$database = "****";
$mysqli = new mysqli("localhost", $name, $password, $database);
    if (strcasecmp($_GET[cmd], "delete")) {
        $mysqli->query("DELETE FROM tickets WHERE ticketno=".$_GET[id]);
    }
$mysqli->close();

Ok, so this is half the code to a ticket management system I am building, and when I load the page, the whole table is cleared. No GET values, just the normal load of the page.
Before it would display the table's contents (in the other half of the code), but couldn't delete.
I am new to SQL databases and none of my friends have used it.
Go to the top of the page 
 
  + Quote Post
ClickSSL
post Aug 29 2012, 10:54 AM
Post #2


Newbie
*

Group: Members
Posts: 8
Joined: 13-April 10
From: Newark, DE, USA
Member No.: 138,271



As per your code if you dont passed cmd command in your url string then you will not able to GET this variable and value so plz first check have you pass cmd command in your URL ??......
there is not any problem with the connection therefore if you had any doubt in your database connection then add below code and check ...if connection is not proper then display error and also your query not execute properly then also display error.

$name = "****";
$password = "****";
$database = "****";
$mysqli = new mysqli("localhost", $name, $password, $database);
if ($mysqli->connect_errno)
{
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}

if (strcasecmp($_GET[cmd], "delete"))
{
$result=$mysqli->query("DELETE FROM tickets WHERE ticketno=".$_GET[id]);
if($result)
{
echo "Delete tickets successfully!!";
}
if(!$result)
{
printf("Errormessage: %s\n", $mysqli->error);
}
$mysqli->close();
}
else
{
echo "query is not execute";
}
Go to the top of the page 
 
  + Quote Post
 Reply to this topic Start new topic
left right
0 Members:
left right
 


Lo-Fi Version Time is now: 18th June 2013 - 11:44 PM