Jump to content

rhoffer21

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

rhoffer21's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Well that worked. IM not sure why but it did Thanks.
  2. no error, its just not changing my data at all.
  3. That all worked great, the only problem im having now is that its not actually updating. I checked all the variables and they are all correct. mysql_query('UPDATE schedule SET date = '.$date.', away = '.$away.', home = '.$home.', time = '.$time.', field = '.$field.' WHERE id = '.$game.'');
  4. <?php include 'config.php'; include 'opendb.php'; $game = $_POST['game']; $date = $_POST['date']; $away = $_POST['away']; $home = $_POST['home']; $time = $_POST['time']; $field = $_POST['field']; $delete = $_POST['delete']; echo "delete equals " .$delete. "<br>"; if ($delete = 1) { mysql_query('DELETE FROM schedule WHERE id = '.$game.''); echo "The game has been deleted!"; } else { mysql_query('INSERT INTO schedule(date) VALUES '.$date.' WHERE id = '.$game.''); mysql_query('INSERT INTO schedule(away) VALUES '.$away.' WHERE id = '.$game.''); mysql_query('INSERT INTO schedule(home) VALUES '.$home.' WHERE id = '.$game.''); mysql_query('INSERT INTO schedule(time) VALUES '.$time.' WHERE id = '.$game.''); mysql_query('INSERT INTO schedule(field) VALUES '.$field.' WHERE id = '.$game.''); echo "The Game has been changed succesfully!"; } include 'closedb.php'; ?> That is my code. Everytime this script is run the part beneath the if ($delete = 1) is run. I added the echo "delete equals " .$delete. "<br>"; to the page to show me what delete equals. delete equals 1 when it is supposed to and it doesnt equal 1 when its not supposed to but it runs through the part every time and it doesn't run the else part ever. any ideas?
  5. Those 2 problems were the cause. Thanks a bunch for looking at it.
  6. Ahhhhh, I figured it was something dumb like that. Going to fix the code right now and I'll let you know what happens. Thanks alot.
  7. I added the time limit thing because by default it is 30 seconds and i thought that maybe if it had a little more time it could finish, but it still timed out at 60 seconds, so that line is irrelevant anyway and i have already removed it. I have wamp installed so my config info is all localhost info and ill attach them below: <?php // This is config.php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $dbname = 'baseball'; ?> <?php // This is opendb.php $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); ?> <?php //this is closedb.php mysql_close(mysql_connect($conn)); ?>
  8. I just started learning PHP/MySQL today. I'm trying to design a website that will make the management of a baseball league I run a little easier. I have a few while loops in this script that I am writing and I keep getting a timeout error. Any tips to speed up the script would be great. Thanks, Ryan <?php set_time_limit(60); //includes the server configuration and opens the database include 'config.php'; include 'opendb.php'; //selects the table standings from our database $result = mysql_query('SELECT * FROM standings') or die(mysql_error()); //initializes the initial table echo "<table border='1' cellspacing='0' frame='box' spacing='0' padding='1'>"; //The following code displays the table headers with a red background and white text echo "<tr bgcolor='red'><th><b><center><font color='White' size='2'>Name</center></b></th> <th><b><center><font color='White' size='2'>W</center></b></th> <th><b><center><font color='White' size='2'>L</center></b></th> <th><b><center><font color='White'>PCT</center></b></th></tr>"; //this while loop will read all the data about the teams and arrange them the way I want it to while($row = mysql_fetch_array($result)) { //sets games equal to wins + losses $games = $row['wins'] + $row['losses']; //if the team has played any games this if statement sets winpercentage to the proper percentage //if not it sets winpercentage to 0 if ($games > 0) { $winpercentage = $row['wins'] / $games; } else { $winpercentage = 0; } //multiples winpercentage by 1000 for proper format $winpercentage*=1000; $standingcountertop = 1002; $standingcounterbottom = 1000; $standingcountertop = $standingcountertop-1; $standingcounterbottom = $standingcounterbottom-1; while ($standingcountertop > '-1'); { if ($winpercentage > $standingcounterbottom && $winpercentage <$standingcountertop) { //accesses the database and outputs team name wins and losses echo "<tr>"; echo "<td><font size='2'>"; echo $row['name'] . " </td>"; echo "<td><font size='2'>"; echo $row['wins'] . " </td>"; echo "<td><font size='2'>"; echo $row['losses'] . " </td>"; echo "<td><font size='2'>"; //these statements sets the decimal point for proper display if ($winpercentage == '0') { $winpercentage = '.000'; echo $winpercentage; } else if ($winpercentage == '1000') { $winpercentage = '1.000'; echo $winpercentage; } else { echo "."; echo number_format($winpercentage) . " </td>"; } } } }//End of while loop //ends the table echo "</table>"; //closes the databse for security include 'closedb.php'; ?> Edit ---- I'm not sure whether I overlooked some logic and this is stuck in an endless loop or if it is simply taking that long to run through the loops. Just looking for a few extra eyes to glance at it.
×
×
  • 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.