
jrobles
Members-
Posts
66 -
Joined
-
Last visited
Never
Everything posted by jrobles
-
import csv into mysql table and log record count fopen()
jrobles replied to jrobles's topic in PHP Coding Help
worked like a champ, thanks a million -
I have a script that imports the data from a csv file. before I insert into the table I want to log the import i.e. row count, import date, file name...etc. I got most of the the functions working, I am just having trouble getting the record count of the csv file. $link = connectToDB(); if(isset($_POST['submit'])) {$filename=$_POST['filename']; $handle = fopen("$filename", "r"); //LOG THE BATCH IMPORT $user=$_SESSION['SESS_MEMBER_ID']; $log_query="INSERT INTO batchImportLog(ImportDate,FileLocation,RecordCount, ImUserID ) VALUES(NOW(),'xxx','xxx','$user')"; mysql_query($log_query) or die(mysql_error()); //GRAB LAST ID FROM LOG TABLE $batchid=mysql_insert_id(); //INSERT EACH ROW INTO THE TABLE while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {$import="INSERT INTO inventoryTable(campcode,imbatchid, importdate,fname, mname, lname, phone, address1, address2, city, state, zip) VALUES('$data[0]','$batchid',NOW(),'$data[1]','$data[2]','$data[3]', '$data[4]','$data[5]','$data[6]','$data[7]','$data[8]','$data[9]')"; mysql_query($import) or die(mysql_error());} fclose($handle); print "Import done";} else {print "<form action='import.php' method='post'>"; print "Type file name to import:<br>"; print "<input type='text' name='filename' size='20'><br>"; print "<input type='submit' name='submit' value='submit'></form>";}
-
I have a FF plug in that does it, but I have to store the data manually in an excel spreadsheet. I have seen several php scripts online but of the three that I tested none of them worked, hence why I am here.
-
cURL to where google?
-
with my phalanges and a keyboard
-
I want to write a script that I can use to gather keyword rank statistics for SEO research. Ultimately I want to have the script run once a day and enter the stats into a mysql table. I have searched far and wide and have not found a script that a. works, or b. is free. The problem is, I dont even know where to get started in coding a script like this...any help?
-
damn, that worked like a champ. those little details always get me. Thanks a million for your help guys
-
Thanks a million for your help. I see the that the query is running but I have not submitted the form yet so it should not do anything until i hit the login button
-
sorry, I suck at life... this is my error: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/vg001web02/68/11/3001168/web/dev/bsp/includes/login.inc.php on line 6 I am not sure why its looking for mysql data because the login form has not been submitted yet. This error happens right off the back regardless of what page I am on. Here are the first 15 lines of login.inc.php <? //if($_SERVER[REQUEST_METHOD]=='POST') if (!$_POST['login']) { $sql="select * from products where id=$_POST[program]"; $program=mysql_fetch_assoc(mysql_query($sql)); //print_r($_POST); //print_r($program); $myAexxis=array( "q_system_key"=>$program[sitekey], "q_action"=>"CUST_AUTH", "q_cust_username"=>$_POST[username], "q_cust_password"=>$_POST[password] ); $myCust=new CRM;
-
no, the login form is being processed by the include which does some cURL stuff. The contact form has a quick if statement that says: if (!$_POST['submit']) {show form} else {process mail form} I tried using if (!$_POST['login']) on my login include instead of if($_SERVER[REQUEST_METHOD]=='POST') but that screwed with my include and caused an error a few lines down
-
not sure i follow your solution. How do i use the $_SERVER code with the hidden field?
-
I have an include that processes the log in form for located at the header of every page. The problem is, when it comes to my contact page now I have two forms. So when i process the contact form the header form is checked because the page is sending a post. Is there away that I can use the code below but only have it look at one particular form, so when any other forms are processed it ignores them? $_SERVER[REQUEST_METHOD]=='POST'
-
yeah my code doesn't have curl yet, I was looking for instructions on how to implement it, include or post to php file with curl code inside of it
-
I have a pretty basic form that I need to cURL post to a file in my includes folder (includes/login.inc.php). I have never used cURL and cant find any good tutorials online so you guys are my last resort here is the syntax for my very basic form: <form action='' method='post' enctype='multipart/form-datax'> <input name='username' type='text' value='username' id='textinput_login' /> <input name='password' type='password' id='textinput_login' /> <select name='program' id='ssl_login'> <option value='type3'>Choose Plan</option>"; if (mysql_num_rows($result_ssl) > 0) {while($row_ssl=mysql_fetch_object($result_ssl)) echo"<option value='$row_ssl->id'>$row_ssl->product</option>";} echo" </select> <input name='login' class='btn' type='submit' value='LOGIN' /> </form> Do I need to include the file that I am going to cURL post to? i.e. include_once ('login.inc.php'); , or do I need more php code to send the form values to my include?
-
no, thats the else statement that outputs the regular button with no sub menus and the class of 'menuitem'
-
I cant seem to put my finger on why this isnt working. I have a nested if statement that checks if there are sub categories in the menu_sub table. I am getting the following error Notice: Trying to get property of non-object in C:\wamp\www\BSP\includes\left_nav.php on line 26 this is my code //QUERY TO GET LEFT MENU ITEMS $query="SELECT* FROM menu WHERE type=2 ORDER BY sort ASC"; $result= mysql_query($query); echo"<div class=\"glossymenu\">"; if (mysql_num_rows($result)>0) {while($row=mysql_fetch_object($result)) //echo "<a class='menuitem' href='$row->url'>$row->text</a>"; //QUERY TO GET SUB MENUS $sub_query ="SELECT* FROM menu_sub WHERE menu_id = $row->menu_id"; $sub_result = mysql_query($sub_query); if (mysql_num_rows($sub_result)>0) {while($row_sub=mysql_fetch_object($sub_result)) echo "<a class='menuitem submenuheader' href='$row->url' >$row->title</a> <div class='submenu'> <li><a href='$row_sub->url'>$row_sub->text</a></li> </ul>} </div>";} else {echo "<a class='menuitem' href='$row->url'>$row->text</a>";} }//CLOSING TAG FOR LINE 10 else {echo"NO MENU ITEMS AVAILABLE";} echo "</div>"; line 26 is my first else where i refer to the rw from the first query {echo "<a class='menuitem' href='$row->url'>$row->text</a>";}