Re: [PHP-DB] Hello
HI, Thanks for your response. Here is my query. UserID is auto incrament and UserLastLogin is a current_timestamp. $query_users = "INSERT INTO users(UserID, Username, UserEmail, UserPassword, UserFirstName, UserLastName, UserCompany, UserAddress, UserAddress2, UserCity, UserState, UserCountry, UserZip, UserPhone, UserFax, UserEmailVerified, UserRegistrationDate, UserVerificationCode, UserIP, UserLastLogin) VALUES('NULL','".$Username."','".$UserEmail."','". $UserPassword."','".$UserFirstName."','".$UserLastName."','". $UserCompany."','".$UserAddress."','".$UserAddress2."','". $UserCity."','".$UserState."','".$UserCountry."','".$UserZip."','". $UserPhone."','".$UserFax."','".$UserEmailVerified."','". $UserRegistrationDate."','".$UserVerificationCode."','".$UserIP."', now())"; This works as far as populating the database, but my results page does not return anything. Only if the VALUES is set like this: VALUES('NULL','".$Username=$_POST['Username']."','".$UserEmail=$_POST ['UserEmail']."','".$UserPassword=$_POST['UserPassword']."','". $UserFirstName=$_POST['UserFirstName']."','".$UserLastName=$_POST ['UserLastName']."','".$UserCompany=$_POST[$UserCompany]."','". $UserAddress=$_POST['UserAddress']."','".$UserAddress2=$_POST ['UserAddress2']."','".$UserCity=$_POST['UserCity']."','".$UserState= $_POST['UserState']."','".$UserCountry=$_POST[$UserCountry]."','". $UserZip=$_POST['UserZip']."','".$UserPhone=$_POST['UserPhone']."','". $UserFax=$_POST[$UserFax]."','".$UserEmailVerified=$_POST [$UserEmailVerified]."','".$UserRegistrationDate=$_POST [$UserRegistrationDate]."','".$UserVerificationCode=$_POST ['UserVerificationCode']."','".$UserIP=$_POST[$UserIP]."', now())"; but some do not work with this setup. variables like $UserEmailVerified, $UserRegistrationDate and $UserIP are not created from the form that was submitted. for example, User IP date is created like this. $UserIP = md5($_SERVER[REMOTE_ADDR]); - Below is a snip of how I retrieve the info on the result page (dont want to clutter with whole code. also $fieldOne etc are MySql wildcards '%' from some dropdown lists that show before this code is executed. The results from adding show up fine there.) $query_users = "SELECT * FROM users WHERE UserID LIKE '$fieldOne' AND Username LIKE '$fieldTwo' AND UserEmail LIKE '$fieldThree' AND UserPassword LIKE '$fieldFour' AND UserFirstName LIKE '$fieldFive' AND UserLastName LIKE '$fieldSix' AND UserCompany LIKE '$fieldSeven' AND UserAddress LIKE '$fieldEight' AND UserAddress2 LIKE '$fieldNine' AND UserCity LIKE '$fieldTen' AND UserState LIKE '$fieldEleven' AND UserCountry LIKE '$fieldTwelve' AND UserZip LIKE '$fieldThirteen' AND UserPhone LIKE '$fieldFourteen' AND UserFax LIKE '$fieldFifteen' AND UserEmailVerified LIKE '$fieldSixteen' AND UserRegistrationDate LIKE '$fieldSeventeen' AND UserVerificationCode LIKE '$fieldEighteen' AND UserIP LIKE '$fieldNineteen' AND UserLastLogin LIKE '$fieldTwenty' LIMIT $min, $max_results"; $result = mysql_query($query_users) or die(mysql_error()); for($i = 1; $i <= $num_sql; $i++) { $r = mysql_fetch_array($result, MYSQL_ASSOC); $UserID = $r['UserID']; $Username = $r['Username']; $UserEmail = $r['UserEmail']; $UserPassword = $r['UserPassword']; so I have 3 pages. one adds the users, the next reviews and the last shows the results of what is picked. Thanks, Karl -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Hello
I don't quite understand what your problem is but it looks as if some fields of the records that show up in phpMySql are empty and that the result page that you have built does not show them. If that is the case, is there a where clasue that causes them to not return? Can you run the query that is on your result page in phpmysql and see what it returns. Jack 2009/12/14 Karl DeSaulniers > Hi I am new to this list. > I am in need of some help or direction. > I am new to php and databases, so forgive me if my request seems too > simple. > > I am making a database if users and have had much success in getting it to > work however, not all my data is getting shown once I try to display > results. I am running an INSERT query that inputs data into the database > from a form. But here is the hiccup. I am asigning the form data to a > $variable. > > Eg: $Username = $_POST['Username']; > > I then run $Username through some checks to make sure it's not an > injection. After all that I want to insert it into the database. This works > fine if I use: > > $query = "INSERT INTO users (Username, UserEmail, etc) > > VALUES ('".$_POST['Username']."', '".$_POST['UserEmail']."', etc)"; > > And it works if I use > > VALUES ('".$Username."', '".$UserEmail."', etc)"; > > However I have some variables that are not posted from the form and in the > first example, it does not insert those in the database. > > In the second, it will insert them into the database, but when I go to > display them it is saying there are no records to retrieve. I looked at > the database in phpMySql and they are there. It will only display them in > the results page if they had been inserted using $_POST. Is this normal? > What is the best way to $_POST a $Variable. Something like > $_POST[$Username] (which doesn't work). > > Any help would be greatly appreciated. > Thanks, > > Karl > Design Drumm > > Sent from losPhone > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Jack van Zanen - This e-mail and any attachments may contain confidential material for the sole use of the intended recipient. If you are not the intended recipient, please be aware that any disclosure, copying, distribution or use of this e-mail or any attachment is prohibited. If you have received this e-mail in error, please contact the sender and delete all copies. Thank you for your cooperation
[PHP-DB] Hello
Hi I am new to this list. I am in need of some help or direction. I am new to php and databases, so forgive me if my request seems too simple. I am making a database if users and have had much success in getting it to work however, not all my data is getting shown once I try to display results. I am running an INSERT query that inputs data into the database from a form. But here is the hiccup. I am asigning the form data to a $variable. Eg: $Username = $_POST['Username']; I then run $Username through some checks to make sure it's not an injection. After all that I want to insert it into the database. This works fine if I use: $query = "INSERT INTO users (Username, UserEmail, etc) VALUES ('".$_POST['Username']."', '".$_POST['UserEmail']."', etc)"; And it works if I use VALUES ('".$Username."', '".$UserEmail."', etc)"; However I have some variables that are not posted from the form and in the first example, it does not insert those in the database. In the second, it will insert them into the database, but when I go to display them it is saying there are no records to retrieve. I looked at the database in phpMySql and they are there. It will only display them in the results page if they had been inserted using $_POST. Is this normal? What is the best way to $_POST a $Variable. Something like $_POST [$Username] (which doesn't work). Any help would be greatly appreciated. Thanks, Karl Design Drumm Sent from losPhone -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Mysql query
The query from my previous post was only part of a larger query. This is the entire query: SELECT GREATEST( IF( CURDATE( ) >= DATE_SUB( DATE( FROM_UNIXTIME( 1239508800 ) ) , INTERVAL LEAST( 14, ( SELECT COUNT( * ) FROM `verse_of_the_day_Bible_verses` WHERE seasonal_use =1 ) ) DAY ) AND CURDATE( ) <= DATE( FROM_UNIXTIME( 1239508800 ) ) , 1, 0 ) , IF( CURDATE( ) >= DATE_SUB( DATE( 2009 -12 -25 ) , INTERVAL LEAST( 14, ( SELECT COUNT( * ) FROM `verse_of_the_day_Bible_verses` WHERE seasonal_use =2 ) ) DAY ) AND CURDATE( ) <= DATE( 2009 -12 -25 ) , 2, 0 ) ) AS verse_application The result should be a "2". I am getting a 0. When I try the first subquery / IF statement the error message is: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF( CURDATE( ) >= DATE_SUB( DATE( FROM_UNIXTIME(1239508800) ) , INTERVAL LEAST( ' The error message for the Christmas check which should be giving me a "2" result is: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF( CURDATE( ) >= DATE_SUB( DATE( 2009 -12 -25 ) , INTERVAL LEAST( 14, ( SELE' at line 1 Any help out there please? Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Mysql query
Does anyone see anything wrong with this query? Do I have one of the >, = or < mixed up? The purpose is to figure out if it is within 14 days of Christmas AND if there is content for Christmas available. 2 is symbolic in the database being Christmas. Ron IF( CURDATE( ) >= DATE_SUB( DATE(2009-12-25) , INTERVAL LEAST( 14, ( SELECT COUNT( * ) FROM `verse_of_the_day_Bible_verses` WHERE seasonal_use =2 ) ) DAY ) AND CURDATE( ) <= DATE(2009-12-25) , 2, 0 ) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php