Jump to content

WatsonN

Members
  • Posts

    227
  • Joined

  • Last visited

Everything posted by WatsonN

  1. Any field that is 0
  2. That still pulls all rows with 0 as their value out.
  3. It sure does. I used SELECT y.*, COUNT(ads.UID) AS posts FROM YBK_Login AS y LEFT JOIN YBK_Ads AS ads ON ads.UID=y.ID WHERE `delete` = '0' GROUP BY y.ID And any field that was 0 was not displayed
  4. One more quick question. Could I put the WHERE clause in this, or would it break it? SELECT y.*,COUNT(ads.UID) AS posts FROM YBK_Login AS y LEFT JOIN YBK_Ads AS ads ON ads.UID=y.ID GROUP BY y.ID
  5. Works perfectly Thank Ya much
  6. 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 'delete = '0'' at line 1 I used what you said and I got that
  7. Is there a way to have multiple WHERE statements in a mysql . Like: SELECT * FROM YBK_Ads WHERE UID = '{$_GET['UID']}' and WHERE delete = '0' That doesn't work but is it possible
  8. Thank ya much, works perfectly. if (isset($_POST['Update'])){ $e71 = mysql_real_escape_string($_POST['element_7_1']); $e72 = mysql_real_escape_string($_POST['element_7_2']); $e2 = mysql_real_escape_string($_POST['element_2']); $e3 = mysql_real_escape_string($_POST['element_3']); $e4 = mysql_real_escape_string($_POST['element_4']); $e5 = mysql_real_escape_string($_POST['element_5']); $e13 = mysql_real_escape_string($_POST['element_13']); $e11 = mysql_real_escape_string($_POST['element_11']); $e6 = mysql_real_escape_string($_POST['element_6']); $e12 = mysql_real_escape_string($_POST['element_12']); $e8 = mysql_real_escape_string($_POST['element_8']); $update = "UPDATE `YBK_Ads` SET `CNF` = '{$e71}', `CNL` = '{$e72}', `ADD` = '{$e2}', `CITY` = '{$e3}', `STATE` = '{$e4}', `ZIP` = '{$e5}', `AS` = '{$e13}', `PT` = '{$e11}', `CN` = '{$e6}', `BY` = '{$e12}', `ACI` = '{$e8}' WHERE `ID` = '{$_POST['id']}'"; mysql_query($update) or die( 'Query string: ' . $update . '<br />Produced an error: ' . mysql_error() . '<br />' ); header("Location: http://ybk.watsonn.com/list.php"); }
  9. My code is supposed to update the table but it just wipes all the fields clean if (isset($_POST['Update'])){ // here we encrypt the password and add slashes if needed if (isset($_POST['add'])) { $_POST['element_1'] = addslashes($_POST['element_1']); $_POST['element_7_1'] = addslashes($_POST['element_7_1']); $_POST['element_7_2'] = addslashes($_POST['element_7_2']); $_POST['element_2'] = addslashes($_POST['element_2']); $_POST['element_3'] = addslashes($_POST['element_3']); $_POST['element_4'] = addslashes($_POST['element_4']); $_POST['element_5'] = addslashes($_POST['element_5']); $_POST['element_13'] = addslashes($_POST['element_13']); $_POST['element_11'] = addslashes($_POST['element_11']); $_POST['element_6'] = addslashes($_POST['element_6']); $_POST['element_12'] = addslashes($_POST['element_12']); $_POST['element_8'] = addslashes($_POST['element_8']); //------------------// $e1 = $_POST['element_1']; $e71 = $_POST['element_7_1']; $e72 = $_POST['element_7_2']; $e2 = $_POST['element_2']; $e3 = $_POST['element_3']; $e4 = $_POST['element_4']; $e5 = $_POST['element_5']; $e13 = $_POST['element_13']; $e11 = $_POST['element_11']; $e6 = $_POST['element_6']; $e12 = $_POST['element_12']; $e8 = $_POST['element_8']; } mysql_real_escape_string($update = "UPDATE `YBK_Ads` SET `BSN` = '{$e1}', `CNF` = '{$e71}', `CNL` = '{$e72}', `ADD` = '{$e2}', `CITY` = '{$e3}', `STATE` = '{$e4}', `ZIP` = '{$e5}', `AS` = '{$e13}', `PT` = '{$e11}', `CN` = '{$e6}', `BY` = '{$e12}', `ACI` = '{$e8}' WHERE `ID` = '{$_POST['id']}'");mysql_query($update) or die( 'Query string: ' . $update . '<br />Produced an error: ' . mysql_error() . '<br />' );//header("Location: http://ybk.watsonn.com/list.php");}
  10. @eran works perfectly Thanks both of you $data = mysql_query("SELECT y.*,COUNT(ads.UID) AS posts FROM YBK_Login AS y LEFT JOIN YBK_Ads AS ads ON ads.UID=y.ID GROUP BY y.ID") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { Print "<tr>"; Print "<td>".$info['UID'] . " </td>"; Print "<td>".$info['posts'] . " </td>"; Print "<td>".$info['ID'] . "</td> "; Print "<td>".$info['Allowed'] . "</td> "; Print "<td>".$info['pass'] . " </td>"; Print "<td>".$info['HR'] . " </td>"; }
  11. It wasn't posting I fixed it and works perfectly. Thank yall so much for the hep
  12. @joel24 I got unknown table a @eran it gives be a blank value it would be $info['postCount'] right?
  13. I changed it to that and echoed it and I still can't get it to echo the ID
  14. I'm sorry today hasnt been my day if (isset($_POST['payment'])) { mysql_real_escape_string($insert = "UPDATE `YBK_Ads` SET `payment` = '{$_POST['element_1']}' WHERE `ID` = '{$_POST['id']}'"); mysql_query($insert) or die( 'Query string: ' . $insert . '<br />Produced an error: ' . mysql_error() . '<br />' ); $error="<span style="; $error .="color:green"; $error .=">"; $error .= "<p>Thank you, the Payment status has been updated.</p>"; $error .="</span>"; setcookie('Errors', $error, time()+20); //header('Location: /?p=YearbookM'); exit; die; } Its not producing any error but its not updating either
  15. Spoke too soon Query string: INSERT INTO `YBK_Ads` (`payment`) VALUES ('Bill Sent') WHERE `YBK_Ads`.`ID` = '' Produced an 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 `YBK_Ads`.`ID` = ''' at line 1 code if (isset($_POST['payment'])) { mysql_real_escape_string($insert = "INSERT INTO `YBK_Ads` (`payment`) VALUES ('{$_POST['element_1']}') WHERE `YBK_Ads`.`ID` = '".$_POST['id']."'"); mysql_query($insert) or die( 'Query string: ' . $insert . '<br />Produced an error: ' . mysql_error() . '<br />' ); $error="<span style="; $error .="color:green"; $error .=">"; $error .= "<p>Thank you, the Payment status has been updated.</p>"; $error .="</span>"; setcookie('Errors', $error, time()+20); header('Location: /list.php'); exit; die;
  16. I'm trying to figure out how to implement SELECT COUNT into a php generated list. My script lists all the users in one table $data = mysql_query("SELECT * FROM YBK_Login") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { Print "<tr>"; Print "<td>".$info['UID'] . " </td>"; Print "<td>"."#"."</td>"; Print "<td>".$info['ID'] . "</td> "; Print "<td>".$info['Allowed'] . "</td> "; Print "<td>".$info['pass'] . " </td>"; Print "<td>".$info['HR'] . " </td>"; } ?> And I want to use the count to count the number of entries each user has in a diffrent table. Like pull the $info['ID'] and check against posts in YBK_Ads with the column name UID
  17. Works perfectly Thanks
  18. Changed to UPDATE `YBK_` SET `payment` = '$_POST[\'element_1\']' WHERE `ID` = '$_POST['id']' And I get Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/n/a/t/nathanwatson/html/admin/YBK/list.php on line 7
  19. I've half way fixed it so it doesnt look bad anymore so I'll call this solved
  20. Changed to ($insert = "UPDATE `YBK_Ads` (`payment`) VALUES ('{$_POST['element_1']}') WHERE `YBK_Ads`.`ID` = '".$_POST['id']."'") Error: Query string: UPDATE `YBK_Ads` (`payment`) VALUES ('Paid') WHERE `YBK_Ads`.`ID` = '' Produced an 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 '(`payment`) VALUES ('Paid') WHERE `YBK_Ads`.`ID` = ''' at line 1
  21. Update existing . . . I probally need to use UPDATE dont i -edit- spelling -edit-
  22. I have a form that is supposed to update a mysql row. The problem is that it wont post the $id to the script here is the form: form method="post" action=""> <label class="description" for="element_1">Payment Status: </label> <select class="element select medium" id="element_1" name="element_1"> <option value="Paid" SELECTED>Paid</option> <option value="Bill Sent" >Bill Sent</option> <option value="Check to be cashed" >Check to be cashed</option> </select> <input type="hidden" name="id" vlaue="<?php Print $ID; ?>"> <input id="saveForm" class="button_text" type="submit" name="payment" value="Update" /> </li> </ul><br><?php Print "Payment Status: <b>".$info['payment'] . "</b>"; ?> </form> here is the php side: if (isset($_POST['payment'])) { mysql_real_escape_string($insert = "INSERT INTO `YBK_Ads` (`payment`) VALUES ('{$_POST['element_1']}') WHERE `YBK_Ads`.`ID` = '".$_POST['id']."'"); mysql_query($insert) or die( 'Query string: ' . $insert . '<br />Produced an error: ' . mysql_error() . '<br />' ); $error="<span style="; $error .="color:green"; $error .=">"; $error .= "<p>Thank you, the Payment status has been updated.</p>"; $error .="</span>"; setcookie('Errors', $error, time()+20); header('Location: /list.php'); exit; die; } ?> I'm getting this on post Query string: INSERT INTO `YBK_Ads` (`payment`) VALUES ('Paid') WHERE `YBK_Ads`.`ID` = '' Produced an 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 `YBK_Ads`.`ID` = ''' at line 1 its not putting anything in the ID value
  23. I'm getting the error Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/n/a/t/nathanwatson/html/admin/post.php on line 156 and I cant find whats wrong with it Line 156 & 157: $check = mysql_query("SELECT * FROM users WHERE UID = '$_COOKIE['UID_WatsonN']'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) {
  24. I went over it again and fixed the bottom div error and now I can't find anything else. ?> </p> </div> </div> </div> <?php } ?>
  25. I have a page and i'm using php to add a "post" and it throws off my div and I cant figure out what to change. The source http://admin.watsonn.com/YBK/template.source The file that is messing up: http://admin.watsonn.com/YBK/list.source
×
×
  • 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.