Jump to content

thereaper87

Members
  • Posts

    49
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

thereaper87's Achievements

Member

Member (2/5)

0

Reputation

  1. Great, thank you for your help! For others that come across this thread, this is what I used, and it works! mysql_query("(SELECT * FROM `schedule` WHERE `date` < NOW() ORDER BY `date` DESC LIMIT 1) UNION ( SELECT * FROM `schedule` WHERE `date` > NOW() ORDER BY `date` ASC LIMIT 1)") or die("error");
  2. Hello there, this is more of a me trying to get my mind around it, more than it is a coding problem. I have a list in a database table that has a data on it in the format: mm/dd/yyyy I am trying to get the closest date from today. So today is the 4th, and the next date in the table is October 12, but when it is the 13th, it should get the next date automatically. I can't seem to figure out what coding structure to use. Any ideas?
  3. Not too sure what it means, but here is the result: array(4) { ["pick1"]=> string(7) "Science" ["pick2"]=> string(7) "General" ["pick3"]=> string(11) "Electronics" ["bio"]=> string(11) "asdfasdfsdf" }
  4. There is no error output. I have die(mysql_error($update_profile)); echo '<br />Your profile has been updated.'; But it does not display an error.
  5. Trying to debug my sql statement. This is what it echo'd out when I ran the query: Everything seems to be in their columns...i'm lost
  6. I posted almost the exact same thing has phpSensei! lol
  7. Hello there, I'm having a bit of trouble getting the UPDATE function to work and I was looking for some guidance. Here is the form: echo '<tr><td width="300">Current Avatar: <br /><img src="avatars/'.$data[avatar].'" width="100" height="100"></td><td width="300"><input type="file" value="Change" name="file"></td></tr>'; echo '<tr><td width="300">News Pick 1</td><td width="300"><select name="pick1"><option value="'.$data[field1].'">'.$data[field1].'</option><option value="Science">Science</option><option value="Politics">Politics</option><option value="Arts">Arts</option><option value="Sports">Sports</option><option value="Religious">Religious</option><option value="General">General</option><option value="Electronics">Electronics</option></select></td></tr>'; echo '<tr><td width="300">News Pick 2</td><td width="300"><select name="pick2"><option value="'.$data[field2].'">'.$data[field2].'</option><option value="Science">Science</option><option value="Politics">Politics</option><option value="Arts">Arts</option><option value="Sports">Sports</option><option value="Religious">Religious</option><option value="General">General</option><option value="Electronics">Electronics</option></select></td></tr>'; echo '<tr><td width="300">News Pick 3</td><td width="300"><select name="pick3"><option value="'.$data[field3].'">'.$data[field3].'</option><option value="Science">Science</option><option value="Politics">Politics</option><option value="Arts">Arts</option><option value="Sports">Sports</option><option value="Religious">Religious</option><option value="General">General</option><option value="Electronics">Electronics</option></select></td></tr>'; echo '<tr><td width="300">Edit Bio</td><td width="300"><textarea name="bio" cols="50" rows="8">'.$data[bio].'</textarea></td></tr>'; echo '<tr><td width="300"><input type="submit" value="Submit Changes"></form></td><td></td></tr>'; Pretty much 3 drop-downs and a textbox. Here is the processing: if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) { $_POST['pick1'] = stripslashes($_POST['pick1']); $_POST['pick2'] = stripslashes($_POST['pick2']); $_POST['pick3'] = stripslashes($_POST['pick3']); $_POST['bio'] = stripslashes($_POST['bio']); $userid = stripslashes($userid); } $pick1 = mysql_real_escape_string($_POST['pick1']); $pick2 = mysql_real_escape_string($_POST['pick2']); $pick3 = mysql_real_escape_string($_POST['pick3']); $bio = mysql_real_escape_string($_POST['bio']); $userid = mysql_real_escape_string($userid); $update_profile=mysql_query("UPDATE `user` SET `field1`='$pick1',`field2`='$pick2',`field3`='$pick3',`bio`='$bio' WHERE `username`='$userid'") or die(mysql_error($update_profile)); echo '<br />Your profile has been updated.'; echo '<br /><a href="index.php?page=cpanel">Go to profile</a>'; // $userid = $_SESSION['user'] , that is where it is called But when I fill out the form, it says it has been updated, but no change in the row in the database. Any ideas? What am I missing?
  8. Thank you! It now updates the row in phpmyadmin. But it does it twice! So instead have adding 1, it adds 2! Any idea?
  9. Hello there, I have an UPDATE sql state which is giving me some troubles Here is the update code $r_time = date("m/j/Y g:i A"); $u_time = date("U"); $news_id = (int)$news_id; $update_article_rate_up=mysql_query("UPDATE `articles` SET `up_rating`=(`up_rating`+1) AND `avg_rating`=(`avg_rating`+1) WHERE `id`=$news_id") or die("Error updating up rating"); $news_id is pulled from the URL. That's it. Nothing else. It is set as an integer. Here is the debugging verision: $r_time = date("m/j/Y g:i A"); $u_time = date("U"); $news_id = (int)$news_id; $update_article_rate_up=("UPDATE `articles` SET `up_rating`=(`up_rating`+1) AND `avg_rating`=(`avg_rating`+1) WHERE `id`=$news_id") or die("Error updating up rating"); echo $update_article_rate_up; This is what it says: Which I think is right! What is going on here?
  10. Awesome! Just to be sure, I wrap that in script tags correct?
  11. Hello there, I have a problem, that I am trying to find some literature about, or maybe an example, or a demo; or just plain help. What I am trying to do, is to have a query ran every 2 seconds, to display a number. Here is what I am trying to implement. //index.php <script> function updateShouts(){ // Assuming we have #shoutbox $('#shoutbox').load('latestShouts.php'); } setInterval( "updateShouts()", 2000 ); </script> // to merge that with // latestShouts.php $total = mysql_query("SELECT COUNT(*) FROM $table_and_query"); $total = mysql_fetch_array($total); return $total[0]; I know that will not work, because I really don't know much about ajax. I read all of the tutorials on w3, but they didn't really have an example I was looking for. Any help is appreciated.
  12. $sql=mysql_query("SELECT * FROM `buds` WHERE `level`<='$user_level' UNION SELECT * FROM `buds`, `unlocked_buds` WHERE buds.`id` = unlocked_buds.`bud_id` ORDER BY buds.`id` ASC") or die("A MySQL error has occurred.<br />Your Query: " . $sql . "<br /> Error: (" . mysql_errno() . ") " . mysql_error()); I have been trying to learn about UNION select statements. I ran the query above and got this response: I think I know what the problem is, but not sure how to fix it. There is two columns, one is "buds" which holds the flowers seeds info. The seconds is "unlocked_buds" which just links the "id" from buds to "user_id" to the user table. Both buds and unlocked_buds are both 8 columns. What do I need to learn?
  13. Hello there, decided to try to have a joined table query, running into a couple of problems. Here is the query: $sql=mysql_query("SELECT * FROM `buds`, `unlocked_buds` WHERE `id`.buds = `bud_id`.unlocked_buds ORDER BY `id`.buds ASC") or die("A MySQL error has occurred.<br />Your Query: " . $sql . "<br /> Error: (" . mysql_errno() . ") " . mysql_error()); Which gives the error: The two tables are 'buds' and 'unlocked_buds' Not really sure what to change, I have been following this tutorial http://www.sqltraining.org/selecting+data+from+multiple+tables/, but really is not helping that much. What exactly does that mean? What really is happening?
  14. Thank you for your input, but since I am the only one that is clicking on the form, I am not double clicking. I clicked the slowest possible and still it double submits. Could it be a server configuration problem?
  15. Hello there, I have made a ban form on my website. It is all going good until I open phpmyadmin. There is two records from one submission. Usually the second record has some missing information. There should not be a duplicate and I do not understand why it is happening. If anybody could explain what is causing this would be great. Here is the page. <?php session_start(); require_once 'database.php'; if(isset($_SESSION['mod'])) { $userid = $_SESSION['user']; if(isset($_GET['action']) && strcasecmp($_GET['action'], "file") == 0) // checks to see if form is submitted { $username = $_POST['user']; $time = $_POST['time']; $reason = $_POST['reason']; $u_time = date("U"); $r_time = date("m-j-Y g:i A"); if($time == "00") { // if the time is a permaban $sql=mysql_query("SELECT * FROM user WHERE username='$username'") or die("Error 1"); $data=mysql_query($sql); $user_ip = $data['last_ip']; if ($user_ip != 127.0.01) { // admin stuff $p_ban=mysql_query("INSERT INTO ip_ban (ip,real_time,unix_time,days_left,reason) VALUES ('$user_ip','$r_time','$u_time','99999999999','$reason')") or die("Error 2"); echo 'The user '.$username.' has been banned.'; }else{ // if it is an admin echo 'You cannot ban that user.'; } }else{ // not a perma ban if($username != "admin") // admin stuff { $temp_ban=mysql_query("INSERT INTO blacklist (email,reason,end_date,appeal,unixtime) VALUES ('$username','$reason','$time','No','$u_time')") or die("Error 3"); echo 'The user '.$username.' has been banned.'; }else{ echo 'You cannot ban that user.'; } } }else{ $user_ban = $_GET['user']; if(isset($user_ban)) { ?> <form name="file_ban" method="post" action="?action=file"> Username: <input type="text" name="user" value="<?php echo $user_ban; ?>"><br /> Length of Ban: <select name="time"> <option value="1">1 Day</option> <option value="3">3 Days</option> <option value="5">5 Day</option> <option value="7">1 Week</option> <option value="15">15 Days</option> <option value="30">1 Month</option> <option value="90">3 Months</option> <option value="99999999999">∞ Infinity (Permaban)</option> <option value="00">IP Ban (Does not expire)</option> </select><br /> Reason: <br /> <textarea name="reason" cols="50" row="4"></textarea><br /> <input type="submit" value="Ban"> <?php }else{ } } }else{ // If session is not set header("Location: index.php"); } ?> If you need any explanation of what anything does, just please ask. Thank you!
×
×
  • 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.