Jump to content

Steppio

Members
  • Posts

    51
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Steppio's Achievements

Member

Member (2/5)

0

Reputation

  1. The problem is that when i define $id = $conn->insert_id that id is specific / primary to the orders table, so running another query would not bring that variable with it, i need to stick that ID into another table to be able to cross-link the tables t_users and t_orders through t_o_link. Maybe i'm going about this the wrong way
  2. So how would i get the same ID for each new order to be saved into the t_o_link table if php does'nt handle multiple queries?
  3. I have a giant MySQL query thats processed by PHP and then put into two tables in the database, the only problem being it adds to 1 table and not the other. The query is as follows (NB: The Majority of this can be ignored, the problem is likely at the bottom): $id = $conn->insert_id; $linkid = $conn->insert_id; $result1 = $conn->query("INSERT into t_orders (orderid, orderdate, ordercat, userid, main_head_type, idler_head_type, bridge_centres, length_crs_to_crs, blade_fitting_dia, inward_bend, build_type, overall_length, main_bend_length, i_bend, bend_bolt_length, bend_degree, bend_end_hook, i_clip, crank, spindle_a, a_dim, spindle_b, b_dim, crs_of_pin, pin_dia, pin_length, motor_shaft_size, crs_of_hole, hole_dia, thread_hand, arm_straight, main_spindle_dia, main_spindle_thread_dia, idler_spindle_thread_dia, idler_spindle_dia, main_liner_length, idler_liner_length, brop_arm_crs, conn_link, idler_drop_arm, spindle_dia, thread_dia, liner_length, drop_arm, cranked_straight, up_down, screen_height_a, screen_height_b, mounting_distance, spindle_centers_d, spindle_position, top_bottom, 12_24, minimum_liner, left_right, open_length, tube_length, stroke_length, tube_dia, end_fittings, newtons, rod_dia) VALUES ('" . $id . "','" . $orderdate . "','" . $ordercat . "','" . $userid . "','" . $main_head_type . "', '" . $idler_head_type . "','" . $bridge_centres . "','" . $length_crs_to_crs . "', '" . $blade_fitting_dia . "','" . $inward_bend . "','" . $build_type . "', '" . $overall_length . "','" . $main_bend_length . "','" . $i_bend . "', '" . $bend_bolt_length . "','" . $bend_degree . "','" . $bend_end_hook . "', '" . $i_clip . "','" . $crank . "','" . $spindle_a . "','" . $a_dim . "', '" . $spindle_b . "','" . $b_dim . "', '" . $crs_of_pin . "','" . $pin_dia . "','" . $pin_length . "','" . $motor_shaft_size . "', '" . $crs_of_hole . "','" . $hole_dia . "','" . $thread_hand . "', '" . $arm_straight . "','" . $main_spindle_dia . "','" . $main_spindle_thread_dia . "', '" . $idler_spindle_thread_dia . "','" . $idler_spindle_dia . "', '" . $main_liner_length . "','" . $idler_liner_length . "', '" . $drop_arm_crs . "','" . $conn_link . "','" . $idler_drop_arm . "', '" . $spindle_dia . "','" . $thread_dia . "','" . $liner_length . "', '" . $drop_arm . "','" . $cranked_straight . "','" . $up_down . "', '" . $screen_height_a . "','" . $screen_height_b . "','" . $mounting_distance . "', '" . $spindle_centers_d . "','" . $spindle_position . "','" . $top_bottom . "', '" . $volt . "','" . $minimum_liner . "','" . $left_right . "','" . $open_length . "', '" . $tube_length . "','" . $stroke_length . "','" . $tube_dia . "', '" . $end_fittings . "','" . $newtons . "','" . $rod_dia . "'); INSERT into t_o_link (linkid, orderid, userid) VALUES ('" . $linkid . "','" . $id . "','" . $userid . "')"); if (!$result1) echo '<h4>Could not register order in database ' .'- please try again later.</h4>'; Now everythings swell and candylicious up until i attempt to insert data into the t_o_link table, probably due to my crappy programming. The result returns negative and as such throws an error. Is there anyway to do a query like this were another query is added after another? The reason i dont seperate the two querys is that once i've used $conn->insert_id for the variable $id, its left in the first query and i cant figure out a way to get that same id into the second table. Any ideas or solutions would be helpful and very gratefully accepted. Thank you in advance.
  4. Darkwater ... i love you. I want to somehow produce offspring from you. They can share my total lack of perception and your lovely cranium. I literally cannot believe it all came down to that, 1 missing 's' (the folder name was //uploads//). I don't know how to thank you, i must have looked over that page (it's based on about 4 different form PHP_SELF reloads) a hundred times and never saw that. Your a star mate, got me out a diddley of a pickle there. Again - THANK YOU!!!
  5. Is it even possible to do it this way? I'd usually use a blob type in database but the site soon runs slow and takes forever to flush the database. ANY suggestions?
  6. Is the MIME type i am using correct to upload jpegs?
  7. Thanks for the suggestion but i've corrected the necessary names and am still having a great deal of trouble. Any help would be greatly appreciated. Thanks in advance.
  8. Yeah sorry overlooked that one, the Input field name is userfile, not usefile.
  9. I'm having a few problems uploading jpegs and moving them into a new folder. I've looked all over the web for help and scanned the code a hundred times, so i think its time to ask for some help: if ($_FILES['usefile']['error'] > 0) { echo 'Problem: '; switch ($_FILES['usefile']['error']) { case 1: echo 'File exceeded upload_max_filesize'; break; case 2: echo 'File exceeded max_file_size'; break; case 3: echo 'File only partially uploaded'; break; case 4: echo 'No file uploaded'; break; } exit; } if ($_FILES['userfile']['type'] != 'image/jpeg') { echo 'Problem: File is not a picture'; exit; } $currentdir=getcwd(); $target_path = $currentdir . "\\upload\\images\\" . basename($_FILES['userfile']['name']); echo "Target: $target_path<br>"; $temploc=$_FILES['userfile']['tmp_name']; echo "Temploc: $temploc<br>"; if (move_uploaded_file($_FILES['userfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['userfile']['name']). " has been uploaded<br><br>"; } else { echo "There was an error uploading the file, please try again!<br><br>"; } The error i am receiving upon trying to move this file is: Target: C:\Program Files\Apache Group\Apache\htdocs\trans\upload\images\Windscreen.jpg Temploc: C:\WINDOWS\Temp\php137.tmp Warning: move_uploaded_file(C:\Program Files\Apache Group\Apache\htdocs\trans\upload\images\Windscreen.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\Program Files\Apache Group\Apache\htdocs\trans\add_product.php on line 77 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\Temp\php137.tmp' to 'C:\Program Files\Apache Group\Apache\htdocs\trans\upload\images\Windscreen.jpg' in C:\Program Files\Apache Group\Apache\htdocs\trans\add_product.php on line 77 There was an error uploading the file, please try again! I really am at my wits end, any help would be greatly appreciated. Thanks in advance for your time. Steppio
  10. Thank you both, both cases worth perfect, however i was intrigued by your comment mjdamato. When you say i should store the admin rights in the database, would that mean adding a separate field called for example 'Admin' then manually adding a '1' or '2' respectively, or did you mean go into the settings for the MySQL database and setting it that way? Thank you both for your time and comments.
  11. Hi, i have a small problem in that everytime i log on to my site as username 'Frank', i am given admin access, yet everytime i log in as username 'frank' i am still allowed into the correct profile, but not given admin rights. Is there anyway of taking the input i use to log in, stripping it of caps lock, running it through the database and admin function then returning the caps lock on? Below is the code and function i use to log into my site, followed by my switch for admin rights: Members page code: require_once('main_fns.php'); session_start(); $usern = $_SESSION['valid_user']; if ((!$_POST['username'] || !$_POST['password'])) { require('head.inc'); echo 'You did not fill the form in properly, <a href="index.php">please try again</a>.'; require('foot.inc'); } else { $user = htmlspecialchars($_POST['username']); $pass = htmlspecialchars($_POST['password']); get_admin($user); $_SESSION['admin'] = $bgi; if ($user && $pass) { $return = safelogin($user, $pass); if ($return == true) { $_SESSION['valid_user'] = $user; require('head.inc'); display_member_details($user); require('foot.inc'); } else { echo 'failed'; } } } Login Code function safelogin($user, $pass) { if (isset($user) && isset($pass)) { $conn = db_connect(); if(!$conn) { echo "Failed to connect to the server\n"; } else { if(get_magic_quotes_gpc()) { $username = stripslashes($user); $password = stripslashes($pass); } else { $username = $user; $password = $pass; } $query = sprintf("SELECT * from t_users where username='$username' and password=sha1('$password')", mysqli_real_escape_string($conn,$username), mysqli_real_escape_string($conn,$password)); mysqli_query($conn,$query); if (mysqli_affected_rows($conn) > 0) { return true; } } } else { return false; } } Function code: function get_admin($user) { switch ($user) { case 'Steppio': $bgi = '1'; break; case 'Frank': $bgi = '1'; break; case 'Karl': $bgi = '1'; break; case 'Sam': $bgi = '1'; break; case 'Kris': $bgi = '1'; break; default: $bgi = '2'; } $_SESSION['admin'] = $bgi; return $_SESSION['admin']; } Any advice you could give me would be greatly appreciated, thanks for your time.
  12. aebstract - if you look at my original message you'll see i didn't ask for any code, i asked if anyone had seen or had any information that could help me. I tried searching for 'PHP Bad Language filter'/'PHP Undesirable Language Filter' which both came up with nothing. I asked for help and phpSensei gave it to me, you gave me sarcasm and a bad attitude. If you feel the need to insult peoples intelligence everytime they ask for help, maybe help forums aren't for you. Thanks to everybody else
  13. Thanks very much for the information, i believe i will be able to build a suitable array for the website with that example. Wheres that solved button...
  14. Try typing 'PHP Bad Language Filter' or 'PHP Undesirable Language Filter', its equally amazing, smart ar$e.
×
×
  • 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.