Jump to content

scott.stephan

Members
  • Posts

    53
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

scott.stephan's Achievements

Member

Member (2/5)

0

Reputation

  1. //Send off the Rec to be written $qry_new_rec = "INSERT INTO scores(grade,section,group,group_name,year,semester,u_id) VALUES($grade,$section,$g_num,$g_name,$year,$semester,$u_id)"; $result = @mysql_query($qry_new_rec); echo "Rec written?"; Assuming that all of those variables are named correctly and have values, why won't this write a record? I feel like I'm overlooking something major and I just cant see it. This runs fine without any errors, but it doesn't create a new record. Here;s the rest of the (sloppy sloppy) code: require_once('config.php'); //DB settings ini_set('display_errors',1); error_reporting(E_ALL|E_STRICT); /* Open DB Connect */ //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } if($link){ echo "Successful DB connect"; } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } /*END DB CONNECT */ /*Nab the POST data. Yes, I know this is sloppy, but it'll do for Alpha */ $semester=ucfirst($_POST['semester']); //Move to ALLCAPS to ascertain u_id predicatbility. $grade=$_POST['grade']; $section=$_POST['section']; $g_num=$_POST['g_num']; $g_name=$_POST['g_name']; $year=date('y'); //Compile a unique ID for a group: GradeSectionNumberSemesterYear, i.e 612F09 for Grade 6 Section 1 Group 2 Fall of 2009 $u_id=$grade.$section.$g_num.$semester[0].date('y'); echo "Semester: $semester <br/> Grade: $grade <br/> Section: $section <br/> Group Num: $g_num <br/> Group Name: $g_name Unique ID: $u_id"; //Send off the Rec to be written $qry_new_rec = "INSERT INTO scores(grade,section,group,group_name,year,semester,u_id) VALUES($grade,$section,$g_num,$g_name,$year,$semester,$u_id)"; $result = @mysql_query($qry_new_rec); echo "Rec written?";
  2. Is the way to do this to: -GET the file -Write it locally -FTP it back to the archive folder -DELETE the original remote file ?
  3. Here's what I'd like to do- I have no problem formatting an ftp_get() and using it to nab a file from server x. WHat I'd like to do is then move that file from 'serverx/stufftoget' to 'serverx/stufftoget/archives' or something like that. Is there a command to MOVE a file that's remote?
  4. Great. I actually have a series of rows like A D D F And each requires a different kind of processing, so I just wanted to be able to say if($data[0] == 'A'){ process_a_row($data); }
  5. When using fgetcsv, you get an array of results. Let's call it $data. I believe I have this correct- $data is JUST the result for a ROW of a CSV, not the entire CSV, correct? IE- If there are 5 rows of data with 5 columns each, count() will return "5" not "25", correct?
  6. I have a small issue- Everyday a .csv file is published to a server. This .csv file has an unpredictable name, but it does show up everyday at the same time and after it's processed it gets moved to an "Archive" directory. Is it possible to tell PHP "Look for any new *.csv" file. As far as I can tell, the fgetcsv requires a $handle. Is there a way to read the directory and get the name of the CSV sitting in it?
  7. I know PHP is capable of writing a file and SENDING it somewhere. Is it possible to have PHP, with the proper credentials, go OUT to an FTP and PICK UP a file? Or is that a no-no?
  8. Ugh. Really? I can be so dumb sometimes. Thanks a bunch!
  9. I currently have a little test I'm trying to run and hitting a wall. <?php $header_img_urls=array('http://ilovepr.com/media/upload/image/tile1(1).jpg','http://ilovepr.com/media/upload/image/vegg-tile.jpg','http://ilovepr.com/media/upload/image/tile2(2).jpg'); $rand_img=rand(0,count($header_img_urls)-1); $url=$header_img_urls[$rand_img]; ?> "gfgcv"; <?php echo $url; ?> <h1><img alt="" src="<?php $url; ?>" /> </h1> It echos fine, but it never outputs anythig to the "src". It comes up blank everytime. What stupid thing am I missing?
  10. Problem solved. It was a different, similar clause: $querybol="SELECT * FROM $T_NAMES[1]] WHERE po_num='$curr_po_num'"; Where I had an extra goofy bracket. I swear, I struggle with these things for like 40 minutes, post ot here and then solve it 30 seconds later. Is there some kind of ESP stuff going on?
  11. I have a function I pass an array to do some stuff with. Here's the array initialization, plus the clause giving me trouble: if($type == 'acknowledge' || $type == 'view'){ $table_name[0]="new_batch"; $table_name[1]="bol_new"; $table_name[2]="lots_new"; } bol_display($table_name, $curr_po_num); And here's what gives me a problem: $queryall="SELECT * FROM $T_NAMES[0] WHERE po_num='$curr_po_num'"; $result=mysql_query($queryall) or die(mysql_error()); And the error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '] WHERE po_num='777MCLANE'' at line 1 If I change it to $queryall="SELECT * FROM '$T_NAMES[0]' WHERE po_num='$curr_po_num'"; , I get You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''new_batch' WHERE po_num='777MCLANE'' at line 1 It looks like I'm getting an extra " ' " in there. Any idea where? What's my goof here?
  12. Ugh. Why did that never occur to me? Thanks so much. Solution: Don't be a goof
  13. I cannot figure out what's going on here. Basically- If the SAU ("Saleable Unit") is equal to CS (Case) or PK2 (Pack of 2), the Category should be W (Wholesale) Else, if the SAU is EA ("Each"), Category should be "C" (Consumer). But EVERYTIME, even if the SAU is = "EA" it defaults to "W". What's going on here?! //Get category type- Wholesale Orders will ALWAYS be in CS/PK2, Consumer will ALWAYS be in EA. $sau=$row[sau_ID]; $category=""; echo "SAU is $sau <br/>"; //I THINK THE ORS ARE THE ISSUE if($sau == 'CS' || 'PK2'){ $category="W"; } else if($sau == 'EA'){ $category="C"; } Here's the output: CURR SKU IS 17020001 with [b]SAU EA[/b] MULTIPLIER IS: 1 SKU BEFORE STR REPLACE Seriously Strawberry Jam SKU AFTER STR REPLACE Seriously Strawberry Jam PRE EXPLODE NOTES ARE: B LINE: 17020001,Seriously Strawberry Jam,1,1 FULL LINE: 100367,07/17/2009,W,5, , ,SWU11, ,100164,FAKE NAME,45 FAKE Street ,New FAKESVILLE,NY,66666,USA,FAKE NAME,FAKE,45 FAKEStreet ,FAKECity,NY,66666,USA,FAKENAME, ,17020001,Seriously Strawberry Jam,1,1 I cannot figure out what's happening. Help!
  14. SKU BEFORE STR REPLACE Three Seas Ship-CR,WC,DC SKU AFTER STR REPLACE Three Seas Ship-CR WC DC There we go. With code: $replace=array(","); $desc_init=$row_itm[itm_desc]; echo "SKU BEFORE STR REPLACE $desc_init <br/>"; $desc=str_replace($replace," ",$desc_init); //A few SKUs have commas in them. They drive the CSV bonkers. We pull them here. echo "SKU AFTER STR REPLACE $desc <br/>"; echo "PRE EXPLODE NOTES ARE: $notes <br/>";
  15. Stupid- I meant to strip the commas out of another variable. Ugh. Works now. Thanks!
×
×
  • 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.