Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. Oh ok, so in your edit script you will want to pass those values to the getTowns() and state_dropdown() functions. When the value of the <option> tag matches the state/town passed to the function you set the selected html attribute First the getTowns function, get changed to. See comments in code // In edit page the state is pass as an argument. It will be the selected value in the dropdown menu function getTowns($selected_state = null) { $result = mysql_query("SELECT DISTINCT State FROM state_town") or die(mysql_error()); while($tier = mysql_fetch_array( $result )) { // when the current state matches the state being passed, the selected attribute for the <option> tag will be set $selected = $tire['State'] == $selected_state ? ' selected="selected"' : ''; echo '<option value="'.$tier['State'].'"'.$selected.'>'.$tier['State'].'</option>'; } } When you call this function in your edit page, you pass $row['State'] as an argument getTowns($row['State']); on loading the edit page, it should have the state chosen whcih is stored in the database. When calling the state_dropdown() function in your edit page you will pass $row['State'] and $row['town'] as arguments <span id="result_1"><?php echo state_dropdown($row['State'], $row['Town']); ?></span>, The function will be changed to // the state and town are passed as arguments in the edit page function state_dropdown($state, $town = null) { include("manage/connect.php"); $result = mysql_query("SELECT * FROM state_town WHERE State='$state'") or die(mysql_error()); // when a town has been passed, remove the selected attribute from the Any Town option echo '<select name="Town" id="Town"> <option value="" disabled="disabled" ' . ($town != null ) ? 'selected="selected"' : '') .'>Any Town</option>'; while($town_dropdown = mysql_fetch_array( $result )) { // if the current town matches the town passed to the function, set the selected attribute to the <option> tag $selected = ($row_dropdown['Towns'] == $town) ? ' selected="selected"' : ''; echo '<option value="'.$town_dropdown['Towns'].'"'.$selected.'>'.$town_dropdown['Towns'].'</option>'; } echo '</select> '; }
  2. Sorry, not understanding what you mean. Could you explain what it is you are trying to do.
  3. If nothing is being inserted then there is most likely a problem with the query. if(!mysqli_query($con, $msg)) { trigger_error('Unable to insert message into database: ' . mysqli_error($con)); } Also your lispa function will not be very good for protecting against sql injection. You should use mysqli_real_escape_string or preferably prepared statements for protecting against sql injection when using user input in your queries.
  4. Ok. Well those two lines would not produce that error. Its is the line with number_format() producing that error. It seems the value ($prix) you are giving number_format is not a number this why you are getting the error. How is $prix defined before that line?
  5. Look at your other topic you posted 15 minutes ago
  6. I guess the error is from number_format()? The three lines you posted look ok. So it looks like $prix is not a number can you tell us how and where that variable is defined?
  7. Add onClick="Click()" to the <area> tag <area shape="rect" coords="1,1,116,109" href="#" alt="Clicker" onclick="Click()" /> The Click() function can be written as function Click() { var petals = document.getElementById("Petals"); petals.innerHTML = parseInt(petals.innerHTML) + 1; }
  8. You need to use the comparison operator ( == ) not the assignment operator ( = ) here if($utilizador = $ln['to']){ ^ | this should be ==
  9. If this is for only your use, then a mysql database is a bit overkill. You store the date in a text file when the button is pressed. Example code <?php // change date.txt to the filename for storoing the date in define('DATE_FILE', 'date.txt'); // set to true if you want the counter to increment at midnight define('COUNT_FROM_MIDNIGHT', false); // when form is submitted if(isset($_POST['start'])) { // save current time to file file_put_contents(DATE_FILE, date('Y-m-d h:i:s')); } // if the date file has been created if(file_exists(DATE_FILE)) { // get todays date $today = new DateTime(); // read the date recorded $recoredDate = file_get_contents(DATE_FILE); // set the date to compare $date = new DateTime($recoredDate); // if we are counting from midnight, set the hour, minute and seconds to zero if(COUNT_FROM_MIDNIGHT) $date->setTime(0, 0, 0); // calcualate the difference between the two dates $diff = $today->diff($date); // output the difference echo $diff->format('Today is day %a'); } // file has not been created, show button to start counter else { $date = date('Y-m-d'); $time = date('h:i:s'); echo ' <form method="post"> <input type="submit" name="start" value="Start Counter" /> ' . 'From ' . $date . ' ' . $time . '<br />Counter increments at ' . (COUNT_FROM_MIDNIGHT ? 'midnight' : $time . ' tomorrow') . '</form>'; } ?> To simulate the difference in days, change $today = new DateTime(); to a date in the future eg $today = new DateTime('2015-06-30 09:21:50');
  10. Looks like you are wanting to change the font for all p tags within blockquote tags, in that case put the following at the end of your style. blockquote p { font-family: 'Roboto', sans-serif; font-size: 32px; line-height: 40px; font-weight: 400; font-style: italic; text-align: center; text-transform: uppercase; color: ... }
  11. Yes, you can set the samplename field to be unique ALTER TABLE ProcessDetails ADD UNIQUE(samplename) Now when you go to insert a duplicate value into the samplename field an error will be triggered and the insert query will fail, if you do want to the error to be triggered then change your INSERT query to INSERT IGNORE or if you want the insert query to update the existing data for that row, then use INSERT ON DUPLICATE KEY UPDATE query
  12. Then you need to pass the convoy id when the user clicks the sign up button First you need to change the query which gets convoy date and the users signed up to convoy to also return the convoy id $query = " SELECT u.username, cv.date as 'date', cv.id as convoy_id # get the convoy id FROM convoy cv, convoysignup cvsu INNER JOIN users u ON u.id = cvsu.name "; Then in the signup form, add the convoy id as hidden input field <form class="form-signin" role="form" action="convoy.php" method="post"> <input type="hidden" name="convoy_id" value="<?php echo $row['convoy_id']; ?>" /> <button class="btn btn-lg btn-primary btn-block" name="addConvoyUser" type="submit">Sign up for this convoy</button> </form> Then when adding the user to the convoy retrieve the convory id from $_POST $query = " INSERT INTO convoysignup ( username, convoyid ) VALUES ( :username, :convoyid )"; $query_params = array( ':username' => $_SESSION['userid'], ':convoyid' => intval($_POST['convoy_id']) );
  13. Thats not how you define an array in PHP all you are doing is defining a string. You should be able to do something like $arrayOutSideTempData= array(); while(...) { ... $arrayOutSideTempData[] = array($TimeSamp, $OutsideTemp); // add $Timestamp, $outsideTemp values as an array to $p->data array } $p->data = array($arrayOutSideTempData); You can then use print_r($p->data); after the loop to check the array structure
  14. Your HTML has quite a few errors in it which could be why the radio buttons are not being included in your form, even though they are within your <form></form> tags In google chrome the inspector, does not include the radio buttons in your form.
  15. Continue to replace 113 through to 149 with the code I provided earlier but then on lines 159 and 162 replace $sireid with $dogVO->sire->id and on lines 174 and 177 replace $damId with $dogVO->dam->id Now delete lines 119 and 120 $sireId = $dogVO->sire->id; $damId = $dogVO->dam->id; That should now fix it.
  16. When a user clicks on a other player, you pass their player id and the (style type of) attack to your processing script. You then run an update query which takes away the health points in an update query UPDATE players SET health = health - $attackDamage WHERE id = $playerid
  17. Lines 113 to 149 should read as } elseif($level != 1) { echo "<TD ROWSPAN=" . pow(2,($generations - $level)); echo " >"; if (($dogVO != -1) && (!empty($dogVO ))) { $name = $dogVO->name; $sireId = $dogVO->sire->id; $damId = $dogVO->dam->id; $landofbirth = $dogVO->landofbirth; $yearofbirth = $dogVO->yearofbirth; $color = $dogVO->color; $title = $dogVO->title; $photo = $dogVO->photo->thumb_ref; if (empty($photo)) $photo = $dogVO->photo->reference; ### Highlight title w/ red font if (!empty($title)) { echo "<label>"; echo "<font color=\"blue\">$title</font><BR>"; echo "</label>"; } if ($images == "yes") { if (!empty($photo)) { echo '<img SRC="'.$photo.'" width="'.$THUMBNAIL_WIDTH.'"></p>'; } } echo "$name"; echo "<label>"; echo "</label>"; } else { $out[] = "<label>unknown</label>"; } echo "</TD>"; }
  18. Although it appears to work it actually is still outputting the the first level (child item). I also meant to to say to delete line 116 and and to add a } after line 149. I submitted my post earlier too soon.
  19. At a guess try changing line 113 to } elseif($level != 1) {
  20. Use fgets, each time it is called it returns the next line. Everytime you get a new line increment a counter, when the counter hits 3, this will be the 3rd line then set the $subject $data = ''; $i = 0; while (false !== ($line = fgets(STDIN))) { $data .= $line; /// if we are on the 3rd line, set the subject if(++$i == 3) $subject = $line; }
  21. How is $row defined? Its because you are using = NULL not == NULL = NULL will be overriding the value for $row['avatar'] As I said earler
  22. You need to be using the comparison operator == (two equals) not the assignment operator = (one equals) when comparing values here. Or use empty <?php if($row['avatar']) = NULL: ?> And alternative way of writing that if/else would be <?php $avatarImage = empty($row['avatar']) ? 'holder.js/200x200' : $row['avatar']; /* use ternary operator to define what image to server for avatar*/ ?> <img data-src="<?php echo $avatarImage; ?>" alt="...">
  23. If the id column in the convory table is auto_increment then you can use mysqli->insert_id.
  24. Try define('UPLOAD_DIR', 'repository/'); // default major, minor values; $minor = 1; $major = 0; if (isset( $_POST['addfile'])) { // get the filename and extension of the uploaded file $path = pathinfo($_FILES['fileToUpload']['name']); $filename = $path['filename']; $extension = $path['extension']; // find existing uploaded versions $existingFileVersions = glob(UPLOAD_DIR . "$filename *.*.$extension"); if($existingFileVersions) { // get the last file $lastFileVersion = end($existingFileVersions); // extract the major and minor version from the filename preg_match('/(.*) (\d+).(\d+)$/', pathinfo($lastFileVersion, PATHINFO_FILENAME), $m); list(, $filename, $major, $minor) = $m; // increment the major/minor versions switch($_POST['rev_type']) { case 'major': $major += 1; break; case 'minor': $minor += 1; $minor = sprintf('%02d', $minor); // format minor version to two digits 01, 02 .. 10 etc break; } } // set the new filename $updatedFilename = UPLOAD_DIR . "$filename $major.$minor.$extension"; // upload file if(move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $updatedFilename)) { echo "You have successfully uploaded and renamed the file as a '{$_POST['rev_type']}' revision."; echo "<p>FILE: $updatedFilename</p>"; } }
  25. Use while ($stmt->fetch()) { if(empty($lev3)) { $categories[$lev1][$lev2] = null; } else { $categories[$lev1][$lev2][] = $lev3; } }
×
×
  • 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.