-
Posts
2,965 -
Joined
-
Last visited
Everything posted by mikesta707
-
Weird error in a simple fopen read script!
mikesta707 replied to drakeman's topic in PHP Coding Help
you are trying to open a file that doesn't exist in the directory. are you sure your file paths are set correctly? also I believe that the file structure in unix based systems are different than windows in that they use a backslash instead of a forward slash, but that could be entirely wrong, and I could have just made that up -
what table? where is a table involved in this script? echo both post['month'] and post['year'] and make sure they are populated with the correct data. I just tested this and it worked as indicated on my machine
-
$getnumber2=date("m/Y",strtotime($_POST['month'].' '.$_POST['year'])); echo $getnumber2; try that, you example didnt really make much sense. you are telling it to convert your string, which may look like march/2009 to the format of a 2 digit representation of a month. the following outputs $getnumber2=date("m/Y",strtotime("March 2009")); echo $getnumber2; 03/2009
-
Are you asking how to do it, or do you want to know if there are other methods of doing it? Define "better" the logic behind "deffering" javascript is to only load the javascript that doesn't need to be loaded before the page is loaded, thus making rendering time faster. I'm not quite sure what you are asking
-
[SOLVED] How can I change css properties with js?
mikesta707 replied to landysaccount's topic in Javascript Help
function changePic(){ var pic = getPic(); document.getElementById("Visual").style.background = "url("+ pic +")"; return true; } you were just writing the string pic inside the url instead of concatenating the value of the pic variable. -
Why would you want to have a user with a constant connection to the database anyways? It would probably be nicer to your servers if they were only connected when they needed to be, and otherwise they were disconnected
-
make sure you include the page where your class is defined before session_start() also. post the relevant code. also what exactly is your problem? is your class not being transferred between pages, or is it a different problem
-
[SOLVED] How to reload a form after submitting
mikesta707 replied to php_beginner_83's topic in PHP Coding Help
..... ..... // get last ID in 'pictures' table $result = mysql_query("SELECT * FROM pictures ORDER BY ID desc limit 1") or die('order images error'); $row = mysql_fetch_array($result); $newID = $row['ID'] + 1; // insert new image into 'pictures' table $insert = "INSERT INTO pictures (ID, Description, Path) VALUES ($newID, '{$_POST['imageDescription']}', '{$_POST['path']}')"; mysql_query($insert) or die(mysql_error()); // insert record into 'pics_in_albums' table $insert2 = "INSERT INTO pics_in_album (PicID, AlbumID) " . "VALUES ($newID, '{$_POST['albumMenu']}')"; mysql_query($insert2) or die('insert into pics_in_album errors'); header("Location: mypage.php");//this redirects -
$time = date("H:i:s"); $newtime = date("H:i:s", strtotime("+15 minute")); echo $time."<br />".$newtime; returns the following (eastern standard time) 16:36:37 16:51:37 that is the time now, 15 minutes from now is that what you want?
-
you can use array_unique on your array of random numbers. Random number generators will run into duplicate entries at some point, so perhaps randomly generated numbers isn't what you want. also uniqueid() seems to be exactly what you want as people have said.. why dont you use that?
-
if you are I thought when you said Creating Object, you meant that you were instantiating the object outside of the class. not to mention that I don't see any characters attribute in your character class itself. and if that is inside the character class, than why does the class instantiate objects of itself and store them in a seemingly non-existant class variable? sorry if I misread what you posted, but the little that was posted didn't make much sense in the context it was in. perhaps post what is above or below the Object creation code you posted so I can get a better idea of why you are why that particular snippet is there.
-
well for one this is the wrong forum but if you want those elements to be hidden by default, you must hide them when the page loads, IE make a function that hides everything, and then in the body tag, for the onload attribute, call that function.
-
if ($_POST['name']=="") { Print("Please fill in all fields!<br>"); } elseif ($_POST['email']=="") { Print("Please fill in all fields!!<br>"); } elseif ($_POST['comment']=="") { Print("Please fill in all fields!!!<br>"); } else { //do the query here //then output the stuff below echo "Successful"; echo "<BR>"; echo "<a href='viewguestbook.php'>View guestbook</a>"; }
-
this line $this->characters[] = $character; you only use the this symbol inside the class itself. when you want to call a method of a class you instantiated inside a variable, you use the variable name $character->characters[] = $character; should help you out
-
you have to exit() after one of the validation ifs or the script will just spit out the error message, but keep running. for example if ($_POST['name']=="") { Print("Please fill in all fields!<br>"); exit(); } you can also have the query execute in the else statement if you dont want to use exit
-
[SOLVED] variable not displaying properly??
mikesta707 replied to twilitegxa's topic in PHP Coding Help
whats it displaying -
perhaps you meant emails.email='$email' in any case you have to wrap varchars with single quotes
-
you never close the first if's code block if ((isset($_GET['train'])) && ($_GET['train'] == 'test1')) { $display_block = "<h3>Train Your Character To Level Up</h3> <h4>Choose a different <a href=choose_train.php>character</a> to train?</h4> <table cellpadding=3 cellspacing=3> <tr>"; $get_player_info = "select * from training WHERE identity = '$_GET[identity]'"; $get_player_info_res = mysql_query($get_player_info, $conn) or die(mysql_error()); while ($player_info = mysql_fetch_array($get_player_info_res)) { $id = $player_info['id']; $identity = $player_info['identity']; $level = $player_info['level']; $energy = $player_info['energy']; $experience = $player_info['experience']; $update_energy = ($energy - 2); $update_experience = ($experience + 50); $lose_energy = mysql_query("UPDATE training SET energy ='$update_energy' WHERE identity = '$identity'"); $gain_experience = mysql_query("UPDATE training SET experience ='$update_experience' WHERE identity = '$identity'"); $display_block .= " <td valign=top> <form action=train.php> <select name=train> <option>test1</option> <option>test2</option> </select> <input type=submit name=submit value=Train> <input type='hidden' name='identity' value='$identity' /> </form> </td> <td valign=top>Player: $identity<br /> Level: $level<br /> Energy: $energy<br> Current Experience: $experience<br /> Experience To Next Level:<br /> </td> </tr>"; }//end while }//end if elseif ((isset($_GET['train'])) && ($_GET['train'] == 'test2')) { $display_block = "<h3>Train Your Character To Level Up</h3> <h4>Choose a different <a href=choose_train.php>character</a> to train?</h4> <table cellpadding=3 cellspacing=3> <tr>"; $get_player_info = "select * from training WHERE identity = '$_GET[identity]'"; $get_player_info_res = mysql_query($get_player_info, $conn) or die(mysql_error()); while ($player_info = mysql_fetch_array($get_player_info_res)) { $id = $player_info['id']; $identity = $player_info['identity']; $level = $player_info['level']; $energy = $player_info['energy']; $experience = $player_info['experience']; $update_energy = ($energy - 10); $update_experience = ($experience + 100); $lose_energy = mysql_query("UPDATE training SET energy ='$update_energy' WHERE identity = '$identity'"); $gain_experience = mysql_query("UPDATE training SET experience ='$update_experience' WHERE identity = '$identity'"); $display_block .= " <td valign=top> <form action=train.php> <select name=train> <option>test1</option> <option>test2</option> </select> <input type=submit name=submit value=Train> <input type='hidden' name='identity' value='$identity' /> </form> </td> <td valign=top>Player: $identity<br /> Level: $level<br /> Energy: $energy<br> Current Experience: $experience<br /> Experience To Next Level:<br /> </td> </tr>"; } $display_block .= "</table>"; } else { print "Your character did not train."; } ?> see if that helps
-
[SOLVED] Help passing myrow data to a php.class
mikesta707 replied to RyanSF07's topic in PHP Coding Help
curious. thats because of this particular snippet of code from the functin // check for a difference like between one MIN and one HOUR if ( ($difference >= $min) && ($difference < $hour)) $c = 'n'; // check for a difference like between one HOUR and one DAY elseif ( ($difference >= $hour) && ($difference < $day)) $c = 'h'; // check for a difference like between one DAY and one WEEK elseif ( ($difference >= $day) && ($difference < $week)) $c = 'd'; // check for a difference like between one WEEK and one MONTH elseif ( ($difference >= $week) && ($difference < $month)) $c = 'ww'; // check for a difference like between one MONTH and one YEAR elseif ( ($difference >= $month) && ($difference < $year)) $c = 'm'; else $c = 'y'; it seems that all the checks are running false on the first run, and then running fine on the second. I don't really know why it does that, but I can't think of a quick fix off the top of my head. If it works on the second time around but not the first, i'm not sure why it would do that. -
[SOLVED] Autofill a form element by clicking on a link?
mikesta707 replied to madhattan's topic in PHP Coding Help
Oh ok, that was your only problem then. forget what i was saying after the code then haha. glad I could help -
[SOLVED] Update Run On Same Page When Form Submited?
mikesta707 replied to twilitegxa's topic in PHP Coding Help
create a hidden field with the value of the identity, than using the get value, assign identity. like $display_block .= " <td valign=top> <form action=train.php> <select name=train> <option>test1</option> <option>test2</option> </select> <input type=submit name=submit value=Train> <input type='hidden' name='id' value='$indentity' /> </form> </td> <td valign=top>Player: $identity<br /> Level: $level<br /> Energy: $energy<br> Current Experience: $experience<br /> Experience To Next Level:<br /> </td> </tr>"; -
if you don't want all the echos, condense what you are echoing into 1 or 2 lines... but it doesn't matter really...
-
[SOLVED] Help passing myrow data to a php.class
mikesta707 replied to RyanSF07's topic in PHP Coding Help
hmm, well whats happening is that when the function subtracts your input date from the value of time() it returns a negative number. whoever wrote this function didn't do it right I think (well the logic anyways) but try this $times = $class->timeAgo(time(), $date); and see what happens -
[SOLVED] Autofill a form element by clicking on a link?
mikesta707 replied to madhattan's topic in PHP Coding Help
well firstly, that echo must be inside the option tags, like <option value="2"><?php echo ($_GET['name'] == 2) ? "Selected='selected'" : ""; ?>Lily Clark</option> should be <option value="2" <?php echo ($_GET['name'] == 2) ? "Selected='selected'" : ""; ?>>Lily Clark</option> secondly, I don't really see where that switch gets used for anything... nor the variable $emailTo, or why that forms action is set to contactengine.php.... what page sets the get variable 'name'? -
[SOLVED] Update Run On Same Page When Form Submited?
mikesta707 replied to twilitegxa's topic in PHP Coding Help
ahh ok this code looks much better. one thing $get_player_info = "select * from training where identity = '$_GET[identity]'"; should be $get_player_info = "select * from training where identity = '".$_GET['identity']."'"; you have to surround associative array keys with single quotes. also in train.php I dont see anywhere where $identity is set before this line $get_player_info = "select * from training WHERE identity = '$identity'"; which needs identity to be set for the query to run correctly