-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Posts posted by PFMaBiSmAd
-
-
You should only exit()/die() on fatal errors where you don't want to display the rest of your page.
You need to design your logic differently. Rather than exit() use if/else logic to surround your code so that it only executes the portion that you want, then when any block of code is complete, you can continue with the rest of the page, including your footer.
-
Your php code is outputting that. You would need to post the php code to get help with what it is doing.
-
The extra character is probably the newline at the end of each line from the file. The last line in the file probably does not have a newline after it.
You can add the FILE_IGNORE_NEW_LINES flag as the second parameter in the file() function call to have the newline characters stripped off -
$chars = file('file.txt',FILE_IGNORE_NEW_LINES);
-
Firstly, the purpose of a programming help forum is for people to learn and to help others with the same problem. So please post the solution to the original problem so that someone who finds this thread and has the same symptoms will be able to see if your solution would help him solve his problem.
For your current problem, you are obviously doing something in a non-standard way. You would need to post your main file and the file being included, along with their file names/extensions to get any specific help with what it is doing.
We need to see the big picture of what you are actually doing in order to be able to help you without playing a game of 20 questions.
-
You would need to post examples of your data in $query1['Date'], the expected results, and the actual results. Basically, nothing in the posted code would account for a nonexistent date, so you would need to show what your data is.
-
First of all $_GET is not dependent on register globals to work and you should in fact turn register globals off (register globals are completely eliminated in PHP6 and php.net turned them off by default in php4.2 in the year 2002. No new code, tutorials, books... should have been written after then that relied on register globals being on.)
However, either something your code is doing is clearing the $_GET values or because register globals are on, they (the $_GET variables) are being overwritten by another variable with the same name $f or $d.
-
On the page, use their id and query the database for their record. If the query returned a row, put the values into the value="..." parameters in the form.
When they submit the form, use their id and query the database for their record. If the query returned a row, they already have a row and you need to perform an UPDATE query. If the query did not return a row, you need to perform an INSERT query.
Pretty basic if() {// a row was found, do an UPDATE } else {// no row found, do an INSERT } logic -
if(mysql_num_rows($result) > 0) { // They already have a record, use an UPDATE query } else { // They don't have a record, use an INSERT query. }
-
Make the "button" in the href link using CSS - http://www.dynamicdrive.com/style/csslibrary/item/3d-css-buttons/
-
Each call to a mysql_fetch_xxxxx() function only fetches one row from a result set, like the php manual states. To fetch all rows from a result set, you would need to use something like a while() loop to iterate over the result set, like the mysql examples in the php manual.
-
There is an install.txt file in there that has instructions for just about every possible combination of operating system and web server. The same information can be found in the installation section in the php manual. Find, read, and follow the instructions that apply to your operating system and web server.
-
Actually I see that I left off an "as cnt" alias, which would have generated a syntax error in the ORDER BY clause, so it is unlikely that the code you executed was the code you just posted. It should not have given the same error as before.
Here is the corrected code I meant to post -
$query="SELECT ratings_winner, count(*) as cnt FROM `ratings` WHERE ratings_winner=$user"; for ($i=0; $i<count($friends);$i++) { $query = $query . " OR ratings_winner=" . $friends[$i]['uid']; } $query .= " GROUP BY ratings_winner ORDER BY cnt DESC LIMIT 0 , 15";
I just tested both your original query and the one I gave, and in mysql 5.0.45, they both work without any mysql error.
My guess at this point is that your version of mysql does not support the combination of GROUP BY and ORDER BY.
-
The last question is easy. Yes there is -
Magic constantsPHP provides a large number of predefined constants to any script which it runs. Many of these constants, however, are created by various extensions, and will only be present when those extensions are available, either via dynamic loading or because they have been compiled in.
There are five magical constants that change depending on where they are used. For example, the value of __LINE__ depends on the line that it's used on in your script. These special constants are case-insensitive and are as follows:
Table 13.1. A few "magical" PHP constants
Name Description
__LINE__ The current line number of the file.
...
-
The following part of the code is where the query is formed -
$query="SELECT ratings_winner FROM `ratings` WHERE ratings_winner='$user'"; for ($i=0; $i<count($friends);$i++) { $query = $query . " OR ratings_winner=" . $friends[$i]['uid']; } $query .= " GROUP BY ratings_winner ORDER BY count( ratings_winner ) DESC LIMIT 0 , 15";
To make the changes that I believe will fix this, change those lines to the following (I also removed the single-quotes around the first value ) -
$query="SELECT ratings_winner, count(*) FROM `ratings` WHERE ratings_winner=$user"; for ($i=0; $i<count($friends);$i++) { $query = $query . " OR ratings_winner=" . $friends[$i]['uid']; } $query .= " GROUP BY ratings_winner ORDER BY cnt DESC LIMIT 0 , 15";
-
The mysql error - Invalid use of group function - is most likely occurring because the count() function is being used in the ORDER BY clause.
If your query was as follows, it should work -
SELECT ratings_winner, count(*) as cnt FROM `ratings` WHERE ratings_winner='634794851' OR ratings_winner=305300379 OR ... all the OR'ed values, removed for clarity ... GROUP BY ratings_winner ORDER BY cnt DESC LIMIT 0 , 15
I just noticed in the query that the first ratings_winner = value is enclosed in single-quotes. While this will not prevent the query from working, the single-quotes should not technically be there.
-
Because your mysql_query() failed and returned a FALSE value instead of a result resource.
-
Um. This thread is exactly the same as the one gatez posted yesterday, including adding mysql_error() reporting to get what the problem with the query was - http://www.phpfreaks.com/forums/index.php/topic,169849.0.html
gatez, if you already have a thread for a problem, don't start another duplicate thread. It just wastes everyone's time getting to the point where the previous thread left off.
-
There is a 99.9% chance that it is the short php opening tag <? being used near the end of the file with the error (all the other files are irrelevant, why did you post them?)
Always use full php opening tags <?php to make your code portable between any server configuration.
-
It sounds like either the php.ini that you are making changes to is not the one that php is using or the extensions path setting in php.ini does not point to where the .dll extensions are located, or the php_mssql.dll (you had this spelled with one too many 's' in your first post) file is not present in the extensions folder.
-
The end of life for PHP4 is the end of this year, in a little more than 30 days. Your web host probably won't continue offering PHP4 for very long after that.
Your problem is not PHP4 vs PHP5 but configuration differences in php.ini and since register_globals have been eliminated completely in PHP6, you're going to need to remove any dependencies on register_globals if you want your code to keep working when PHP6 is released.
-
Check your web server log for errors and/or turn on full php error reporting in php.ini or a .htaccess file to get php to help you out. I suspect a problem with register_globals.
session_register() and session_is_registered() functions are depreciated (a long time ago) and only work when register_globals are on.
-
The IE cookie question is really very simple. Any cookie with a zero life time is kept in a cookie cache in memory (which is deleted when the browser closes.)
For the second question, as long as the browser is left open (even if you browse to a different site) the session cookie is kept alive. However, if the session garbage collection runs on the server and deletes the corresponding session data file, then the session cookie would no longer have a corresponding session data file when the browser fetches a URL at your site.
-
Seeing a visual representation of the data as an array (so you can see the indexes), the way php sees it, will probably help. See the following print_r() code added to your code and I believe the two foreach() loops that do what you want -
<?php $PAT_ID = '1145566'; $xmlstring = file_get_contents("patients.xml"); $xml = new SimpleXMLElement($xmlstring); echo "<pre>"; print_r($xml); echo "</pre>"; foreach ($xml->Patient as $Patient) { foreach($Patient->Study as $Study) { if (strtolower($Study->PatientID) == "$PAT_ID") { $sid = $Study->StudyCode . "</p>"; echo($sid); } } } ?>
-
Get mysql to help you find what is wrong by putting some error checking and error reporting on the mysql_query() function call.
$result = mysql_query($query) or die("Query failed: " . mysql_error());
-
The only way to get information from a browser to a server is to make a HTTP request to the server and include that information as part of the request.
The ways of making a HTTP request are a form that is submitted (POST or GET), a URL that is requested (GET), or using AJAX techniques (POST or GET.)
[SOLVED] Extranious </body></html>
in HTML Help
Posted
I didn't find any output being done in that code either (even the $message variable is getting set in a number of placed but is never used.)
That leaves something in the configuration.php file itself or something the DBConnect() function code is doing.