harristweed
Members-
Posts
346 -
Joined
-
Last visited
-
Days Won
1
harristweed last won the day on May 10 2018
harristweed had the most liked content!
About harristweed
- Birthday 03/01/1947
Contact Methods
-
ICQ
1
Profile Information
-
Gender
Male
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
harristweed's Achievements
Newbie (1/5)
1
Reputation
-
php mysql error for the right syntax to use near
harristweed replied to newphpcoder's topic in PHP Coding Help
I agree with PFMaBiSmAd: Try this: $Approved = isset($_POST['priority']); if ($Approved) { $lot_number = trim($_POST['lot_number']); $sr_number_ =trim( $_POST['sr_number_']); $SubQty = trim($_POST['SubQty']); $ItemCode = trim($_POST['ItemCode']); $picked_by = trim($_POST['picked_by']); $sql = "SELECT stock_item, qty FROM wms WHERE stock_item = '$ItemCode' AND lot_number = '$lot_number'"; $res = mysql_query($sql, $con) or die(mysql_error()); $row = mysql_fetch_assoc($res); $stock_item = $row['stock_item']; $qty = $row['qty']; if($qty >= $SubQty){ $output = $qty - $SubQty; $qty_withdraw = '0.00'; } else{ $output = '0.00'; $qty_withdraw = $SubQty - $qty; } } -
New to PHP and I'm getting "...unexpected T_VARIABLE in line 3"
harristweed replied to FoxRocks's topic in PHP Coding Help
all lines need to be closed with a semi-colon; -
I have an export that I use, here is the code, it might point you in the right direction: <?php include("variables.php"); $link_id = mysql_connect("$db_host","$db_user","$db_password"); if (mysql_select_db("$db_database", $link_id)); else { echo "connection failed."; } $select = "SELECT club_nr, first_name, surname, email, address1, address2, postcode, town, province, phone FROM members"; $export = mysql_query($select); $fields = mysql_num_fields($export); for ($i = 0; $i < $fields; $i++) { $header .= mysql_field_name($export, $i) . "\t"; } while($row = mysql_fetch_row($export)) { $line = ''; foreach($row as $value) { if ((!isset($value)) OR ($value == "")) { $value = " \t"; } else { $value=stripcslashes($value); $value = str_replace('"', '""', $value); $value = '"' . $value . '"' . "\t"; } $line .= $value; } $data .= trim($line)."\n"; } $data = str_replace("\r","",$data); if ($data == "") { $data = "\n(0) Records Found!\n"; } header("Content-type: application/x-msdownload"); header("Content-Disposition: attachment; filename=bridge_club_members.xls"); header("Pragma: no-cache"); header("Expires: 0"); print "$header\n$data"; ?>
-
Importing Large XML into PHP db, looking to create progress bar
harristweed replied to patsfans's topic in PHP Coding Help
Well, as I said, it worked for me. -
Importing Large XML into PHP db, looking to create progress bar
harristweed replied to patsfans's topic in PHP Coding Help
I did this some time ago and it seemed to work! set $i=0 outside of the 'loop' then have this code inside the 'loop' $i++; $nl=$i % 100; if($nl==0)echo"<br />$i Records processed<br />"; echo"|"; ob_flush(); flush(); -
Counting total different elements in a column
harristweed replied to absenm's topic in PHP Coding Help
$cDiff = mysql_query("SELECT COUNT(DISTINCT cCode) AS number FROM onlinenow"); -
I’d tackle your requirement like this…. <?php // date function function date2mysql($date){ $day=substr($date,0,2); $month=substr($date,3,2); $year=substr($date,-4); $date=$year."-".$month."-".$day; return $date; } //has the form been posted? if($_POST['submit']=="submit"){ //Get the old customer total $customer_count = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM table_name WHERE condition' "),0) ; // format the date and add posted info to database $date_to_mysql=date2mysql($_POST['datepicker']); //update database with post infomation $number_customers = $new_customers + $customer_count; //display totals echo "<p>Total customerrs =".$number_customers."</p>\n"; }else{ //display form echo "<form id=\"form\" action=\"$_SERVER[php_SELF]\" method=\"post\" >\n"; ?> <input type="text" name="form_stuff"> <input type="submit" name="submit"> </form>
-
I have a datepicker that is formatted to show dates dd/mm/yyyy to add them to mysql database I use a function to 'amend' the format: function date2mysql($date){ $day=substr($date,0,2); $month=substr($date,3,2); $year=substr($date,-4); $date=$year."-".$month."-".$day; return $date; } perhaps you could do something similar....
-
<?php if($_POST['formSubmit'] == "Submit") $varUserName = $_POST['username']; $varPW = $_POST['PW']; $varEmail = $_POST['email']; { $fs = fopen("testcsv.csv","a"); fputcsv($fs, array("$varUserName","$varPW","$varEmail","user","title",",category","some text '<a href=\"http://$varUserName.url.com/splash/\">site.com</a>'")); fclose($fs); exit; } ?>
-
try changing this line. to this: $query .= "WHERE branch = '$branch' ";
-
Have a look at: http://www.alohatechsupport.net/webdesignmaui/maui-web-site-design/easy_jquery_auto_image_rotator.html
-
<?php $array1 = array(1, 2, 3); $array2 = array(4, 5, 6); $array3=array_merge($array1, $array2); foreach ($array3 as $key => $value) { echo"key = $key value = $value<br />\n"; } ?>
-
I think that you can't use a GET in the query, Try $id=$_GET['id']; $sql = 'SELECT `car_year`, `car_name`, COUNT(*) as `total` FROM `company_inventory` WHERE owner_name = '.$userdata['user_name'].' AND warehouse_id = '.$id.' GROUP BY `car_name`, `car_year` ORDER BY `car_name` ASC'; $result = mysql_query($sql) or trigger_error($sql . ' has an error<br />' . mysql_error());