Jump to content

DavidAM

Staff Alumni
  • Posts

    1,984
  • Joined

  • Days Won

    10

Everything posted by DavidAM

  1. DavidAM

    QUERY Hell

    In your original post, you are assigning the INSERT SQL string to a variable, and then you immediately overwrite that variable with the SELECT SQL string. YOU NEVER EXECUTED THE INSERT. So there is nothing to SELECT when you DO execute the SELECT statement.
  2. That's one reason I always use compound words for column names, i.e. "ShowCount". It is much more unlikely to be a reserved word (and unlikely to become a reserved word in a future release). And never, never let any tool put backticks in your CREATE TABLE statements (I still build mine by hand), if the CREATE had failed you would have solved this problem hours ago.
  3. See the difference?
  4. They style themselves as a "school" (it's in the name), and they named the site in a way to imply (intentional or not) a relationship with the Consortium (W3C) that defines the standards. Then the don't keep their curriculum up-to-date. Any school that fails to keep their curriculum up-to-date is not worth "attending". Especially in the technology sector, teaching past "facts" that have changed, does not benefit the "students". We, the members of this community, have had to "un-teach" the practices taught by that site, enough that we warn people away from it. If you want to ignore those warnings, on your head be it. At the very least, you now know that you need to take those teachings "with a grain of salt"; and when developing code using that site as a resource, problems you have may be the result of misinformation.
  5. (emphasis added) +1 -- And remember w3schools has absolutely no relationship with W3C! It (w3schools) is an independant website that can't even be bothered to keep their content accurate and uptodate.
  6. 1) Turn on error reporting (at the beginning of each script) so you can see if there are any warnings or notices causing problems: error_reporting(E_ALL); ini_set('display.errors', 1); 2)Make sure session_start() is called in each script before trying to reference data in the session 3) Current versions of PHP have register_globals OFF, so $username and $password are not going to exist unless you set them in some code you did not show. You have to get those values from the $_POST array: $username = $_POST['username']; 4) Depending on your ini settings, the SESSION may not carry across subdomains (www.mydomain.com/login vs mydomain.com/home) or across subdirectories (mydomain.com/subdir/login vs mydomain.com/otherDir/showArticle
  7. Congratulations, Christian! Welcome to the club.
  8. If you installed XAMP on Windows, then you have PHP installed on Windows. I have LAMP running on a Windows 7 machine at work -- I don't recommend Windows for this either, but that's what I have to work with there. I run PHP scripts from the command line (command prompt) all the time. I have even put a couple in the Task Scheduler.
  9. What is the name of the script file that is being loaded by the server? Is it "sat" as shown in the url? Or is it index.html (in the sat directory)? Or is there some mod_rewrite going on? Unless the server is specifically configured otherwise, only files ending with .php will be executed as PHP scripts.
  10. Are you certain the username and password are valid for the server? Does the user have INSERT/UPDATE/DELETE/SELECT Privileges in the database? ... for the tables? You need to echo or log the mysql_error() message if the connection fails, or a query fails. It will tell you why it failed.
  11. You can run PHP scripts from the command-line as well --- no Apache needed.
  12. Did you test base64_decoding the data and then displaying the image right after retrieving it? The encode/decode process should not change the image one iota. Just to confirm, write the raw image data to a file, then encode it, decode it, and write the processed image data to a different file. The two files should be identical. Be aware, that besides the "send_long_data" and the packet size settings for the database server (and client), you have to consider the size of the data coming back from the database server as well. Conceptually, I understand this process; but I don't store large binary data in the db, so I don't have a lot of experience with it. I'm pretty sure I did it once, just to play with the concept, but I don't think I have any of that code laying around, or know where to start looking for it. If you know the data is good when you retrieve it, you could use the mysql command-line, or phpmyadmin, to retrieve the row, copy the encoded data, stick it in a short script to decode and display it, and see if that is good. This will confirm that the stored data is correct. How is the image column defined? A BLOB or TEXT column will hold only 2^16 bytes (roughly 64K). So it will need to be a MEDIUMBLOB or larger to hold 300K Christian is correct, again, the problem could be in the retrieval process. Christian: One of us would be superfluous, then. Hey, does that mean I could take a vacation?
  13. I agree 100% with what Christian F. said (for a change ). But, I have to ask, why are you using base64-encode to store the data? That increases the amount of data to be stored by about 37% - so a 300KB image will take about 411KB of space in the column -- plus the standard column / table overhead. If you must store image data (or any other binary data) why not just store it as, oh, I don't know ... binary data? (Google "BLOB" -- Binary Large Object)
  14. You can not bind Table names or Column names to/in a prepared statement.
  15. (emphasis added) from the mySql 5.0 Manual Considering mySql is at 5.6, using 5.0 is not a real good idea.
  16. There are several people here --- your topic has been "viewed" 40 times. But it is next to impossible to read what your post says, and you have not posted anything to clarify that garbled text in the first post. So we all move on to other posts. Jessica at least tried to let you know that you need to provide a readable post if you expect any answers. You could post a reply with the complete readable text of your problem. :soapbox: Am I the only person who has the "Preview Post" button on this site? I am constantly shocked and appalled by the horrific posts that would have been obvious garbage if the user had only used the "Preview Post" button to see what it would look like, and check for spelling / grammar errors :soapbox:
  17. You could do it in the query (assuming the column is defined as a TIME datatype): SELECT IF (TIME(NOW()) < ColumnName, TIMEDIFF('24:00:00', TIMEDIFF(ColumnName, TIME(NOW()))), TIMEDIFF(TIME(NOW()), ColumnName)) AS `TimeDiff` FROM TableName There are probably half-a-dozen ways to do it in PHP, but I think doing it in the query is more efficient.
  18. You are checking to see if the database column is an integer value of zero if ($row['pic2'] == 0 ) { then you are using the value of the database column as a file name string $file2 = $row['pic2']; You should probably just test to see if the column is empty: if (empty($row['pic2'](( {
  19. Variables are not interpreted inside a single-quoted string; only in double-quoted strings. Also, you have to use curly-braces for complex variables in a string (i.e. an array element) And, you need quotes around the value (for HTML) echo "<input type='radio' name='character' value='{$data[0]}' /><br />";
  20. She's talking about the PHP string (not the mySQL string value) This statement: $new_admin_create_account = "INSERT INTO /*$dbprefix*/users (username, password)". "VALUES ('{mysql_real_escape_string($new_admin_username)}',". "'{mysql_real_escape_string($new_admin_password)}');"; is building a string. This part "VALUES ('{mysql_real_escape_string($new_admin_username)}'," is a string (literal). While you can use variables inside a (double-quoted) string, you can not use a function inside a string. You have to break the string assignment up and concatenate the function's return value. $new_admin_create_account = "INSERT INTO users (username, password)" . "VALUES ('" . mysql_real_escape_string($new_admin_username) . "'," . "'" . mysql_real_escape_string($new_admin_password) . "');";
  21. Each "page" is a separate request to the server. So, every page that needs to access the session data must start a session. The "second" (and subsequent) pages will end up with the "session" that was started on the first page. So, yes, it does make it seem like "start" is the wrong verb to use here. But that's the way it is. And if someone goes straight to the "second" page, without accessing the first page, then that page will actually "start" the session (so maybe "start" is the right verb to use here).
  22. If you want to store the image on the same server that is generating the image, you do not "upload" the image --- it is already there. You just need to store or copy the image to where you want it. This part of the code: appears to be placing the image in a file in the $PNG_TEMP_DIR. You should be able to copy or move the generated file to your images directory. On a side note, unless there is some code somewhere to clean out that temporary directory, it is going to collect a lot of files. I would recommend cleaning it out periodically (with a cron job).
  23. @salathe: I did not realize that. I almost never use double-quoted strings. But I see you are correct, this code produces an "Undefined variable" notice. Yet another reason to avoid double-quoted strings. And to make sure error reporting is on during development.
  24. mySql does not treat the $-sign specially. However, if you happen to have a PHP variable named $GGGabcd (you should change the name to something meaningful), PHP will interpret the variable when you include it in a double-quoted string. Use single quotes: $_SERVER['argv']['1'] = '$GGGabcd';
×
×
  • 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.