Jump to content
Larry Ullman's Book Forums

fishswim

Members
  • Posts

    9
  • Joined

  • Last visited

fishswim's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. you could try a if construct. test if end user is logged in, if so echo date time, where you want the data in the page. what is weird in your question is that the date time is displayed when end user is not logged in. of any construct that you made to call date time , may be bassakwards.
  2. Okay i will play with that direction. Thank you for the reply.
  3. Hello On page 368 MySQL second edition when i write this script out and send it through the browser ... Warning mysqli_fetch array() expects parameter 1 to be mysqli_result, boolean given /file/string/file/string I have gone into the PHP web site and type in mysqli_fetch_array to look at the syntax and the page i am directed to shows, mysqli_result::fetch_array and the calls in the PHP manual page for mysqli_result::fetch_array are the same as in the script in the book. $query = SELECT etc $r or result = mysqli_query($link, $query); The warning in the browser is from this line of the script in the book list($num_records) = mysqli_fetch_array($result, MYSQLI_NUM); --------------------------------------------- if i reconstruct the call to: list ($num_records = mysqli_fetch_array($result, MYSQLI_NUM)); the warning`s change to one warning: syntax error, unexpected '=' expecting ',' or ')' if i use a , the results are fatal error: cannot use function return value in write context. and if a remove the , and close ) the list() call: Parse error, syntax error, unexpected mysql_fetch_array expexting '=' and then its back to parameter 1 expecting to be mysql_result, boolean given. I also added the script from the PHP manual mysqli::real_connect and it works as a stand alone when called by the browser, Does any one have any suggestions Thank you.
  4. Yes with a large exclamation mark. Migrating with the bison. yet i am a little slow. i was really freaking out on that script. it has been two years since i was fully into coding, been working the graveyard shift, learned my lesson. this works also, WHERE column_name = REGEXP ' '; Thanks for the reply.
  5. I am working with PHP Third edition and MySQL second edition - both show php mysql scripts. working with PHP for the web, third edition, page 373, modify the script to accept value from form field and then and to receive data from database. I have re worked this many times over and am frustrated to the point of brain freeze. what can i do to receive the business name associated with zip code in database. any assistance ? thank you. <?php if ( isset($_POST['submitted']) ) { $baz = $_POST['zip']; $dbc = mysql_connect('localhost', 'usr_name', 'password'); mysql_select_db('data_base_name'); //$query = 'SELECT biz_name FROM retail_client WHERE zip_code = 99201'; //$query = 'SELECT biz_name FROM retail_client WHERE zip_code = \'$baz\' '; // error message: mysql_query() expects parameter 2 to be resource, if($r = mysql_query('$dbc' 'SELECT biz_name FROM retail_client WHERE zip_code = 99201')) { while ($row = mysql_fetch_array($r) { print "<p> {$row['biz_name']} </p>"; } // while } // two } //ONE print ' <form action="this_script.php" method="post"> <p>Zip code: <input type="text" name="zip" size="10" /></p> <input type="submit" name="submit" value="go" /> <input type="hidden" name="submitted" value="true" /> </form> '; ?>
  6. In the HTML form value="30000" what does the 30000 translate to. I have gone into the php ini file and see there is a value of 32m. I could slap together a text file in text edit with a few lines for testing, that would be a few kb, that would work as a test. Yet i was wondering what the 30000 translate to. Thank you
  7. There is received this error notice. Notice: Undefined index: temp_name and the if conditional in the script as written in the end user`s script and book shows: if(move_uploaded_file($_FILES['thefile']['temp_name'], "../t_testUploads/{$_FILES['thefile']['name']}")) I do see in the ini file: upload_tmp_dir = /Applications/MAMP/tmp/php before i attempt to place the value of /Applications/MAMP/tmp/php in place of temp_name. so the actual question here is, will placing the ini file value of /Applications/MAMP/tmp/php in place of temp_index do the trick. note, i am working a graveyard shift so the brain and action is in a state of ask questions first. normally i would just jump and see what happens. Thank you.
  8. I am working thru chapter 8, page 214 and supplementing my own code to see what works. If i have a separate conditional for each $_POST[] array first_name, last_name, email etc and then place the conditional to print out the values at the bottom before the closing bracket that began with the first initial conditional, i do receive error messages as shown below in the first code example. Why would that be. If each conditional to print out the value from the $POST array can print out its value in its own conditional, following a conditional using the same index in its own conditional. Or put another way. If there is one value from a html form in a post array and that value can be accessed in a conditional. why is that value not available several conditional`s below its first iteration. does this particular situation have something to do with " stack " or is the stack, [deal with] functions only. Thank you in advance for any response. // the error messages: //Notice: Undefined index: first_name in /somewhere/ qC_stickyRegister.php on line 73 //Notice: Undefined index: last_name in /somewhere/qC_stickyRegister.php on line 78 //Notice: Undefined index: email in /somewhere/qC_stickyRegister.php on line 83 if(!empty($_POST['submitted'])) { $problem = FALSE; if(empty($_POST['first_name'])) { $problem = TRUE; print'<p class="error">Please enter a first name.</p>'; } //---------------------------------------- if(empty($_POST['last_name'])) { $problem = TRUE; print'<p class="error">Please enter a last name</p>'; } //--------------------------------------- if(empty($_POST['email'])) { $problem = TRUE; print'<p class="error">Please enter your e mail address</p>'; } //------------------------------------------- if(empty($_POST['password1'])) { $problem = TRUE; print'<p class="error">Please provide a password.</p>'; } //----------------------------------------- if($_POST['password1'] != $_POST['password2']) { $problem = TRUE; print'<p class="error">Your passwords do not match.</p>'; } //------------------------------------------------------------------------------ if(!$problem) { print'<p>Registration is good.</p>'; $_POST = array(); } else { print'<p class="error">Something went wrong</p>'; } // ----------CONDITIONALS TO PRINT OUT THE VALUES ------------------ if($_POST['first_name'] == TRUE) { $Fname = $_POST['first_name']; print "<p>If the following information is correct please press proceed. <br />First Name: $Fname <br />"; } if($_POST['last_name'] == TRUE) { $Lname = $_POST['last_name']; print "Last Name: $Lname <br />"; } if($_POST['email'] == TRUE) { $mailE = $_POST['email']; print "E mail Address: $mailE </p>"; } } And This Does Work ... if(!empty($_POST['submitted'])) { $problem = FALSE; //------------------------------ if(empty($_POST['first_name'])) { $problem = TRUE; print'<p class="error">Please enter a first name.</p>'; } //------------------------------- if($_POST['first_name'] == TRUE) { $Fname = $_POST['first_name']; print "<p>If the following information is correct please press proceed. <br />First Name: $Fname <br />"; } //---------------------------------------------------------------- if(empty($_POST['last_name'])) { $problem = TRUE; print '<p class="error"Please enter a Last name</p>'; } //------------------------------- if($_POST['last_name'] == TRUE) { $Lname = $_POST['last_name']; print "Last Name: $Lname <br />"; } //------------------------------------------------------------------------------ if(empty($_POST['email'])) { $problem = TRUE; print'<p class="error">Please enter your e mail address</p>'; } //-------------------------------- if($_POST['email'] == TRUE) { $mailE = $_POST['email']; print "E mail Address: $mailE </p>"; } //-------------------------------------------------------------------------- if(empty($_POST['password1'])) { $problem = TRUE; print'<p class="error">Please provide a password.</p>'; } if($_POST['password1'] != $_POST['password2']) { $problem = TRUE; print'<p class="error">Your passwords do not match.</p>'; } if(!$problem) { print'<p>Registration is good.</p>'; $_POST = array(); } else { print'<p class="error">Something went wrong</p>'; } }
×
×
  • Create New...