Jump to content

hitman6003

Members
  • Posts

    1,807
  • Joined

  • Last visited

Everything posted by hitman6003

  1. So it's an issue with the update script...not the html display
  2. JOINs http://dev.mysql.com/doc/refman/5.0/en/join.html
  3. echo ' <tr> <td>Is Admin?</td> <td> <label> <input type="radio" name="admin" value="1" ' . ($uadmin == 1 ? 'checked="checked"' : '') . ' /> Yes <input type="radio" name="admin" value="0" ' . ($uadmin == 0 ? 'checked="checked"' : '') . ' /> No </label> </td> </tr> ....and so on for the others....';
  4. the "die" will only be executed if the mysql query fails...not if it returns a result meaning that the username and password were not found. $conn = mysql_connect("localhost", name, password) or die("can not connect"); $db = mysql_select_db(database, $conn) or die ("can not connect"); $username = $_POST["username"]; $password = $_POST["password"]; $result = mysql_query("SELECT id FROM users WHERE uname = '$username' AND pword = '$password' ", $conn) or die ("Error in query: " . mysql_error()); if (mysql_num_rows($result) == 1) { echo "Username / Password combo found"; } else if (mysql_num_rows($result) > 1) { echo "Username / Password error - multiple entries"; } else { echo "Username / Password combo not found"; } mysql_close($conn); Note the difference in the "die" statement.
  5. The easiest thing, or at least the way with the least initial work, is to use a system like wordpress, or something similar, that presents tutorials in a format that you can categorize. http://www.learningjquery.com, among many others, does this.
  6. The ternary operator replaces an if...else statement... <? echo ($uadmin == 1) ? 'checked="checked"' : ''; ?> replaces <? if ($upageman == "1") { echo " checked=\"checked\""; } ?>
  7. Haven't tested it, but... SELECT item_name, date, STR_TO_DATE(date_column, '%d/%m/%Y') AS dtg FROM table_name WHERE MONTH(dtg) >= MONTH(NOW()) ORDER BY dtg ASC
  8. $conn1 = mysql_connect("1.1.1.1", "user", "pass"); $conn2 = mysql_connect("2.2.2.2", "user", "pass"); $query = "SELECT * FROM table1"; $results_from_conn1 = mysql_query($query, $conn1); $results_from_conn2 = mysql_query($query, $conn2); Same query, two different servers, presumably two different results. You can connect to as many database servers as your php server has resources for (each connection does take memory and such), and you can query each one independently in the same script.
  9. Not sure what you mean by "before it saves". If you change the value, then click update, and it doesn't update, that generally means that there is a problem with the update script, not the display script. On a different note, you can also use the ternary operator to do the "checking" of radio buttons... <tr> <td>Is Admin?</td> <td> <label> <input type="radio" name="admin" value="1" <? echo ($uadmin == 1) ? 'checked="checked"' : ''; ?> /> Yes <input type="radio" name="admin" value="0" <? echo ($uadmin == 0) ? 'checked="checked"' : ''; ?> /> No </label> </td> </tr>
  10. or strstr http://www.php.net/strstr
  11. php and javascript don't interact like that...JS is client side, php is serverside...and they don't talk directly. You'll have to read the html for the page into a variable, then use regex to get the title out of that text.
  12. probably not infinite...just too big an int for php
  13. Well, this is a php forum, so that is probably the kind of help you're going to get.
  14. Yep, use fopen, fwrite, and fclose. http://www.php.net/fopen http://www.php.net/fwrite http://www.php.net/fclose file_get_contents or fopen and fread. http://www.php.net/file_get_contents http://www.php.net/fread echo and/or print http://www.php.net/echo http://www.php.net/print Don't know what you mean ummm, text files. .doc is a MS word extension. It doesn't matter what extension you use, it will contain plain text regardless.
  15. Since you answered your own question, here is the correct way to use it: http://us.php.net/manual/en/function.mysql-real-escape-string.php#id5312299
  16. From the manual... http://www.php.net/session_destroy
  17. http://www.phpfreaks.com/tutorials/33/0.php
  18. Make sure you have a full text index on all columns you are using in your MATCH query. Also, check to see what rundbquery() does on an error...does it just return? Does it throw an error, but continue execution? Does it stop execution? If in doubt, use mysql_query() with a die on the end. $search_full = mysql_query($sql_query) or die(mysql_error()); What does rundbquery() return? An object? An array? Your while loop is infinite...you will always be able to set one var equal to another...you want something like: while ($found1 = mysql_fetch_assoc($search_full)) { printr ($found); printr ($search_full); } or foreach ($search_full as $found1) { printr ($found); printr ($search_full); } Depending on what your rundbquery returns (a mysql object, a set of object rows, or an array).
  19. As you can see here, http://us.php.net/manual/en/function.mail.php#id4752425, headers need to be separated by "\r\n"...including the last one. WTF is "\are"? I know it's not always necessary to use the curly braces ( {} ), however, since your script isn't functioning properly, you should make sure to use them to eliminate that as a source of error. Ensure error reporting and display errors are turned on: ini_set("display_errors", 1); error_reporting(E_ALL ^ E_NOTICE); <?php ini_set("display_errors", 1); error_reporting(E_ALL ^ E_NOTICE); $to = "xxx@yahoo.com"; $subject = "Put your subject line here"; $tmp = array(); foreach($_POST as $fld => $val) { if ($fld != 'submit') { $tmp[] = $fld . ': ' . stripslashes($val); } } $body = implode("\r\n",$tmp) . "\r\n"; $headers = 'From: ' . $_POST['name'] . ' <' . $_POST['mail'] . '>' . "\r\n"; if (mail($to,$subject,$body,$headers)) { echo "<h5>YOUR REQUEST HAS BEEN SENT! WE WILL GET BACK TO YOU SOON!</h5>"; } else { echo "An error has occurred"; } ?>
  20. You can not output any data / text to the browser before sending a header... This is incorrect: echo "hey, thanks dude!"; ............... header("Content-length: " . strlen($csv)); header("Content-type: text/csv"); header("Content-Disposition: attachment; filename=data.csv"); You must send the headers before anything else.
  21. Where is your open / close form tag? The single most important part of your file upload form is the enc type.... http://us2.php.net/manual/en/features.file-upload.php
  22. The session_start() outputs a header to the browser, which I think may be causing a problem. YOu also should not output html to the browser after telling it that you are sending a csv file... Also check to make sure that your included "login.php" isn't outputting to the browser before the csv does. <?php session_start(); include("database.php"); $user = $_SESSION['username']; if($user != "dan") { $first = ucwords($_POST['first']); $last = ucwords($_POST['last']); $spouse = ucwords($_POST['spouse']); $address = ucwords($_POST['address']); $city = ucwords($_POST['city']); $state = ucwords($_POST['state']); $zip = ucwords($_POST['zip']); $homePhone = ucwords($_POST['homePhone']); $cellPhone = ucwords($_POST['cellPhone']); $email = $_POST['email']; $query = "INSERT INTO info VALUES ('$user','$first','$last','$spouse','$address','$city','$state','$zip','$homePhone','$cellPhone','$email')"; mysql_query($query); } else if ($user == "dan") { /*********************************** Write Date to csv file ***********************************/ if ($_POST['submit']) { $query = "select * from info"; $result=mysql_query($query); $csv = username.','.First.' '.Name.','.Last.' '.Name.','.Spouse.','.Address.','.City.','.State.','.Zip.','.Home.' '.Phone.','.Cell.' '.Phone.','.Email."\n"; while ( list($user, $first, $last, $spouse, $address, $city, $state, $zip, $homePhone, $cellPhone, $email) = mysql_fetch_row($result) ) { $csv .= $user.','.$first.','.$last.','.$spouse.','.$address.','.$city.','.$zip.','.$homePhone.','.$cellPhone.','.$email."\n"; } header("Content-length: " . strlen($csv)); header("Content-type: text/csv"); header("Content-Disposition: attachment; filename=data.csv"); echo $csv; } } mysql_close(); include("login.php"); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Thank you!</title> <link rel="stylesheet" type="text/css" href="mycss.css" /> </head> <body> <br> <br> <form method="post"> <input type="submit" name="submit" value="Get Data" /> </form> <br /> <br /> <br /> <a href="logout.php">Logout</a> </body> </html>
  23. You can't prevent people from opening tabs...what you can do is set a session variable, for example a "last loaded" value that contains a timestamp and the page name...then on each page check that timestamp. If a period of time, say 45 seconds, hasn't passed, then just display a simple text "You must wait ... to refresh this page". Once the time period has gone by, they can load the page, then it resets the timer.
×
×
  • 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.