Jump to content

Steppio

Members
  • Posts

    51
  • Joined

  • Last visited

    Never

Everything posted by Steppio

  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.
  15. I've been building a website lately that will have alot of comments from users coming across and was just wondering if anybody has ever heard of a bad/undesirable language filter/template that i could read up on and possibly manipulate into my own webpage. If you've ever heard of anything like this i would be more than grateful if you could help me out. Thanks in advance. Steppio.
  16. The code that i am using to enter the TinyMCE formatted content in to the MySQL database is as follows: function add_news($userid,$newsdate,$newshead,$news) { $conn = db_connect(); // check if username is unique $result = $conn->query("SELECT * from t_news where newshead='$newshead'"); if (!$result) throw new Exception('Could not execute query'); if ($result->num_rows>0) throw new Exception('That news title is taken ' .'- go back and choose another one.'); // if ok put in db $newsid = $conn->insert_id; $result = $conn->query("INSERT into t_news values ('$newsid','$userid','$newsdate','$newshead','$news')"); if (!$result) throw new Exception('Could not register article in the database ' .'- please try again later.'); return true; } The code to retrieve and display the data is as follows: <?php function get_news1($id) { $conn = db_connect(); $result2 = $conn->query("SELECT newsid, userid, newsdate, newshead, news FROM t_news WHERE newsid='$id'"); if (!$result2) { exit('<p>Error performing query: ' . mysql_error() . '</p>'); } while ($row2 = mysqli_fetch_array($result2)) { $newsid = $row2['newsid']; $user = $row2['userid']; $date = $row2['newsdate']; $head = $row2['newshead']; $news = $row2['news']; } ?> <table cellspacing="0" cellpadding="0" class="dbox" border="0"> <tr> <td class="logo-s"><img src="images/dbox/logo-s.gif"></td> <td class="date"><img src="images/dbox/date.gif"></td> <td class="header" align="left"><h2><?php echo $head;?></h2></td> <td class="end"> </td> </tr> <tr> <td class="sidestrip"> </td> <td class="bg" colspan="2"> <table cellspacing="0" cellpadding="0" border="0" class="register"> <tr> <td> <p><?php html_entity_decode($news); echo $news;?></p> <h2 align="right">From <?php echo $user;?> on <?php echo $date;?> </h2> <table class="register"><tr><td> <?php $user = $_SESSION['valid_user']; get_admin($user); if ($_SESSION['admin'] == 1) { echo "<br /><a href='deleteid.php?id=$newsid'>Delete/</a>"; echo "<a href='editnews.php?id=$newsid'>Edit</a>"; } ?> </td> <td align="right"> <?php if (isset($_SESSION['valid_user'])); { echo "<br /><a href='deleteid.php?id=$newsid'>Post a Comment</a>"; } ?> </td></tr></table> </td> </tr> </table> </td> <td class="l-line"> </td> </tr> <tr> <td class="sidestrip"> </td> <td class="bg" colspan="2" align="right" style="height: 10px; padding-right: 20px;"> </td> <td class="l-line"> </td> </tr> <tr> <td class="corner-s"> </td> <td class="line-top" colspan="2"> </td> <td class="br-corner"> </td> </tr> </table> ?> I've tried the html_entity_decode function but it still displays no hint of formatting. Any help would be greatly appreciated. Thanks in advance. Ste.
  17. I'm currently using TinyMCE as a formatting tool in collaboration with a MySQL database, storing using PHP, however whenever i retrieve the formatted data from the Database it doesn't format the text, but echo's the data as shown below: '<p style="text-align: center;">Example text Example te<strong>xt Example te</strong>xt Example text Example text Example text Example text Examp<span style="text-decoration: underline;">le text Exam</span>' I know this is probably a very simple problem to solve and i'm just being an idiot but its making me tear my hair out. If anybody can help me out i'd be eternally grateful. Thanks in advance. Steppio.
  18. Hi, i have a small problem concerning dates in PHP. I wish to take 3 options from 3 seperate drop-down boxes, POST them to a seperate page, checkdate all 3 selections together and them convert them into ISO 8601 format so i can store them in my database. My code after the POST is: <?php require_once('main_fns.php'); session_start(); check_valid_user(); $month = $_POST['month']; $day = $_POST['day']; $year = $_POST['year']; checkdate($day, $month, $year); $gigvenue = $_POST['add_venue']; $gigtime = $_POST['time']; $gigprice = $_POST['price']; $gigaddress = $_POST['add_address']; $gigcomments = $_POST['add_comments']; try { //check forms filled in if (!filled_out($_POST)) { throw new Exception('You have not filled out the form correctly '. '- please go back and try again.'); } add_gigs($gigdate, $gigvenue, $gigaddress, $gigtime, $gigprice, $gigcomments); require('head.inc'); echo 'Your gig was succesfully added, thank you for your time. <br />'; echo '<a href="gigs.php?<?php echo strip_tags(SID); ?>">Go to the gigs page...</a>'; require('foot.inc'); } catch (Exception $e) { require('head.inc'); echo $e->getMessage(); require('foot.inc'); exit; } ?> Basically i'd just like to add the $day, $month and $year variables into 1 variable. Any ideas?
  19. mjdamato ... i love you. Thank you so much for your help it appears to work excellently. Just in case you think i'm trying to get by on other peoples knowledge i'll explain a little of my predicament. I'm in a band and in the middle of a cash flow crisis i told the band i'd do the site. To begin with i started with a static HTML / CSS combo, but slowly the lure of PHP and Javascript, and basically the whole dynamic website scene began to cloud my focus, and now even though i could pay for someone to finish it off properly i've spent weeks and months doing this whole thing, everything from the graphics to the coding, and i feel as though i absolutely have to finish it. I've realised i'm crap at PHP but i may pursue it further, it's just very complicated and it's the first language of its type i've tried to learn. I've bit off more than i can chew but thank you for your help and everybody who replied, its most appreciated. Thanks again! Ste
  20. Just tried that, no errors, no output ... urrrgh
  21. As much as i want to just give up i absolutely have to finish this as i've started it. Can anybody please help me before i blow my brains out - i have a problem (no pun intended). I want some users to have other rights then other users, for instance i want both types of user (admin and user) to log in through the same form, but i want the login function to take the username and password and depending on the username i want it to decide if the login is for admin or user access. The code i have worked with a switch, but never ever ever works no matter where i put it in the code: function login($usern, $pass) // check username and password with db // if yes, return true // else throw exception { // connect to db $conn = db_connect(); // check username is unique $result = $conn->query("select * from t_users where username='$usern' and password=sha1('$pass')"); switch ($usern) { case 'Ste': $bgi = yes; break; case 'Keith': $bgi = yes; break; case 'Dave.Fingers': $bgi = yes; break; case 'Ben': $bgi = yes; break; case 'Matt': $bgi = yes; break; default: $bgi = no; } return ('$decide = ' . $bgi . ';'); if ($result->num_rows>0) return $decide; return true; if (!$result) throw new Exception('Could not log you in.'); else throw new Exception('Could not log you in - message 2.'); } This is were i originally tried to put it, then i made a function out of it itself, tried to call the function and stick the $decide into a session variable, then i tried to stick it into the login page: if ($usern && $pass) // if they have just tried logging in { try { switch ($usern) { case 'Ste': $bgi = yes; break; case 'Keith': $bgi = yes; break; case 'Dave.Fingers': $bgi = yes; break; case 'Ben': $bgi = yes; break; case 'Matt': $bgi = yes; break; default: $bgi = no; } return ('$decide = ' . $bgi . ';'); login($usern, $pass); // if they are in the database register the user id $_SESSION['valid_user'] = $usern; } catch(Exception $e) { require('head.inc'); // unsuccesful login echo 'You could not be logged in. You must be logged in to view this page.<br>'; echo '<a href="main.php">Back to main page...</a>'; require('foot.inc'); exit; } require('head.inc'); echo 'Hi ' . $usern . ' and welcome to the Members page. From this page you can control your settings associated with Kin-Kade.com. <br /><br />'; echo '<a href="main.php?<?php echo strip_tags(SID); ?>">Back to main page...</a><br /><br />'; echo $_SESSION['valid_user']; echo $decide; require('foot.inc'); } } ?> None of it works and it never prints the variable $decide, presumably because i have done something wrong that my stupid eyes and overlooking brain cant see. Please, Plllleeeeeaaaase help me.
  22. The url bit? Thats not part of the code, for some reason when i added that line the forum form changed it to that :/
×
×
  • 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.