Jump to content

farse

Members
  • Posts

    26
  • Joined

  • Last visited

farse's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. In PHP 5, I conventionally opened my pages with <?php but within the pages I often used <? to open a php block, e.g., <?echo $variable; ?>. In PHP 7, I find it is necessary to always use <?php and follow it with a space, e.g., <?php echo $variable; ?> I haven't been able to find any reference to this syntax change so my question: Is this a new requirement of PHP 7? Can it be turned off? Otherwise, I will need to edit all of the sites where my earlier habit was used, which I think I can do but would feel compelled to spend some hours testing afterward.
  2. This code is excerpted from a larger form for editing values saved in the database. It was written by someone else who is no longer available and I am stymied by its behavior. The conditions are: artPrice can be any integer; the query returns more than one row and all three “allow" functions return true. As indicated, artPrice = 0 means not for sale; artPrice = 1 means price on request and all other values represent dollar values. For the first row returned, expected behavior occurs. A price can be changed in value or changed to POR or NFS; POR can be changed to NFS and vice versa and either one can be changed to a dollar value. For all rows other than the first, a dollar price can be changed to a different value or it can be changed to POR or NFS. POR can be changed to NFS and vice versa. The problem is that POR or NFS, whether set from the database or by a change from a dollar value, cannot be reset to a dollar value. It took me a few hours just to figure out the parameters of the problem and lots more to decide I couldn’t solve it. Anybody? price_edit.php
  3. Here's the answer I found elsewhere: // You were really close! I think the issue was that when you called // mysqli_stmt_get_result in the if() you didn't realize it was consuming the // data set up by the execute and thus your second call to it didn't get any // records. // you should assign into $result immediately and then test that in the if() if ( $result = mysqli_stmt_get_result($stmt) ) { $row = mysqli_fetch_array($result); $col1 = $row[0]; echo phpversion(); echo "<p>$col1</p>"; exit; } else { echo '<p>We got nothing</p>'; };
  4. We know the code works through mysqli_stmt_execute because it works fine when mysqli_stmt_get_result is replace with: mysqli_stmt_bind_result($stmt, $col1); mysqli_stmt_fetch($stmt) echo "$col1\n"; exit;
  5. When I saw: Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /Applications/MAMP/htdocs/TEST/accountinsert.php on line 188 I realized I had not changed the ini file when I downloaded the latest MAMP a few days ago--and have done that. Still, the error message seems to mean that mysqli_stmt_get_result is not returning data. Also, I'm coding in TextWrangler which colors the PHP code pretty consistently and does not seem to recognize get_result as legitimate.
  6. I probably should have put all the code up initially but here it is--with late edits: $query = "SELECT col1 FROM contactinfo WHERE col2 = ? && col3 = ? && (col4 = ? || col5 = ?) "; $stmt = mysqli_prepare($connect, $query); mysqli_stmt_bind_param($stmt, "ssss", $var1, $var2, $var3, $var4); mysqli_stmt_execute($stmt); if (!mysqli_stmt_get_result($stmt)) { report the result in a user message } else { $result = mysqli_stmt_get_result($stmt); $row = mysqli_fetch_array($result); $newvar = $row[0]; echo "$newvar\n"; exit; } I'm not getting the user message and get a blank screen. The data is in the db and is an integer. Also, the code works OK with: mysqli_stmt_bind_result($stmt, $col1); mysqli_stmt_fetch($stmt) echo "$col1\n"; exit;
  7. Adding echo "$newvar\n"; exit; I get a blank page. PHP error_display is on and working but nothing from that.
  8. I want to convert an existing site to use prepared statements. This will be much easier if I can get the result of a SELECT query as an array to replace the array returned by mysqli_fetch_array. I am using PHP 5.4 with mysqlnd activated and should be able to use mysqli_stmt_get_result(stmt) to get such an array. But that function does not work and does not seem to be available at all. But all the documentation I'be read says it should be available in PHP 5.4. $query = "SELECT col1 FROM contactinfo WHERE col2 = ? && col3 = ? && (col4 = ? || col5 = ?) "; $stmt = mysqli_prepare($connect, $query); mysqli_stmt_bind_param($stmt, "ssss", $var1, $var2, $var3, $var4); mysqli_stmt_execute($stmt); $row = mysqli_stmt_get_result(stmt); $newvar = $row[0]; The actual query is much longer but this is the form. If I can't use mysqli_stmt_get_result, I'll probably abandon the transition. Can someone offer advice on my next move?
  9. I'm adopting HTML5 and decided trying to apply it in one of my existing sites would be a good way to learn how it behaves. I am attaching a file that behaves in a way that I am trying to understand. I have excised all irrelevant code. It is an interactive site written in php. As you will see if you open the page in a browser, the HTML5 section element seems to reduce the size of my text as opposed to div. I have played with this for several hours trying unsuccessfully to figure out what's going on. Can anyone offer a reason or even a hypothesis? Incidentally, if you exchange main and section, all three lines are reduced so it is definitely the section element. test.php
  10. Details, details! Thank you. That works nicely. If I could just learn one new thing everyday... Farse
  11. This is too simple but I can't find the answer. I want to send multiple error messages in separate paragraphs in an email sent with mail(). I want to avoid using html. Here's what I tried as a test to see how to make separate paragraphs: mail('email@address', 'System Error','The error(s) relate to a purchase.nnPlease review the PayPal emails and IPN history to determine the correct status of the artwork./n/nMake whatever corrections to the database are needed.', 'FROM: email@address' ); and here's what I get: The error(s) relate to a purchase.nn Please review the PayPal emails and IPN history to determine the correct status of the artwork.nn Make whatever corrections to the database are needed. I'm not even getting a new line, let alone two so it seems inconsistent with the guidance in the Manual. I also tried rr and rn with no luck. Can I do what I am trying to do?
  12. I took my cue from what must have been an earlier list of acceptable values and from the server's default php.ini timezone, which displayed as "Denver" with no "America/" prefix. I will certainly try "America/New_York" and will be delighted with the new functions available in 5.3 when it works. (I'll be back if it doesn't work.) Thank you much.
  13. A search on date.timezone produced no results on this forum, but I have seen this topic discussed somewhere---now forgotten site. In trying to set up PHP 5.3 with a 5.3 php.ini file, I got the following error message: "Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Denver' for 'MST/-7.0/no DST' instead in /home/content/81/9100081/html/lindamoor/adminlist.inc.php on line 3" I included "date.timezone = 'New York'" in my ini file, checked with info.php to see that it was set and still got the same error message. Repeated attempts, including different references (Phoenix & Denver) never eliminated the message. Without being able to change the memory limit with php.ini, I had to abandon 5.2 and revert to 5.2. Can anyone enlighten me?
×
×
  • Create New...