-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
FifeBirder, those are just two different ways of forming strings in php, except that the second way (concatenation, using a lot of extra opening/closing quotes and dots) usually results in more syntax errors.
-
Register script function not inserting into database?!
PFMaBiSmAd replied to jarv's topic in PHP Coding Help
Each string data value must be enclosed in single-quotes so that it will be treated as a string instead of an identifier or keyword. You should also format and store the date of birth as a DATE data type so that it is easier to work with in any query. -
New server causing phpmailer to not work ?
PFMaBiSmAd replied to swatisonee's topic in PHP Coding Help
Does the email address being put into $mail->From actually exist? -
If you used the .msi installer to install php, you must use the Windows control panel add/remove item to enabled php extensions.
-
To reuse a result set from a query, simply use mysql_data_seek to reset the result pointer to the first row. Or you could buffer the data in an array and iterate over the array.
-
Warning: mysqli_error() expects exactly 1 parameter, 0 given in
PFMaBiSmAd replied to genzedu777's topic in PHP Coding Help
I recommend you read the php.net documentation for mysqli_error(), it requires the mysqli link as a parameter. -
Just because a query executes without any errors, does not mean that it matched any rows. You should use mysql_num_rows to find out if there are any rows in the result set before you attempt to fetch the data from the result set. If you echo the $query variable, you will likely be able to see why it is not matching anything in your table (I suspect that $selected is either empty or does not match any title.)
-
cannot modify header information >< need help. - cookies
PFMaBiSmAd replied to Minimeallolla's topic in PHP Coding Help
If you read the error message you are getting, it tells you where you are sending the output at that is preventing the setcookie/header from working. You cannot send any CHARACTERS * to the browser prior to a header. * Characters are anything that is not a header. ALL of your HTML tags and css are CHARACTERS. -
^^^ By concatenating msyql_error() with the result of the mysql_query() in the above line of code, you are likely corrupting the value being put into $result. That line of code should be as follows to get it to display the mysql_error() value if the query fails - $result = mysql_query($sql) or die(mysql_error());
-
sprintf uses % characters to indicate replaceable parameters. You attempted to use a php variable $u (your overall string starts and ends with single-quotes, so a php variable anywhere in it would not get replaced with it's value.)
-
The file where your UPDATE query is being formed and executed has no code in it to set the $firstname, $lastname, $email, and $id variables, so specifically $id is empty and your WHERE clause on that query is FALSE. The query executes without any error (which is what your if($result){ code is testing for), but because the WHERE clause is FALSE, no rows are affected. Your code needs to reference the actual $_POST variables that the form data is in, test if the form was submitted before doing any processing, and validate and escape the data being put into the query.
-
Server side includes (SSI) require that your server be configured to use SSI, which typically also requires that you use a special file extension (.shtml, .stm, .shtm) on the main file. Have you confirmed that your server has been configured to use SSI and that your main file ends in the an extension that your server has been configured to use for SSI? You have also listed three different file extensions in your post for the included file - .txt, .txtl, .html You need to put the actual name into the <---#include ---> statement.
-
user login works on my localhost computer but not on my webhost
PFMaBiSmAd replied to viperjts10's topic in PHP Coding Help
I don't see anywhere in the posted code where you tried setting the error_reporting/display_errors settings to the suggested values to see if there were any problems php would point out. You would need to set them right after the first opening <?php tag in your main file. Have any session variables worked on your live server? Have you tried a simple script that just sets a session variable on one page and tests if it carries over to another page? -
If you look at the query that was echoed by that troubleshooting code, you will notice that the $year variable is empty and the WHERE clause is always FALSE, so, no rows will be returned.
-
LOL, I just looked at the 'view source' of what that code produces and got the same missing data. It's likely that the strings concatenated with the ternary operator became part of the ternary statement (the leading <td> string became part of the condition and the trailing </td> string became part of the false/empty string) and only the result of all of that was returned and echoed. In fact I just tested this by using an invalid index number with the original code. You get an invalid index error because the '<td>' string concatenated with the isset() condition results in a true value and the $lookup[$row['color']] is evaluated with a nonexistent index and produces an error. You can use echo with commas (instead of concatenation) to get it to work properly as that separates the pieces into separate operands to the echo statement and delineates where the ternary operator starts and stops - echo '<td>',isset($lookup[$row['color']]) ? $lookup[$row['color']] : '','</td>';
-
Your code won't work because you cannot output anything to the browser before a statement that uses a header, like a session_start(), a setcookie(), or a header() redirect. If the BOM characters are the problem, you must either save the file as a UTF-8 encoded file without the BOM or you must save the file as a ANSI encoded file.
-
There's a whole section in the mysql documentation addressing the "server has gone away" error. If you have a 12 minute page generation/load time, you need to find out what is causing that and fix it. You would need to post the complete code responsible for producing that problem if you want someone on the forum to help with it. ^^^ Nothing you have posted so far concerns files in your database, so again, posting your code would be the quickest way of getting help with what your code (and queries) are doing. Just having that many pieces of data in your database does not account for a long page load time unless you are retrieving all that data and looping through it using some slow parsed, tokenized, interpreted php code or you are executing queries inside of loops or you don't have necessary indexes setup in the database tables...
-
In you want to be able to lookup/convert any number of values on a page, you would build a simple key/value array (see the code in this post - http://www.phpfreaks.com/forums/php-coding-help/using-$row-and-changing-values/msg1484306/#msg1484306) If these are in a database and you are only getting one id/value on a page, you would do this in the query WHERE id = 38
-
Using nested Ternary operators does not do what you think. It is usually better to use a look up table (array) to map values - $lookup[1] = 'red'; $lookup[2] = 'blue'; $lookup[3] = 'green'; //... additional key/value pairs as needed.... echo '<td>' . isset($lookup[$row['color']]) ? $lookup[$row['color']] : '' . '</td>';
-
Functions, by definition, have their own isolated variable scope so that you can write whatever code you need in them to perform the desired function without any interference with the programs you use those functions in. The variables $format and $tzone don't exist inside your function unless you pass them in as parameters when you call the function (like your $time variable) or define them inside the function.
-
The problem is most likely due to one or more of the 300+ HTML markup errors on the page - http://validator.w3.org/check?uri=http%3A%2F%2Fwww.championtutor.com%2Ftutor_registration.php&charset=%28detect+automatically%29&doctype=Inline&group=0 The other browsers are ignoring the invalid makeup and functioning, while IE is not. I suspect the problem is due to the duplicate id's, but there are so many other errors present, I could be wrong. Before you can even begin to worry about cross-browser functionality, you must have error free markup on the page.