Jump to content

9three

Members
  • Posts

    411
  • Joined

  • Last visited

    Never

Everything posted by 9three

  1. If you don't want the user to go back just set your action to this: <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> Then put all your code in the same page, like so: if (isset($_POST['submit'])) { //The user clicked "submit" so do something... //Handle all your errors through here. } else { //The user has NOT clicked on "submit" so show the form instead } This will keep you on the same page even if the user has the wrong credentials.
  2. Hey, Just curious how everyone handles their inputs when using POST/GET methods? Some ways I've seen it is by just declaring them one by one: $username = $_POST['username']; $password = $_POST['password']; Also with a for each loop like so foreach($_POST as $key => $value) echo $value; I'm trying to figure out if there is a more advanced/efficient way?
  3. If it's giving you an error of "No database selected".... then you need to select a database? Check to make sure your db.php has a mysql_select_db function.
  4. I figured it out. I needed to remove the single quotes around the variables columnSort and viewSort Thank you.
  5. Hey, I'm getting this error: Warning: odbc_fetch_array(): supplied argument is not a valid ODBC result resource in C:\Users\Public\Desktop\Server\www\web\system_files\sql_class\_customer_purchase_history.class.php on line 34 Although the syntax looks correct. Could someone else lend a pair of eyes please? function get_prod_from_sql($New_ship = '', $columnSort = 'item_desc', $viewSort = 'ASC') { global $cust_account, $shipping_session, $shipping_id; $conn = odbc_connect(PROPHET_DATA_SOURCE, PROPHET_USER, PROPHET_PASSW); if($shipping_session > 0 || $New_ship > 0 ) { $prod_query = "SELECT * FROM jbi_web_cust_purch_hist WHERE customer_id = '" .(int)$cust_account. "' AND ship_to_id = '" .$shipping_session. "' ORDER BY '".$columnSort."' '".$viewSort."'"; } else { if ($New_ship == "Show_all") { $prod_query = "SELECT * FROM jbi_web_cust_purch_hist WHERE customer_id = '" .(int)$cust_account. "' ORDER BY '".$columnSort."' '".$viewSort."'"; } else { $prod_query = "SELECT * FROM jbi_web_cust_purch_hist WHERE customer_id ='" .(int)$cust_account. "' AND ship_to_id ='".$shipping_id."' ORDER BY '".$columnSort."' '".$viewSort."'"; } } $prod_conn = odbc_exec($conn, $prod_query); while($favorites = odbc_fetch_array($prod_conn)) { $part_number = $favorites['part_no']; $qty = (int)$favorites['qty_shipped']; $item_desc = $favorites['item_desc']; $ext_price = $favorites['ext_price']; $get_prod = db_query("SELECT products_id, short_code FROM " . TABLE_PRODUCTS . " WHERE part_number = '" . $part_number . "'"); $prod_res = db_fetch_array($get_prod); $this->contents[$favorites['part_no']] = array('qty' => $qty, 'products_id' => $prod_res['products_id'], 'prod_name' => $prod_res['short_code'], 'ext_price' => $ext_price, 'products_name' =>$item_desc);//adding element to the array contents } } Thanks
  6. I can't define the variable as the numbers will dynamically by the users total points. It could range from 0 to around 200 points. You get more points based on how many mines are around.
  7. Hey, I'm creating a simple Minesweeper game in Java for school. I'm having a small issue though. I don't know how to display an integer within a char variable. What I'm doing is checking the left, right, bottom and top for mines and if it's found increment the points for each mine. I'm using a bi dimensional array, Table[x ][y] (table is assigned as a char) and I'm printing it out. After adding all the points I want to display the points to that assigned coordinates (x, y). But I can't do Table[x ][y] == points as Table is searching for a character not an integer. I also tried doing Table[x ][y] = ' ' +points but that's a no go. Is there something I can do to display the points?
  8. That works perfect. But I'm confused by this concept, maybe I'm over complicating it (like always). If the remainder is '0' close the table row and open a new table row. Once you open the new table row, theres no value/variable within the new table row.... This is where I get confused.
  9. hmm.. That seems to do some-what of what I'm looking for. It displays the first 7, which is fine, but I if, for example, I have 14 in total, the next 7 would need to display under that. I've tried a couple of different solution but I haven't gotten the solution I'm looking for :-\
  10. Hey, I'm trying to display 7 columns and then stack the rest under each other so that it doesn't run off the page. echo '<table width="400" border="0" cellspacing="0" cellpadding="0">'; echo '<tr><td>'.CLOSE_OUT_MESSAGE.'</td></tr>'; echo '</table>'; echo '<table width="800" border="0" cellspacing="0" cellpadding="0">'; while($row = db_fetch_array($letterQuery)) { $tempLetter = explode(" ", $row['products_description']); if(!in_array($tempLetter[0], $used)) { $used[] = $tempLetter[0]; echo '<tr>'; for ($i = 0; $i < 7; $i++) echo '<td><a href="'.link_url(PAGENAME_FEATURES, 'featI4yrDauy=4&letter=' . $tempLetter[0]).'" >'.$tempLetter[0].'</a></td>'; echo '</tr>'; } } echo '</table>'; I've tried using a for loop to hit 7 and go down, but it repeats EVERYTHING 7 times. Help please?
  11. Hey, I'm running this: while($row = db_fetch_array($results)) { $tempLetter = substr($row['products_description'], 0, 1); echo '<a href="' . link_url(PAGENAME_PRODUCTS_DESCRIP, 'part_number=' . $row['part_number']) . '">'.$tempLetter.'</a>'; } echo '</div>'; What this does is pull the information from my DB and then I grab the first letter from each product description. What I'm trying to do is pull only the first letter AND display it ONCE. For example if the information pulled three letter Bs and 10 letter As, it should only display each letter once. Can someone lend a hand please?
  12. I figured it out. I had a typo in my constructor $this->database = $databse is suppose to be $this->database = $database. I forgot the 'a' :-\ thank you anway
  13. Hey, I created a method to allow me to pull the first 5 results in my database and display them. public function storeFront() { $mysqli = new mysqli($this->host, $this->user, $this->password, $this->database); $result = $mysqli->query("SELECT id, name, description, price, quantities FROM products LIMIT 5"); echo '<div id="newest">'; while ($row = $result->fetch_object()) { echo '<div class="block">' .'<b>Name: </b>' .$row->name. '<br />' .'<b>Description: </b>' .$row->description. '<br />' .'<b>Price: </b>'.$row->price.'<br />' .'<b>Quantities: </b>' .$row->quantities. '<br />' .'</div>'; } echo '</div>'; } I'm getting an error: Fatal error: Call to a member function fetch_object() on a non-object in C:\Users\9three\Desktop\Server\htdocs\cart\package\cart.php on line 28 line 28 is: while ($row = $result->fetch_object()) fetch_object() is the correct method and I seem to be passing it correct. Does anyone see where I went wrong?
  14. Hey, does anyone know a way to grab a part of a string or integer? $string = 'Hello World!'; $int = 123456789; The tricky part is that the string we always be different as well as the int. I want to pull the last 4 of that integer (6789) or the last 4 of that string (rld!) I'm not sure if there is a function for this?
  15. I tried doing this $mysqli = new mysqli('localhost', 'root', '', 'store'); $result = $mysqli->query("SELECT ID FROM products WHERE ID = '$input_id'"); if ($result == $input_id) return true; return false; But the same issue raises up again. id 1 works, but anything higher returns false.
  16. Got it. Thank you. $result = $mysqli->query("SELECT ID FROM products WHERE ID = '$input_id'"); I'm trying to re factor the loops because if I (for example)4,000 items then the function would need to place all those IDs into an array and then sort through it. I would imagine it would slow down the application a lot.
  17. Update: If the ID is 1 it works perfectly. If its anything bigger than that, it will not work.
  18. Hey I'm creating a simple shopping cart but I'm stuck trying to figure out why I'm not getting the output I'm looking for. function product_exists($input_id) { $mysqli = new mysqli('localhost', 'root', '', 'store'); $result = $mysqli->query("SELECT ID FROM products"); $array = array(); while ($row = $result->fetch_object()) { $array[] = $row->ID; } foreach ($array as $product_id) { if ($product_id == $input_id) return true; else return false; } } Basically what I'm trying to do is store all the IDs that are in my database into an array and compare the ID the user has given me. If it matches it needs to return true, else false. Here is the front side: $product_id = $_REQUEST['id']; if (product_exists($product_id)) echo 'Product Exist!'; else echo 'Not working yet'; It's echoing out Not working yet Can anyone lend a hand please?
  19. Your'e handling your arrays wrong. $array = array(); $array['FName'] = 'My First Name'; $array['LName'] = 'My Last Name'; //variable id will show FName. variable value will show whatever is in the quotes foreach ($array as $id => $value) { echo $value; }
  20. You can put it at the top of the page or in a seperate page. You will need a basic <form></form> tag for the html side of it and based on the names you provided for the fields, those will be the variable names. For example if you gave your field name name="firstname" then your variable for $firstname would look like this: $firstname = $_POST['firstname']; or $_GET whichever one you decide to use.
×
×
  • 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.