Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by farse

  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?
  14. You are wise beyond your years, Old Man from scene 24Thank you.
  15. Is it possible to use a non-alphanumeric character as the $glue string in the implode() function?e.g., implode('\v',$array)I am trying to join strings in an array with a vertical tab using \v. It simply uses the v as the $glue string.I also tried \x0B and it used x0B.I went in circles in the PHP Manual and got mixed messages.??
  16. OK, your tests convinced me that the functions worked so I kept fiddling until I got it to work but, unfortunately, I don't know what was wrong or what fixed it.But I'm happy and appreciate your help. Thanks.
  17. Your two tests worked as expected; var_dump result int(2) for a jpeg. That one didn't surprise me because I could echo $testtext.The first test did surprise me because it seems to be just what I am writing. I'll play around with structure some more and move the IF block up in the code to see what happens.
  18. If you look at my note at 6:20 today: When I used the exif_imagetype directly in the IF function, it didn't see it as a function but as a string. Hence the non-recognition of the $testtext variable.
  19. Here's the code from the top to the part that gives the error; the rest is more tests and some image operations. Again, keep in mind that this code works fine for jpegs when the final block is not there or commented out. Also, I've tried a lot of different configurations to get around this problem and finally decided it's not a function of construction.<?phpsession_start();include('mylibrary/connect.php');connect();if ($_SESSION['artworknumber'] + $_SESSION['numworks'] == 6){ $_SESSION['artworkmessage'] = 7; header ('Location: index.php'); exit;} $title = $_POST['title'];$media = $_POST['media'];$width = $_POST['width'];$height = $_POST['height'];$depth = $_POST['depth'];$price = $_POST['price'];$artwork = $_FILES['artwork'];if (get_magic_quotes_gpc()){ $title = stripslashes($title); $media = stripslashes($media); $width = stripslashes($width); $height = stripslashes($height); $depth = stripslashes($depth); $price = stripslashes($price); }$title = mysql_real_escape_string($title);$media = mysql_real_escape_string($media);$width = mysql_real_escape_string($width);$height = mysql_real_escape_string($height);$depth = mysql_real_escape_string($depth);$price = mysql_real_escape_string($price);$_SESSION['title'] = $title;$_SESSION['media'] = $media;$_SESSION['width'] = $width;$_SESSION['height'] = $height;$_SESSION['depth'] = $depth;$_SESSION['price'] = $price;if (!($title AND $media AND $width AND $height AND $price)){ $_SESSION['artworkmessage'] = 4; header ('Location: index.php'); exit;}if (!(($artwork['type'] == 'image/jpeg') || ($artwork['type'] == 'image/pjpeg')) && ($artwork['size'] < 2000000 )){ $_SESSION['artworkmessage'] = 5; header ('Location: index.php'); exit;}$testtext = exif_imagetype($artwork['tmp_name']);if ($testtext != 2){ $_SESSION['artworkmessage'] = 3; header ('Location: index.php'); exit;}?>
  20. If I comment out the block, the script behaves as it should. To add to the mystery, if I upload a GIF file to the following script:$testtext = exif_imagetype($artwork['tmp_name']);echo "$testtext is correct.";if ($testtext != 2){ do something}The following is printed to the screen:1 is correct.Notice: Undefined variable: testtext in [if ($testtext != 2)]So the exif_imagetype function is providing the correct result, but seems to resist being used as an expression in the IF construct. Yet, the PHP Manual provides the IF construct as an example of its usage.Other IF constructs in the script function as expected.
  21. This promises to be exactly what I need but I'm getting: Parse error: syntax error, unexpected T_STRING in [the following line:]if (exif_imagetype('images/cocochanel.jpg') != IMAGETYPE_JPEG)orif (exif_imagetype('images/cocochanel.jpg') != 2)which seems to me to be identical to the example given in the manual.Actually, I'm trying to apply the function to an uploaded temporary file but get the same error with the following:if (exif_imagetype($_FILES['tmp_name']) != IMAGETYPE_JPEG)Clearly, there is something I don't understand.
  22. I haven't tried these out yet, but they look exactly like what I needed. I tried using fread to get the first 16 characters of the file and had mixed luck. I'll be working on this today and let you know how it turns out.Thanks.
  23. I'm deliberately using a TIFF file less than 2 MB and testing for type and size. However, a false extension provides a false 'type' and that's what I'm trying to catch.
  • Create New...