Help With Databases. |
||
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.
Zymic Webmaster Forums Web Design & Development Server Side Scripting PHP |
||
![]() |
Help With Databases. |
||
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. |
|
|
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"; } |
|
|
![]() |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users) |
||
| 0 Members: | ||
Forum Jump |
||
| Lo-Fi Version | Time is now: 18th June 2013 - 11:44 PM |