-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
Pulling user/pass from a different database to store in a session.
PFMaBiSmAd replied to Lostnode's topic in PHP Coding Help
You should be developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON so that all the php errors in your code will be reported and displayed. You will save a ton of time. The code using the connection is inside of a function. You need to pass the connection into the function as a parameter in the function call to make it available inside of the function. This will allow the function to be reused for any connection without needing to keep editing the function definition. The way the code is doing this now is using global $conn;, which you failed to take into account when you altered the code. -
Pulling user/pass from a different database to store in a session.
PFMaBiSmAd replied to Lostnode's topic in PHP Coding Help
Is your code including the connect.php file? Are you closing the connection at any point prior to that code? You have posted just a few lines of your code taken out of context. That doesn't provide enough information to help you with what the rest of your code is doing that would cause the error. You need to post all your code from the first line of the main file being requested, all the way up to the line with the error, and any include/require files being used between those two points. -
Rearranging my DB. (Simple question for some…)
PFMaBiSmAd replied to DBookatay's topic in MySQL Help
Untested, but should work - UPDATE your_table SET sold_date = CONCAT(IF(sold_date3 IN ('98','99'),'19','20'),sold_date3,'-',sold_date1,'-',sold_date2) WHERE sold_date != '0000-00-00' AND sold_date1 !='' AND sold_date2 != '' AND sold_date3 != ''; Edit: I just tried that query and the sold_date != '0000-00-00' logic is backwards. It should be sold_date = '0000-00-00' -
In looking at the whole code, you also need to do the following - 1) Add some conditional logic to check if the form was submitted before executing the INSERT query. The code currently unconditionally executes the INSERT query every time the page is requested. 2) Validate and escape the data that is being put into the query. Had you been validating each expected value, you would have gotten further indication that they were all empty and you would not have been executing the query with empty values.
-
^^^ Don't do that. Turn them back off. Register_globals was the worst security hole that was deliberately added to any programming language. Any php coding that you learn that is dependent on register_globals will leave you 8 years behind in php code development. You should be learning php, developing php code, and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that all the errors that your code is producing will be reported and displayed. This will help you find the variables in it that are dependent on register_globals.
-
There's no code in your code setting the $sitename, $meta_description, $meta_keywords, $site_email, and $your_name variables, so of course they are all empty. Since your form is using the GET method (the default when no method="..." is specified), you would need to use the correct $_GET['...'] variables to reference the data from the form. Edit: I would add that you should be learning php, developing php code, and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON so that all the errors that your code is producing will be reported and displayed. There would have been undefined error messages for those variables alerting you to the fact that they are not being set by the code.
-
What is line 37 of your code? And you do know that you don't need to keep coping your $_SESSION['items'] to/from another variable $items?
-
I'm going to guess that your data is empty due to a logic error and that's why you are attempting to insert a (duplicate) empty value. Posting all your code responsible for producing (reproducing) the symptom is the quickest way to get a solution as to what your code is doing.
-
Finding the highest and lowest number in an array?
PFMaBiSmAd replied to merylvingien's topic in PHP Coding Help
I have 3 questions - 1) Why do you have an or die() on the end of your $sql = "..." statement? Assigning a string to a variable will always be TRUE and the or die() will never do anything. The or die() should be on the mysql_query() statement. 2) Why do you have $row = @mysql_fetch_array($result); as the 3rd line in the posted code? It is fetching a row from your results set before you start looping over the result set. 3) Why do you have @ in front of the mysql_fetch_array() statements? That just hides errors. You need to know which statements are producing errors so that you can find the problems in your code. Hiding error messages does not fix your code. Your code still won't work AND you won't be getting any errors to help you find where and what the problem is. Don't put any @ in code (ever.) There is really no need. -
The $query = "..."; line is missing the ;
-
The $content1 that you are putting into the alert() box is breaking the Javascript syntax. If you are trying to style the alert box/contents, you need to do something like - http://javascript.internet.com/miscellaneous/custom-alert-box.html
-
$result2 will be a result resource if the query executed or it will be a false value if the query failed due to an error. A query that matches zero rows is a successful query. You need to use mysqli_num_rows($result2) to check how many rows are in the result set.
-
Rearranging my DB. (Simple question for some…)
PFMaBiSmAd replied to DBookatay's topic in MySQL Help
The query would look something like (test it first on a sample of your data to be sure) - UPDATE your_table SET sold_date = CONCAT('20',sold_date3,'-',sold_date1,'-',sold_date2); -
Rearranging my DB. (Simple question for some…)
PFMaBiSmAd replied to DBookatay's topic in MySQL Help
You would form a single UPDATE query * that uses the mysql CONCAT() function to take the three existing column values and produce the value that you set the new column to. * An update query without a WHERE clause will match all the rows in your table and update every row by executing the query once. -
If you post the code, like someone asked, you can probably get an answer 10x faster.
-
Edit: Basically the same as above ^^^^ What makes you think they are not working? What is your code and the symptoms?
-
can i hide my address using mail function?
PFMaBiSmAd replied to rich_traff's topic in PHP Coding Help
You would either write your own script to open a socket connection to the destination mail server and exchange SMTP commends with it, including the SMTP Authorization command, or you would use one of the existing php mailer classes to do this for you. By using SMTP Authorization, the php script 'looks' like an authenticated email client (i.e. outlook) and you can send an email directly to the email account that you have authenticated against, in the same way you would use outlook to send yourself an email to your own inbox. The phpmailer and swiftmailer are two of the more popular php mailer classes - http://phpmailer.worxware.com/ and http://swiftmailer.org/ -
That warning contains a link to BC math functions that don't suffer from floating point conversion errors (because the numbers are operated on as BCD digits.)
-
Please read the big pink WARNING at this link - http://www.php.net/manual/en/language.types.float.php
-
Is the form on the same page as the php code so that any php errors would be seen?
-
Or you can just do that ^^^ (onclick)
-
There are examples posted all over using strtotime() and date()
-
Actually, it kind of works in IE, when you un-select one or select the opposite, you get the value from the other one to be sent. The problem is because when you click one radio the other one becomes un-selected and both fire the onchange event. See the JPnyc 08-24-2005, 12:51 PM post at the following link for how you would need to test which radio button became the selected one and only set the value for that one and submit the form for the radio that became set, not the one that became unset - http://www.phpbuilder.com/board/archive/index.php/t-10307334.html
-
The @ on the copy() statement is hiding any php errors that would tell you why it is failing. Code should never have @ in it to hide errors (there's no need anyway because you would have display_errors set the way you want to show or not show error messages to the client.)
-
You can do this directly in your query - http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format It is about 8-10x faster to do this in your query when you retrieve the data than if you use some php code to do this.