Jump to content

guru62

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Everything posted by guru62

  1. in phpmyadmin, select ur database and hit the export tab, make sure data is checked and save to a file. after that go to your hosting providers phpmyadmin delete that database and simply create a new empty database and import the file you made. simples.
  2. no luck, i want to use button to select the user that is displayed and delete their record but im having trouble in running the mysql query, here is my updated code, the delete query is at the bottom: $sql= "SELECT user_name FROM users"; $result = mysql_query($sql); if(!$result) { echo 'Users could not be displayed, please try again later.' . mysql_error(); } else { if(mysql_num_rows($result) == 0) { echo 'There are no users.'; } else { echo '<table border="1"> <tr> <th>Users</th> <th>Delete user and their posts?</th> </tr>'; while ($row = mysql_fetch_array($result)) { if($_SERVER['REQUEST_METHOD'] != 'POST') { echo '<form method="post" action=""><tr>'; echo '<td class="leftpart">'; echo $row['user_name']; echo '</td>'; echo '<td class="rightpart"><form method="post" action=""><input type="submit" name="delete" value="DELETE - '. $row['user_name'] .' "></form></td>'; echo '</tr>'; } else { $sql="DELETE FROM users WHERE user_name = " . mysql_real_escape_string($_GET['user_name']); } } } }
  3. hello im trying to delete a user from users table by using a button. This is my code: $sql= "SELECT user_name FROM users"; $result = mysql_query($sql); if(!$result) { echo 'Users could not be displayed, please try again later.' . mysql_error(); } else { if(mysql_num_rows($result) == 0) { echo 'There are no users.'; } else { echo '<table border="1"> <tr> <th>Users</th> <th>Delete user and their posts?</th> </tr>'; while ($row = mysql_fetch_array($result)) { if($_SERVER['REQUEST_METHOD'] != 'POST') { echo '<form method="post" action=""><tr>'; echo '<td class="leftpart">'; echo $row['user_name']; echo '</td>'; echo '<td class="rightpart"><form method="post" action=""><input type="submit" name="delete" value="DELETE - '. $row['user_name'] .' "></form></td>'; echo '</tr>'; } else { $sql="DELETE FROM users WHERE user_name = " . mysql_real_escape_string(($_POST['delete']); } } } } When I click the button, it does not delete the record, any ideas?
  4. then why doesnt this query for example in another script of mine need concatenation? $sql= "SELECT categories.cat_id, categories.cat_name, categories.cat_description, COUNT(topics.topic_id) AS topics FROM categories LEFT JOIN topics ON topics.topic_id = categories.cat_id GROUP BY categories.cat_name, categories.cat_description, categories.cat_id";
  5. $sql = "SELECT topic_id, topic_subject, topic_date, topic_cat FROM topics WHERE topic_cat = " . mysql_real_escape_string($_GET['id']) . " ORDER BY topic_date DESC"; I got it, the whole time I forgot to concatenate! Thanks for reminding me, its been bugging me for 2 hours! Also I know we have to use quotes after topic_cat = ", but why does the query not work without it, is it something to do with concatenation of a php function?
  6. still no result
  7. Thanks, I am using a syntax highlighting editor, but what am I missing?
  8. $sql = "SELECT topic_id, topic_subject, topic_date, topic_cat FROM topics WHERE topic_cat = " . mysql_real_escape_string($_GET['id']) ORDER BY topic_date DESC; i tried this now and the page doest even open i get a http 500 error, i think this fails to run
  9. WHAT AM I DOING WRONG IN THIS QUERY??? "SELECT topic_id, topic_subject, topic_date, topic_cat FROM topics ORDER BY topic_date DESC WHERE topic_cat = " . mysql_real_escape_string($_GET['id']); if i remove the order by bit it works but i want my results to come back ordered. this query wont work. i recieve this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE topic_cat = 1' at line 14 this query is to be echoed using php on html page
×
×
  • 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.