bsamson
Members-
Posts
150 -
Joined
-
Last visited
About bsamson
- Birthday November 27
Profile Information
-
Gender
Not Telling
bsamson's Achievements
Regular Member (3/5)
0
Reputation
-
Hello. I am having a heck of a time figuring this one out. I have an array (output below) with info loaded. Everytime I run this, the output a blank page, no errors. Just curious, am I missing something? Thanks in advance for any help. print_r ($tmp_errors) output: Array ( [0] => cust_add1 ) <?php $styleForErrorBoxes = "style='border: 1px solid #FF0000'"; $tmp_errors = unserialize($result[0]['tmp_errors']); if ($tmp_errors) { if (array_key_exists('cust_email', $tmp_errors)) { $err_cust_email = $styleForErrorBoxes; } if (array_key_exists('cust_phone', $tmp_errors)) { $err_cust_phone = $styleForErrorBoxes; } if (array_key_exists('cust_first', $tmp_errors)) { $err_cust_first = $styleForErrorBoxes; } if (array_key_exists('cust_last', $tmp_errors)) { $err_cust_last = $styleForErrorBoxes; } if (array_key_exists('cust_add1', $tmp_errors)) { $err_cust_add1 = $styleForErrorBoxes; } if (array_key_exists('cust_add2', $tmp_errors)) { $err_cust_add2 = $styleForErrorBoxes; } if (array_key_exists('cust_city', $tmp_errors)) { $err_cust_city = $styleForErrorBoxes; } if (array_key_exists('cust_state', $tmp_errors)) { $err_cust_state = $styleForErrorBoxes; } if (array_key_exists('cust_zip', $tmp_errors)) { $err_cust_zip = $styleForErrorBoxes; } } echo $err_cust_add1; ?>
-
THANK YOU SO MUCH @Guru!!!
-
I'm running into some issues with cookies and after reading the documentation, I am still very confused on why the following code produces this output. Why is the cookie not deleted by using the second setcookie function? Any help is GREATLY appreciated. Code: <?php setcookie(custID, "Brian", time()+7200, "/"); echo "Cookie Value: ".$_COOKIE["custID"]."<br>"; setcookie(custID, "", time()-7200, "/"); echo "Cookie Value: ".$_COOKIE["custID"]; ?> Result: Cookie Value: Brian Cookie Value: Brian
-
Two tables, pull last record of table B that references table A
bsamson replied to bsamson's topic in MySQL Help
Essentially, I am trying to condense what can be achieved in nested while loops ... I believe the following loop will achieve what i'm looking for: $qry = "SELECT * FROM sapImport JOIN conStatus ON sapImport.id = conStatus.record WHERE store='3' AND conStatus.statusCode < '998'"; $res = mysql_query($qry); while ($row = mysql_fetch_array($res)) { $idNo = $row['id']; $customer = $row['customer']; $invoiceNo= $row['soldOn']; $ptn = $row['ptn']; $recID = $row['record']; $query = "SELECT * FROM conStatus WHERE record = '$recID' ORDER BY id DESC Limit 1"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)) { $record = $row['record']; $stCode = $row['statusCode']; } } Any suggestions? -
Two tables, pull last record of table B that references table A
bsamson replied to bsamson's topic in MySQL Help
Ah, I was hoping you'd be around to help with this one!!! If there is only one reference in the conStatus table to a customer in the sapImport table - it works as expected. However, if there is more than one reference in the conStatus to a customer record in the sapImport table - it returns zero rows. -
Two tables, pull last record of table B that references table A
bsamson replied to bsamson's topic in MySQL Help
I appreciate the help. Sadly as it's not that easy. The sapImport table contains customer information while conStatus simply tracks interactions with the customers from sapImport. So, in what I need here the soldOn row isn't used. -
Two tables, pull last record of table B that references table A
bsamson posted a topic in MySQL Help
I thought I had this issue figured out last night with the help from this forum, but turns out it still isn't working as expected. I have two tables: Table: sapImport id invoiceNo invoicedAtID invoicedAtName soldOn soldBy customer 1 CICIN123 3 Cicero 1384832632 brian john smith 2 DESTIN12 5 Destiny 1384832632 brian Henry Will 3 VESTIN32 3 Cicero 1384832632 jason Peter Jenn Table: conStatus id store record statusCode 34 3 1 0 35 5 3 0 39 3 1 15 I do have more rows than this, but i'm just trying to give an idea ... I currently have the following query: SELECT * FROM sapImport si INNER JOIN conStatus cs ON si.id = cs.record INNER JOIN ( SELECT record, MAX(id) as id FROM conStatus GROUP BY record ) mx ON cs.record = mx.record AND cs.record = mx.id WHERE cs.store='$storeID' AND cs.statusCode < '998' Basically, the table sapImport contains customer information and the conStatus table contains all interactions with a record in the sapImport table. The 'id' row in sapImport is the primary key and is auto-incremented. The 'record' row in conStatus references the 'id' row from sapImport. I need a query that pulls the LAST record (from conStatus) for a particular customer (from sapImport) where the store=x and the statusCode is less than 998. I should only get ONE result set with this. Any help will be GREATLY appreciated! Thanks in advance! -
@Barand - You are a genius my friend! Thank you SSOO much!!!! @SocialCloud - Thanks for your help as well.
-
Appreciate that. However, I don't want just one total row return. I need one row with the highest ID, then move on to the next match. Does that make sense?
-
Here's my database: Table: sapImport id invoiceNo soldOn 1 123456 11/18/2013 2 156541 11/15/2013 Table: conStatus id record statusCode 1 2 999 2 2 000 3 1 213 I have a query that looks like this: SELECT * FROM sapImport JOIN conStatus ON sapImport.id = record WHERE store = '2' So, the row record matches the ID in sapImport. I only want to display the latest record the corresponds to the row with the highest id. I've been trying to accomplish this for a few hours, but still can't figure it out. Any help is greatly appreciated!
-
Hello. I have a mysql database with an 'entrytime' field which contains the unix timestamp the record was added. How do I create a mysql query to select all records for a given month/year? For example, if I wanted to create a query to display all records for October 2010 how do I go about it? I am at a loss and can't find my answer via google. Thanks in advance for any help!
-
List files in a directory and grab the first filename
bsamson replied to bsamson's topic in PHP Coding Help
Found this great code that lists the file by timestamp ... exactly what I needed. Hope this helps someone else. define ("FILEREPOSITORY", "/home/nxsap/public_html/uploads/"); if (is_uploaded_file($_FILES['priceguide']['tmp_name'])) { if ($_FILES['priceguide']['type'] != "application/pdf") { echo "<p>Class notes must be uploaded in PDF format.</p>"; } else { $name = "priceguide"; $result = move_uploaded_file($_FILES['priceguide']['tmp_name'], FILEREPOSITORY."$name.pdf"); if ($result == 1) echo "<p>File successfully uploaded.</p>"; else echo "<p>There was a problem uploading the file.</p>"; } #endIF } #endIF -
Hello. I have a directory with files that look like this: priceguide_20100809.pdf priceguide_20100808.pdf priceguide_20100807.pdf priceguide_20100806.pdf I am trying to come up with a function that will grab and save the filename with the biggest date .. ie: priceguide_20100809.pdf. Any assistance would be greatly appreciated!!
-
THANK YOU!!!!! A "tired mans" mistake! Thanks again!
-
<? ## CONNECT TO DB FUNCTION! function ConnectTo($db2con) { $hostName = "localhost"; $dbName = "people_".$db2con; $userName = "people_main"; $password = "normal123"; $link = mysql_connect($hostName, $userName, $password) or die("Unable to connect to host $hostName"); mysql_select_db($dbName, $link) or die( "Unable to select database $dbName"); return $link; } $conn = ConnectTo("estore"); $query = "SELECT * FROM CubeCart_inventory"; $result = mysql_query($query) or die(mysql_error()); $num = mysql_num_rows($result); while ($row=mysql_fetch_array($result)) { $prod = $row['productId']; $cat = $row['categories']; } ?> I have the above code ... EVERYTIME it runs I get this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/people/public_html/code/xml/scripts/loadCatIDx.php I do not understand this problem! I understand the error is implying my query returned an error, however when I add echo mysql_num_rows($result) it returns over 2700 records ... Any help would be greatly appreciated!!