-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
query2 should insert based on last insert id in query1
PFMaBiSmAd replied to turpentyne's topic in PHP Coding Help
Your second query is failing because usage is a reserved mysql keyword. You can use mysql_error to get php/mysql to tell you why a query is failing and at what point in the query mysql found a problem. -
Most likely output_buffering is turned on, on your development system, which would allow your code to 'work' on the development system and on a server that also have the same setting turned on. If so, you should turn is off ASAP so that the code you develop will work regardless of server settings. Posting the error message, since is shows where the output is occurring at, would help pin down exactly what is causing the problem (it can also be due to the BOM (byte order mark) characters that could be present in your online files, but not in your development files.)
-
I assume you mean when using a print_r or var_dump statement? If so, use <pre> </pre> tags around the output to get the \n new-lines that are part of the output to cause new-lines to be displayed.
-
^^^ The above line of code means that one instance of your database class cannot perform a second query until you are done using the data from a previous query. You would either need to make a second instance of your database class or rewrite your code so that the result resource is returned to the calling code, which assigns it to a program variable and that calling code then simply uses that program variable in the mysql_xxxxxx statements that expect a result resource.
-
The error message is most likely because your database class does not return a result resource/result object to the calling code, but instead holds the result of the query internally. This means that it cannot execute more than one query at a time and each query overwrites the result of the previous query. What's the code of your database class?
-
Changing field name when MySQL information is dumped into a CSV
PFMaBiSmAd replied to skateme's topic in PHP Coding Help
The alias names only exist in the result for the query that contains the alias names. You could use mysql_field_name to get those names after you execute that query (there's no need for a separate SHOW COLUMNS ... query) - <?php $values = mysql_query( ... ... ); $i = 0; while ($i < mysql_num_fields($values)) { $names[] = mysql_field_name($values,$i); $i++; } $csv_output = implode(',',$names) . "\n"; // implode the names // your while(){} loop to retrieve the data from the query would go here... while( ... ... ){ } -
Changing field name when MySQL information is dumped into a CSV
PFMaBiSmAd replied to skateme's topic in PHP Coding Help
A) Your database columns should already be descriptive, B) You can use alias names in the query (i.e. SELECT field1 as Name, ...), C) You can use a lookup array in your php code to map the column names to your display name. -
Do you have a key defined in the table so that the ON DUPLICATE KEY part would have something to test to determine if the INSERT should be used or if the UPDATE should be used?
-
You would use an INSERT .... ON DUPLICATE KEY UPDATE ... query. See the example in this post - http://www.phpfreaks.com/forums/index.php?topic=354126.msg1672540#msg1672540
-
Getting a simple contact form past spam filter?
PFMaBiSmAd replied to Zola's topic in PHP Coding Help
The 4th parameter in the mail function call would need to be the $headers variable, not the $from variable. -
Functions being called multiple times when header is set
PFMaBiSmAd replied to patawic's topic in PHP Coding Help
Further to the above, as to why it acts differently with and without the header(), I have not specifically seen that problem, but it's most likely due to how the browser is referencing or caching the dynamically produced image or even how you are testing (do you even have a web page with an <img tag that is referring to that dynamically produced image) and it would likely take having enough of your calling code to reproduce the problem to specifically help. -
Functions being called multiple times when header is set
PFMaBiSmAd replied to patawic's topic in PHP Coding Help
As to your actual problem, FF is known to request pages twice when you are using the firebug addon and also when the web page character set encoding is different from the default character set in the browser's settings. You also might have some invalid html in the <img tag you are using to request that script or you might have some url rewriting or redirecting that is causing this, that only affects FF. If the problem is not due to something that you have control over in the markup of your page or on your server, you will need to detect duplicate requests in the script and prevent additional calls to the updateStats function (you would still need to output the image so that the image itself will be displayed.) You would typically identify something about the request that would be the same for duplicate requests, such as the $_GET parameters being the same, but would change or have a different value for that particular visitor when the request should cause the updateStats function to be called again. You would store the values in $_SESSION variables and test those session variables on each request to determine if the updateStats function should be called on any particular request. If you have multiple <img tags on one page that target that script, you would need to use arrays for the $_SESSION variables so that the code would be able to remember and test the data from the multiple sets of requests for any one visitor. -
Functions being called multiple times when header is set
PFMaBiSmAd replied to patawic's topic in PHP Coding Help
The following is completely off topic, but all the logic in your updateStats function can be replaced with one single query by setting up the gamertag and Type columns as a unique composite key - <?php function updateStats($gamertag, $type, $size) { $query = "INSERT INTO loadstats (Gamertag, Type, Loads, Data) VALUES ('$gamertag','$type',1,$size) ON DUPLICATE KEY UPDATE Loads = Loads + 1, Data = Data + $size"; mysql_query($query) or die(mysql_error()); } -
A) Are any thumbnails getting created? B) How about downloading the source images to your development system, creating all the thumbnails, and uploading the thumbnails to the live server.
-
Add the following two lines of code immediately after the first opening <?php tag to see if there are any php detected errors - ini_set("display_errors", "1"); error_reporting(-1);
-
A) What size file are you uploading? B) What does a phpinfo statement show for the post_max_size setting? C) What does a phpinfo statement show for the file_uploads setting?
-
Your previous thread had this, along with a specific line of code for the addclient.php example -
-
I just re-downloaded the .zip source of that class and someone has corrected at least the incorrect include file name and the incorrect class name in the comment that is serving as the documentation on how to instigate the class and pass it an instance of a PDO class. However, they did not update any of the other information in that repository site to indicate that they even did this. Simply, sloppy. You put the database details in when you make an instance of the PDO class (if you don't understand the PDO class, stop now and go read that section in the php.net documentation.) The dbname=mydb, host=localhost, user, and pass are the database name, hostname, database username, and database password values in the following line of code -
-
You have got to be kidding. You marked that other thread as being solved. Both kicken and I posted code to use. I even pointed out some errors in the example code (you have got to ask yourself if the example code and comments in the script are so poor, how good can the code in the class be) and posted the exact changes that you needed to try. If you didn't get it to work, there's absolutely no point in starting a new thread for the same problem without providing any new or actual information about what problems, errors, or symptoms you are getting and what your exact code is that you tried. We cannot help you based on you simply stating you cannot get something to work and repeatedly bumping a thread. For all we know, it's not working for you because you don't have any PDO driver installed. Do you have any actual information that you can supply that would allow someone to actually help you? What have you done to debug what the code is actually doing? What symptoms or errors are you getting?
-
You cannot output two different things (content types) in the response back to a browser. You can either output a html/text page (the html <img ...> tag) or the force download headers/image data. You cannot output both in one response. What exactly are you trying to accomplish?
-
Using the 'Less Than' symbol in query problem
PFMaBiSmAd replied to mat3000000's topic in MySQL Help
You cannot use values that are derived in the SELECT clause, in the WHERE clause, because they don't exist when the WHERE clause is used (to determine which rows are in the results set.) You would need to use HAVING `distance` < 80 -
Correct way to check for boolean values returned from mysql_result
PFMaBiSmAd replied to RedRocky's topic in MySQL Help
If your query is failing with an error, there's no point in trying to use the data. You would need to find and fix whatever problem is causing the query to fail and enclose the code that uses the data from the query inside of logic so that you only access the data when the query executes without any error. -
AND is a logical operator that logically and's the left and right operands together to produce a value. A comma , separates items in a list.