Jump to content
Larry Ullman's Book Forums

TIF

Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by TIF

  1. I predict that USC & PSU will meet again next year in the Championship Game! We're both that promising. // get id from html form $ident = $_POST['identity']; // Add a blank record saving a spot $result = mysql_query("INSERT LOW_PRIORITY INTO purchase (uniq, id) VALUE (NULL, $ident)") or die('Duplicate entry. Please choose another ID.');
  2. To clarify, entering a numeric value for id results in the row being added. Entering an alpha value for id results in an INSERT error. The insert command follows: $result = mysql_query("INSERT LOW_PRIORITY INTO purchase (uniq, id) VALUE (NULL, $ident)") or die('Duplicate entry. Please choose another ID.');
  3. I agree with your observation as to the Primary Key. I did have an AI field and had the same symptoms. I'll change it back. The ID field, now the primary key, is indeed VARCHAR(20), not null. BTW, I was rooting for my alma mater, USC, in the Rose Bowl. It was the most exciting bowl game of the year.
  4. Unable to insert a record with an alpha key value. Structure: name - id type - VARCHAR length - 20 default - None collation - latin1_general_ci attributes - blank null - blank auto incr - blank id is the primary key This works for unique values of $ident: $ident = "12345"; $result = mysql_query("INSERT INTO purchase (id) VALUE ($ident)"); This does not work for values of $ident containing an alpha character: $ident = "ABCDE"; $result = mysql_query("INSERT INTO purchase (id) VALUE ($ident)");
  5. Case #1: Variable created from a POST: $identity = $_POST['soarid']; SELECT statement works just fine: $result = mysql_query("SELECT * FROM faculty WHERE id = $identity") or die("Faculty ID Not Found"); Variable created from a db field: $fac_school = $row["school"]; Variable content verified ok Attempt to use that variable in a SELECT statement: $result = mysql_query("SELECT * FROM position WHERE school = $fac_school") or die("Not found"); Does not work! Forcing the variable value thusly: $fac_school = "SOBM"; $result = mysql_query("SELECT * FROM position WHERE school = $fac_school") or die("Not found"); Still does not work! But this works: $result = mysql_query("SELECT * FROM position WHERE school = 'SOBM' ") or die("Not found"); Case #2: Similar to above but using INSERT INTO. The insert fails when variable values are used but ok when strings are used for values. All examples int the "PHP and MySQL" book use strings and not variables. What am I missing?
  6. I created a PHP file that requests a login name with an HTML form that uses the POST action. Immediately following this form, I open a database and select that name within a PHP section. The form doesn't wait for an entry & a "submit" click to serve up that name to the PHP select. It runs the select code immediately and then reruns it after the submit click. BTW, I loved chapter one via Kindle. The hard copy is coming today.
  7. The book won't get here until sometime tomorrow but I was able to get through chapter one via Kindle without a problem. I created a PHP file with the following HTML form in the beginning: <h3>Committee Volunteer Application</h3> <h4>Enter your Faculty ID</h4> <form method="post"> ID: <input name="soarid" type = "text" /> <input type = "submit" value "Go" /> </form> This was followed by PHP code that is to act upon the submitted value. However, the script does not wait for the form to be submitted but continues to execute. How do I make it wait for the submit button? BTW, separating this code into its own HTML file, it will run a separate PHP file when called by the form.
×
×
  • Create New...