Jump to content

BelowZero

Members
  • Posts

    89
  • Joined

  • Last visited

    Never

Everything posted by BelowZero

  1. I'm trying to add some minutes ($interval) to any given time, but my results aren't as expected... <?php $year="2012"; $opentime="09"; $interval="10"; $thedate = "$year:01:01 $opentime:00:00"; $startdate = strtotime($thedate); $date = date("Y-m-d",$startdate); $time = date("g:i a",$startdate); $newtime = strtotime("+$interval", $time); $nexttime = date("g:i a",$newtime); echo $date; echo "<br>"; echo $time; echo "<br>"; echo $nexttime; is returning: 2012-01-01 9:00 am 7:10 pm I was expecting the last to be 9:10 am. Can someone point me in the right direction? Thanks.
  2. Duh...shoulda seen that. Works great now. Thanks!
  3. Well, now there's a new problem... It appears that my login info is being stored correctly. I have a "databasedata" file that contains: $server = localhost; $username = somename; $password = somepasswork; I include that file into my opendatabase file: include("databasedata.php"); $con = mysql_connect("$server","$username","password"); When I try to connect I get this message: (actual username and password changed) < $server = localhost; $username = somename; $password = somepassword; ?> Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'somename'@'localhost' (using password: YES) in /var/www/html/test/opendatabase.php on line 4 Could not connect: Access denied for user 'somename'@'localhost' (using password: YES) Could there be a problem with where or wherenot quotes are being used? Or could it be another problem? Thanks.
  4. New problem... It appears that all the connection data is being stored properly, but now I can't connect to the database. My databasedata file holds: $server = localhost; $username = somename; $password = somepassword; and I am including this into the opendatabase file include("databasedata.php"); $con = mysql_connect("$server","$username","password"); and I end up with this message: (actual username and password changed) < $server = localhost; $username = somename; $password = somepassword; ?> Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'somename'@'localhost' (using password: YES) in /var/www/html/test/opendatabase.php on line 4 Could not connect: Access denied for user 'somename'@'localhost' (using password: YES) I'm thinking maybe it's a problem with where or wherenot quotes are being included? Or could it be something else? Thanks.
  5. Whew...Thanks everyone! It is now saving my info as needed. Appreciate your help.
  6. Thanks scootstah. Would this be the proper syntax to use? (Variables coming from the setup page) $server = $_POST["server"]; $username = $_POST["username"]; $password = $_POST["password"]; file_put_contents("/test/databasedata.php",$server); file_put_contents("/test/databasedata.php",$username); file_put_contents("/test/databasedata.php",$password); Thanks.
  7. No, I'm still here. Just had to be out of town for awhile. This is what I'm trying to do. The program will be installed on the user's webserver. After that I will have no need for the creds, but they will still need to be stored in a way that the new user will have access to their database without having to re-enter the password every time it connects. I will try file-put-contents and see how that works. Thanks for the advice and the lively conversation.
  8. Thanks sunfighter! The repeat-x repeat-y was the problem. Appreciate your help.
  9. I need to find a way to store a password for connection to a remote database. I'm writing a program that will create a database on whatever server the user is using. Obviously, they will have to provide their username and password in order to create the database and have access to it. I need my program to get the information once (when they use the setup utility), then be able to store it so they can automatically connect to the database whenever my program is used. I plan using a php file for storage and include() to gain access to the info. I just don't have an idea for getting the information into the php file in the first place. Thanks for any ideas!
  10. I'm trying to apply a background image to a nested <div>. The result is as expected in IE9, but nothing is rendered in Safari 5.1.2 or Firefox 3.6.27. Haven't tried it in any other browser. The html is just this. I want to place a background image in "layer2" : <div id="layer1"> <div id="layer2"> <div id="layer3"> ...some code </div> <!--layer3--> <div id="layer4"> ...more code </div> <!--layer4--> </div> <!--layer2--> </div> <!--layer1--> Here is the css: #layer2 { padding:10px 20px 10px; background:url('http://www.tonalproductions.net/test/images/YCC Header.png') left top repeat-x repeat-y; border: 3px solid; border-color: #ffffff; } I've tried it with a background color and a .jpg file but nothing gets rendered. Although IE9 shows it just the way I want it. Any ideas? Thanks.
  11. Thanks for the explanation!
  12. Thanks AyKay47. I do plan on using an external style sheet in my project. But my real question is can I style the <td> in the stylesheet or should it be done inline?
  13. I'm trying to learn how to display data from my database correctly. I came across this example in my google search. <?php $array['Name'] = array('Chris', 'Jason', 'Thomas', 'John'); $array['Age'] = array('27','24','40','32'); $array['Movie'] = array('SpaceBalls','Friday 13th','Star Wars','The Matrix'); ?> <table> <tr style='border: 1px black solid;'> <th style='border: 1px black solid;'>Name</th> <th style='border: 1px black solid;'>Movie</th> <th style='border: 1px black solid;'>Age</th> </tr> <? $i= 0; while ($i <=3){ echo "<tr>"; echo "<td style='border: 1px black solid; text-align: center; width: 100px'>".$array['Name'][$i]."</td>"; echo "<td style='border: 1px black solid; text-align: center; width: 120px;'>".$array['Movie'][$i]."</td>"; echo "<td style='border: 1px black solid; text-align: center; width: 50px'>".$array['Age'][$i]."</td>"; echo "</tr>"; $i++; } ?> </table> My question is: Why did this example style the <td> inside the echo statement echo "<td style='border: 1px black solid; text-align: center; width: 100px'>".$array['Name'][$i]."</td>"; and not in the inline table styling or in a CSS stylesheet? Is this the "correct" way or just the author's choice or is there a particular reason to do it this way? I'd like to make sure I understand the programming before I write it and later discover that I'm using poor logic and technique. Any insights are appreciated. Thanks.
  14. Thank you Mahngiel. I believe that's the answer, but I'll have to wait until tomorrow to test it. I appreciate your help.
  15. People can access the database and sign up for a team. The table shows all the teams and participants. Where someone has already signed up, the table just shows that name. Where no one has signed up, there is a form where they can enter their name. Someone can sign up for Team1 or Team 50. Each time someone submits their name the database is updated. I'm looping through all the teams so the table knows whether to show the name or an input form. So for each team, I use this code: IF (empty($row[Team1])) { echo "<input type='text' size='20' value= '$row[Team1]' name='Team1[$i]'>"; } ELSE { echo $row[Team1];echo "<input type='hidden' value= '$row[Team1]' name='Team1[$i]'>"; } What I've done is copy that code over and over for each team (Team1, Team2, Team3, etc.) It's a lot of code, so I was wondering if I could use a variable for each team number. (Team$a) where $a = 1,2,3, etc. and just loop through the teams to display the data.
  16. Sorry, should have put something like this: $Team1(0)="John"; $Team1(1)="Rick"; $Team1(2)="George"; $Team2(0)="Bob"; $Team2(1)="Warren"; $Team2(2)="Bruce"; So I want to update each team in my database, but what if I had 50 teams? Do I have to write the same code for each $Team? Can I assign a variable to each number in the teams, like $Team$a[$i] (where $a=1,2,3,etc.) or something like that? Then I could just loop through the teams. Still hope that makes sense. Been a long day... Thanks.
  17. Let's say I have an array like this: Man1(0), Man1(1), Man1(2), etc. Man2(0), Man2(1), Man2(2), etc. Man3(0), Man3(1), Man3(2), etc. ... and I want to loop through the array. I know I can do: $i=0; while $i<=99 {//...do something with Man1[$i];} i++; but can I also do a loop with each Man? Like: $i=0;$a=1; while $i<=99 {//...do something with Man$a[$i];} i++;a++; I've written all the code for each Man separately and I'm thinking there's got to be a way to shorten the code with another loop, but I don't know how. Hope that makes sense. Thanks.
  18. Yes, of course. Works like a charm. Thanks Pikachu2000!
  19. I have a dropdown box filled with times in a form: <select name = "closetime"> <option>Choose One</option> <option>All Day</option> <option>7:00 am</option> <option>8:00 am</option> <option>9:00 am</option> <option>10:00 am</option> <option>11:00 am</option> How do I convert "closetime" to a time format ($closetime) that I can insert into my database? I'm assuming that at some point in the code I'll use strtotime, but I'm not sure where... Inside the option tags?, or after "closetime" has a value?, or after "closetime" is sent to a processing file? Any ideas? Thanks!
  20. Tested and working! Thanks for your help.
  21. Ahhh, so if I just moved the redirect to the bottom of the page it should work?
  22. This is where I am confused. As I understand it, the header("Location...) has to be the first line. How then do I assign a value to the variable before that?
  23. Thanks for the reply. Here is the complete code for the display/form page: <FORM Method = "POST" action ="update_tee_times.php"> <?php include("opendatabase.php"); //$dateID = $_POST[teetimedate]; $dateID = $_REQUEST[teetimedate]; echo $dateID; $closetime = "15:30:00"; $opentime = "17:30:00"; $result = mysql_query(" SELECT Date, Player1,Player2,Player3,Player4,Player5,Time, IF( TIME(Time) BETWEEN '$closetime' AND '$opentime','FFFF66','FFFFFF') AS color,Men,Women,Guest FROM Daysheets WHERE Date ='$dateID'"); echo "<h1>"; echo date("l: F d, Y", strtotime($dateID)); echo "</h1>"; echo "<table align=center width=700 border=1>\n"; echo "<th>Time</th><th>Player 1</th><th>C</th><th>Player 2</th><th>C</th><th>Player 3</th><th>C</th><th>Player 4</th><th>C</th><th>Player 5</th><th>C</th><th>M</th><th>W</th><th>G</th><th>Clear</th>"; $i=0; while($row = mysql_fetch_array( $result )) { $dateID = $row['Date']; $timeID = $row['Time']; echo "<tr>"; echo "<td>"; echo date("g:i ", strtotime($row[Time])); echo "</td><td>"; echo "<input type='text' size='16' value= '$row[Player1]' name='player1[$i]' style ='font-size: 11px; background-color:#{$row['color']};'>"; echo "</td><td>"; echo "<input type='text' size='1' value= '$row[C1]' name='c1[$i]' style ='font-size: 11px; background-color:#{$row['color']};'>"; echo "</td><td>"; echo "<input type='text' size='16' value= '$row[Player2]' name='player2[$i]' style ='font-size: 11px; background-color:#{$row['color']};'>"; echo "</td><td>"; echo "<input type='text' size='1' value= '$row[C2]' name='c2[$i]' style ='font-size: 11px; background-color:#{$row['color']};'>"; echo "</td><td>"; echo "<input type='text' size='16' value= '$row[Player3]' name='player3[$i]' style ='font-size: 11px; background-color:#{$row['color']};'>"; echo "</td><td>"; echo "<input type='text' size='1' value= '$row[C3]' name='c3[$i]' style ='font-size: 11px; background-color:#{$row['color']};'>"; echo "</td><td>"; echo "<input type='text' size='16' value= '$row[Player4]' name='player4[$i]' style ='font-size: 11px; background-color:#{$row['color']};'>"; echo "</td><td>"; echo "<input type='text' size='1' value= '$row[C4]' name='c4[$i]' style ='font-size: 11px; background-color:#{$row['color']};'>"; echo "</td><td>"; echo "<input type='text' size='16' value= '$row[Player5]' name='player5[$i]' style ='font-size: 11px; background-color:#{$row['color']};'>"; echo "</td><td>"; echo "<input type='text' size='1' value= '$row[C5]' name='c5[$i]' style ='font-size: 11px; background-color:#{$row['color']};'>"; echo "</td><td>"; echo "<input type='text' size='1' value= '$row[Men]' name='men[$i]' style ='font-size: 11px; background-color:#{$row['color']};'>"; echo "</td><td>"; echo "<input type='text' size='1' value= '$row[Women]' name='women[$i]' style ='font-size: 11px; background-color:#{$row['color']};'>"; echo "</td><td>"; echo "<input type='text' size='1' value= '$row[Guest]' name='guests[$i]' style ='font-size: 11px; background-color:#{$row['color']};'>"; echo "</td><td>"; echo "<input type='checkbox' name='time1[$i]' value='$timeID'>"; echo "<input type='hidden' name='date[$i]' value='$dateID'>"; echo "<input type='hidden' name='time2[$i]' value='$timeID'>"; echo "</td></tr>"; $i++; } echo "</table>"; mysql_close($con); ?> <br /><br /> <input type="Submit" name="Submit" value="Update Tee Times"> </FORM> And for the processing page: <?php header("Location: /teetimes/adminteetimes.php?teetimedate=$dateID"); include("opendatabase.php"); $size = count($_POST['player1']); $i=0; while ($i < $size) { $dateID = $_POST['date'][$i]; $timeID1 = $_POST['time1'][$i]; $timeID2 = $_POST['time2'][$i]; $player1 = ($_POST['player1'][$i]); $player2 = ($_POST['player2'][$i]); $player3 = ($_POST['player3'][$i]); $player4 = ($_POST['player4'][$i]); $player5 = ($_POST['player5'][$i]); $men = ($_POST['men'][$i]); $women = ($_POST['women'][$i]); $guest = ($_POST['guests'][$i]); if (empty($timeID1)) { mysql_query(" UPDATE Daysheets SET Player1='$player1', Player2='$player2', Player3='$player3', Player4='$player4', Player5='$player5', Men='$men', Women='$women', Guest='$guest' WHERE Date ='$dateID' AND Time ='$timeID2' "); $i++; } else { mysql_query(" UPDATE Daysheets SET Player1='', Player2='', Player3='', Player4='', Player5='', Men='0', Women='0', Guest='0' WHERE Date ='$dateID' AND Time ='$timeID2' "); $i++; } } mysql_close($con) ?> Thanks for your help.
  24. I've tested the variable and got the correct result all the way until it's supposed to get passed. After the new page loads the variable is blank.
  25. I'm still learning and am not familiar with Sessions yet. I will look into it. Thanks.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.