Jump to content

ansipants

Members
  • Posts

    20
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

ansipants's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. tysm, i got that part working, how would i do the division correctly to find the percent?
  2. I was wondering if anyone would be able to help me as I've tried everything possible but and I can't get the time to display properly. I have 2 tables in my database, one table has a column that stores the time it would take to complete the physical assignment. I have already done the code that converts the time automatically into seconds, so that part is not the issue. Now, the second table i have captures data and then adds up all of the times from a user and spits it into a column "total_time". Now, the column it stores in is a varchar which shouldn't really matter, but the time goes in like 02:15:37.5, hours:minutes:seconds.milliseconds. I'm having a very hard time getting that to convert to seconds so that I can display the % difference between the first column mentioned in the first paragraph and the second column in this paragraph. Any help would be greatly appreciated. I've been working straight with no sleep for literally 3 days now and i think i fried my brain.
  3. Ok, so I'm attempting to work on a script that will generate random codes and I also want to be able to change the multiplier with a form. Here is what I have so far: <code> <?php $chars = "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; // Alpha numberic character $chars .= "123456789"; $chars .= "123456789"; $chars .= "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $chars .= "123456789"; $chars .= "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $chars .= "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $chars .= "123456789"; $chars .= "123456789"; $chars = str_shuffle($chars); $chars = substr($chars, 0, 15); /** This is the part I'm not sure how to do because it generates the same codes 5 times in a row and I want it to generate different codes on each line or maybe do a form that I can change the multiplier number to generate more */ $input = $chars; $multiplier = 5; $separator = "<br>\n"; print implode($separator, array_fill(0, $multiplier, $input)); print "<br>\n"; ?> </code> Sorry I'm a n00b and trying to learn more =)
  4. well i didn't then I put it in and I got a few errors then i pretty much destroyed the whole thing so, back to the drawing board from scratch :'(
  5. when I try to upload the image on submit, I get there following error: Fatal error: Call to undefined function file_extension() in editlogo.php on line 41 Line 41 is the very last line of the code. // get form data, making sure it is valid $img_name = $_FILES['myimage']['name']; $tmp_name = $_FILES['myimage']['tmp_name']; $img_size = $_FILES['myimage']['size']; if ($img_name) { if ($img_size>2097152) { die('Max image size is 2mb!'); } else { $file_ext = file_extension($img_name);
  6. this is the line in my script that I have to show the image: $output .= "<img>{$row['disp_pic']}</img></br>\n"; As you can see I added the image tag, but it wont show the actual image. IE shows it as a small square with another small square picture icon in the middle of it (i'm sure you guys know what i mean).
  7. there are subdomain creation scripts out there for this that work with member signups. cPanel Subdomains Creator is one I believe, and its free.
  8. yep that did it. any ideas on how i can echo the php data into the textarea? the original line read like this: <textarea name='r_bhours' cols='45' rows='3' value='$bhours'></textarea> rather than: <input type='text' name='r_bhours' cols='45' rows='3' value='$bhours'> haven't cleaned up the code yet, as you can see i changed the part that says textarea to input so that i could test it and it worked the second way, but i need it the first.
  9. ok so i added the name for the submit and how it spits out an error that says Notice: Undefined index that refers to the following lines of code: $username = mysql_real_escape_string(htmlspecialchars($_POST['username'])); $location = mysql_real_escape_string(htmlspecialchars($_POST['loc_name'])); $address = mysql_real_escape_string(htmlspecialchars($_POST['address'])); $city = mysql_real_escape_string(htmlspecialchars($_POST['city'])); $zip = mysql_real_escape_string(htmlspecialchars($_POST['zip'])); $county = mysql_real_escape_string(htmlspecialchars($_POST['county'])); $website = mysql_real_escape_string(htmlspecialchars($_POST['website'])); $map = mysql_real_escape_string(htmlspecialchars($_POST['map'])); $email = mysql_real_escape_string(htmlspecialchars($_POST['email'])); $phone = mysql_real_escape_string(htmlspecialchars($_POST['phone'])); $bhours = mysql_real_escape_string(htmlspecialchars($_POST['hours'])); $ptimes = mysql_real_escape_string(htmlspecialchars($_POST['ptime'])); $pspecials = mysql_real_escape_string(htmlspecialchars($_POST['pspecial'])); $vspecials = mysql_real_escape_string(htmlspecialchars($_POST['vspecial']));
  10. <td colspan='2'><div align='center'><font size='2' face='arial'><a href='edituser.php'>Cancel</a> - </font><input type='submit' value='Update Location'></div></td>
  11. sorry, forgot about the code tags. no errors at all just goes back to the form after submit and I double checked my database - nothing.
  12. Can someone please take a look and see if you can point out what error i made. Everything on the form side is functioning except it doesn't seem to post since its looping back to the form rather than the redirect. Also, within the actual form table, i had to change the section that says Business Hours from a textarea because I couldn't get it to echo the data from the field in the database. Any ideas on that would be greatly appreciated. Sorry if its a bit sloppy, I'm no expert. <?php include "config.php"; mysql_connect("$dbhost","$dbusr","$dbpass"); mysql_select_db("$dbname"); session_start(); if (isset($_SESSION['user'])) { } else { header ('location: login.php'); } // creates the edit record form // since this form is used multiple times in this file, I have made it a function that is easily reusable function renderForm($id, $username, $location, $address, $city, $zip, $county, $website, $map, $email, $phone, $bhours, $ptimes, $pspecials, $vspecials, $error) { echo "<center><strong>Edit Location Information</strong></center>"; // if there are any errors, display them if ($error != '') { echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>'; } echo " <center> <form action='' method='POST'> <table border='0' frame='box'> <tr> <td width='96'><div align='right'>Venue ID:</div></td> <td colspan='2'><input type='hidden' name='id' value='$id'>$id</td> </tr> <tr> <td><div align='right'><font size='2' face='arial'>Username:</font></div></td> <td colspan='2'><input type='text' name='r_username' value='$username'></td> </tr> <tr> <td>Business Name:</td> <td colspan='2'><input type='text' name='r_location' value='$location'></td> </tr> <tr> <td><div align='right'><font size='2' face='arial'>Address:</font></div></td> <td colspan='2'><input type='text' name='r_address' value='$address'></td> </tr> <tr> <td><div align='right'>City/State:</div></td> <td><input type='text' name='r_city' value='$city'></td> <td>Format = City, St</td> </tr> <tr> <td><div align='right'><font size='2' face='arial'>Zip:</font></div></td> <td colspan='2'><input type='text' name='r_zip'value='$zip'></td> </tr> <tr> <td><div align='right'>County:</div></td> <td colspan='2'><input type='text' name='r_county'value='$county'></td> </tr> <tr> <td><div align='right'>Website:</div></td> <td colspan='2'><input type='text' name='r_website' value='$website'></td> </tr> <tr> <td><div align='right'>Directions:</div></td> <td colspan='2'><input type='text' name='r_map' value='$map'></td> </tr> <tr> <td><div align='right'><font size='2' face='arial'>E-mail:</font></div></td> <td colspan='2'><input type='text' name='r_email' value='$email'></td> </tr> <tr> <td><div align='right'><font size='2' face='arial'>Phone #::</font></div></td> <td colspan='2'><input type='text' name='r_phone' value='$phone'></td> </tr> <tr> <td height='80'><div align='right'><font size='2' face='arial'>Business Hours:</font></div></td> <td width='287'><input type='text' name='r_bhours' cols='45' rows='3' value='$bhours'></td> <td width='244'><p>**You must enter </br> after each line to display in rows:</p> <p>Mon - Fri 11am to 10pm</br></p> <p>Sat - Sun 1PM to 3am</br></p></td> </tr> <tr> <td><div align='right'><font size='2' face='arial'>Poker Times:</font></div></td> <td colspan='2'><input type='text' name='r_ptimes' value='$ptimes'></td> </tr> <tr> <td><div align='right'><font size='2' face='arial'>Poker Specials:</font></div></td> <td><input type='text' name='r_pspecials' value='$pspecials'></td> <td> </td> </tr> <tr> <td><div align='right'><font size='2' face='arial'>Location Specials:</font></div></td> <td><input type'text' name='r_vspecials' cols='45' rows='3' value='$vspecials'></td> <td><p>**You must enter </br> after each line to display in rows:</p> <p>Mon - $0.10 Wings</br></p> <p>Fri - 2 for 1 Happy hour</br></p></td> </tr> <tr> <td></td> <td colspan='2'><div align='center'><font size='2' face='arial'><a href='edituser.php'>Cancel</a> - </font><input type='submit' value='Update Location'></div></td> </tr> </table> </form> </center> "; } // check if the form has been submitted. If it has, process the form and save it to the database if (isset($_POST['submit'])) { // confirm that the 'id' value is a valid integer before getting the form data if (is_numeric($_POST['id'])) { // get form data, making sure it is valid $id = $_POST['id']; $username = mysql_real_escape_string(htmlspecialchars($_POST['username'])); $location = mysql_real_escape_string(htmlspecialchars($_POST['loc_name'])); $address = mysql_real_escape_string(htmlspecialchars($_POST['address'])); $city = mysql_real_escape_string(htmlspecialchars($_POST['city'])); $zip = mysql_real_escape_string(htmlspecialchars($_POST['zip'])); $county = mysql_real_escape_string(htmlspecialchars($_POST['county'])); $website = mysql_real_escape_string(htmlspecialchars($_POST['website'])); $map = mysql_real_escape_string(htmlspecialchars($_POST['map'])); $email = mysql_real_escape_string(htmlspecialchars($_POST['email'])); $phone = mysql_real_escape_string(htmlspecialchars($_POST['phone'])); $bhours = mysql_real_escape_string(htmlspecialchars($_POST['hours'])); $ptimes = mysql_real_escape_string(htmlspecialchars($_POST['ptime'])); $pspecials = mysql_real_escape_string(htmlspecialchars($_POST['pspecial'])); $vspecials = mysql_real_escape_string(htmlspecialchars($_POST['vspecial'])); // check that username field is filled in if ($username == '') { // generate error message $error = 'ERROR: Please fill in all required fields!'; //error, display form renderForm($id, $username, $location, $address, $city, $zip, $county, $website, $map, $email, $phone, $bhours, $ptimes, $pspecials, $vspecials, $error); } else { // save the data to the database mysql_query("UPDATE vusr SET username='$username', loc_name='$location', address='$address', city='$city', zip='$zip', county='$county', website='$website', map='$map', email='$email', phone='$phone', hours='$bhours', ptime='$ptimes', pspecial='$pspecials', vspecial='$vspecials' WHERE id='$id'") or die(mysql_error()); // once saved, redirect back to the view page header("Location: edituser.php"); } } else { // if the 'id' isn't valid, display an error echo 'Error!'; } } else // if the form hasn't been submitted, get the data from the db and display the form { // get the 'id' value from the URL (if it exists), making sure that it is valid (checing that it is numeric/larger than 0) if (isset($_GET['id']) && is_numeric($_GET['id']) && $_GET['id'] > 0) { // query db $id = $_GET['id']; $result = mysql_query("SELECT * FROM vusr WHERE id=$id") or die(mysql_error()); $row = mysql_fetch_array($result); // check that the 'id' matches up with a row in the databse if($row) { // get data from db $id = $row['id']; $username = $row['username']; $location = $row['loc_name']; $address = $row['address']; $city = $row['city']; $zip = $row['zip']; $county = $row['county']; $website = $row['website']; $map = $row['map']; $email = $row['email']; $phone = $row['phone']; $bhours = $row['hours']; $ptimes = $row['ptime']; $pspecials = $row['pspecial']; $vspecials = $row['vspecial']; // show form renderForm($id, $username, $location, $address, $city, $zip, $county, $website, $map, $email, $phone, $bhours, $ptimes, $pspecials, $vspecials, ''); } else // if no match, display result { echo "No results!"; } } else // if the 'id' in the URL isn't valid, or if there is no 'id' value, display an error { echo 'Error!'; } } ?> MOD EDIT: code tags added.
  13. I know this is something simple: my script pulls the website url that is stored into the database. The issue is that when it displays the link information, when you click on it, instead of opening www.google.com, it tries to open to www.mydomain.com/www.google.com here is the table i have for it: <td><a href='$website' target='_new'>$website</a></td>
×
×
  • 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.