Jump to content

bulrush

Members
  • Posts

    185
  • Joined

  • Last visited

    Never

Everything posted by bulrush

  1. Looks like you will have to use PHP 4. This happens sometimes. This is unrelated to PHP, but when my dept upgraded from Adobe Distiller v6 to v7, we started having all kinds of problems with images in PDFs getting lines in them. An upgrade is not always a good thing. Does PHP use any unix libraries that might have been changed? Perhaps the setting is in an internet library at the unix level.
  2. Can't do that. Printout could be 10-50 pages or more. Customer won't do that. This process must be 100% automatic, no user intervention is possible.
  3. It worked! This is the only thing that worked. $partname = str_replace("\\f", "", "$partname");
  4. str_replace not working either. I tried: $partname = str_replace("\f", "", "$partname"); $partname = str_replace("\f", "", $partname); //No quotes around $partname All my other preg_replaces work, but I don't use backslash in any of them. It appears preg_replace and str_replace choke on a backslash.
  5. I've tried several variations of preg_replace to get rid of this string: "\f". But nothing seems to remove it. What am I doing wrong? Here is what I've tried. $partname=preg_replace('/\f/', '', $partname); $partname=preg_replace('/\\f/', '', $partname); This works fine in Perl, but not in PHP. In Perl you simply escape the backslash with another backslash.
  6. I have an HTML table which could span 10-50 pages. When I print this HTML page to the printer, how do I prevent the printer from printing part of a row on one page, and part on the next page? I do not rows to break across pages. Thanks.
  7. Shlumph, Can you think of a better design solution, as far as constructing the loops? I have a recordset ordered by prodname, prodsubname, and modelnumcat. These 3 variables form a group, which can have multiple modelnum's. So each time the group changes, I need to write a new table row. In the first column I write prodname, prodsubname, modelnum cat, then all model numbers. In the 2nd column I write out all bullet items related to this group. Any ideas? I've never done grouping manually like this.
  8. You're right. I can't go back one row. After reading the docs again, mysqli_data_seek() only jumps to an absolute row, not a relative row. I'm still stumped. It's not doing what I want.
  9. shlumph, My "LOOP2" is a DO loop, which executes the mysqli_fetch_array at the end of the loop, so I'm already waiting to get the next record at the bottom of the inside loop. I'm not sure what you mean. The mysqli_fetch_array needs to be part of the while condition in order to check for the end of the query set. Doing this: do { ... $row=mysqli_fetch_array(...) } while (($row) and ($oldgroup==$newgroup) and ($lcnt<=$MAXCNT)); did not exit the loop properly. Also, the $lcnt check is simply used to exit the loop early during debugging. crDebug displays data to the screen in a different color, and is used only for debugging.
  10. I believe there is a php.ini variable which controls the max downloadable file size. If the file is too large, your php.ini variable for timeouts might also take effect as the download operation (regarded as a single operation) has not completed yet. Look up the php.ini var for max downloadable file size and change it.
  11. I'v having trouble with a loop to group my results. I want to output multiple model numbers with a single model name but am having problems. I think if I go back one row when my model number loop (LOOP2) is done, that will fix my problem. How do I go back one row? Would "$b=mysqli_data_seek($result,-1)" work? Anyway, here is my code to construct a table. I want a new row when either $prodname, $prodsubname, or $modelnumcat changes. echo '<table border=1>'; $s='<tr valign="bottom"><td width="40%">'. //'<b>Product category</b><br/>'. '<b>Name</b><br/>'. 'Subname<br/>'. 'Model Number Category<br/>'. '<b>Model(s)</b><br/>'. '<td valign="bottom"><b>Bullets</b>'; echo "$s\n"; // Loop through the records, formatting it as HTML $oldprodname=''; $oldprodsubname=''; $oldmodelnumcat=''; $oldgroup=''; //Determines when we make a new group. $newgroup=''; $lcnt=0; //Count rows processed $MAXCNT=50; //Max records to show while (($row = mysqli_fetch_array($result)) and ($lcnt<=$MAXCNT)) { $partid=$row['partid']; $modelvar=$row['modelnum']; $modelnumcat=$row['modelnumcat']; $oldmodelnumcat=$modelnumcat; $prodname=$row['prodname']; $prodsubname=$row['prodsubname']; $newgroup=$prodname.$prodsubname.$modelnumcat; //$oldgroup=$newgroup; // Display new group if group changed. if ($oldgroup <> $newgroup) { echo "\n".'<tr>'; echo '<td valign="top">'; //echo crHtmlBold($row['prodcat']) . '<br/>'."\n"; $s='<b>'.$row['prodname'].'</b><br/>'; echo "$s\n"; echo $row['prodsubname'].'<br/>'."\n"; $s=$row['modelnumcat'].'<br/>'; //$s=$oldmodelnumcat; echo "$s\n"; //Loop through parts in this group. $oldgroup=$newgroup; do { //LOOP2 $partid=$row['partid']; $modelvar=$row['modelnum']; $modelnumcat=$row['modelnumcat']; $prodname=$row['prodname']; $prodsubname=$row['prodsubname']; $newgroup=$prodname.$prodsubname.$modelnumcat; if ($oldgroup==$newgroup) { $s=''; //$s.='('.$partid.') '; $s.=crHtmlBold($modelvar).'<br/>'; echo "$s\n"; $s='model='.$modelvar.', <br/>oldgroup='.$oldgroup. ', <br/>newgroup='.$newgroup; //crDebug($s); //DEBUG $lcnt++; } //$row=mysqli_fetch_array($result); } //while LOOP2 while (($row = mysqli_fetch_array($result)) and ($oldgroup==$newgroup) and ($lcnt<=$MAXCNT)); echo '</td>'."\n"; } //if $oldgroup <> $newgroup if (strlen($partid)==0) { $msg='Partid is missing: '.$partid.'<br/>'.$query; crError(basename($_SERVER['PHP_SELF']).' line '.__LINE__,$msg,true); } //Now show bullets for this part group. echo '<td valign="top">'; //Start bullets $query2="SELECT bullettext FROM bullets WHERE partid=".$partid; $query2.=" ORDER BY bullid"; $query2.=";"; //crDebug($query2); //DEBUG echo '<ul>'; if (!$result2=mysqli_query($dbc,$query2)) { $msg=mysqli_error($dbc); $msg.=$query2; crError(basename($_SERVER['PHP_SELF']).' line '.__LINE__,$msg,true); } $num2=mysqli_num_rows($result2); if ($num2==0) { //$msg='No bullets found for partid='.$partid.'<br/>'.$query2; //crError(basename($_SERVER['PHP_SELF']).' line '.__LINE__,$msg,false); $msg='(No bullets)'; echo "$msg\n"; } while ($row2 = mysqli_fetch_array($result2)) { // Display the bullets $b=$row2['bullettext']; //$b=preg_replace('/</','<',$b); //$b=preg_replace('/>/','>',$b); $b=preprocall($b); echo '<li>'.$b.'</li>'; } # while $row2 (bullets) echo '</ul></td>'; echo '</tr>'."\n"; //$lcnt++; $oldgroup=$newgroup; } # while echo '</table><p/><p/>'."\n";
  12. I have a table with 600+ rows. When I print it, some rows are deep and part of the row prints on the first page, the rest of the row prints on the next page. How do I prevent the row from breaking between pages when I print the page to a printer? Thanks.
  13. It's not working. I have a file style.css which contains, among other things, this: .inputfont { font-family: arial; font-size: 12pt; } I construct the <textarea> in my php file like this: while ($rowbull = mysqli_fetch_array($resbull)) { $b=trim($rowbull['bullettext']); $bid=$rowbull['bullid']; $s='<tr valign="top"><td valign="top">Bullet: <td><textarea name="txtBullet[]" '. 'id="txtBullet[]" rows="2" '. 'cols="60" class="inputfont" >'.$b.'</textarea> '; $s.='<input type="hidden" name="txtBullid[]" id="txtBullid[]" value="'.$bid.'" size="6" readonly />'; $s.='</tr>'; echo "$s\n"; $oldbullarr[]=$b; $oldbidarr[]=$bid; $cnt++; } //while ($rowbull... I tried spelling the font "Ariel" and "Arial". The font in the <textarea> didn't change. Does capitalization matter? How can I find out the correct spellings (and capitalizations) of the fonts my browser (Firefox 3.6 on WinXP) uses?
  14. I have a form that uses some text boxes (type="text") and some <textarea> boxes. The font in the text boxes appear to be Ariel, but the font in the <textarea> are always some type of Courier. How do I get the fonts to be all the same in all my controls in the form? Here is some sample code I am using: $s='<tr><td>Product name: <td><input type="text" name="txtProdname" '. 'id="txtProdname" value="'.$row['prodname'].'" size="50" maxlength="50" /></tr>'; echo "$s\n"; $s='<tr valign="top"><td valign="top">Bullet: <td><textarea name="txtBullet[]" '. 'id="txtBullet[]" rows="2" '. 'cols="60" >'.$b.'</textarea> '; $s.='<input type="hidden" name="txtBullid[]" id="txtBullid[]" value="'.$bid.'" size="6" readonly />'; $s.='</tr>'; echo "$s\n";
  15. Thank you. I fixed it. MY code now looks like this: if (isset($_POST['cmdImport'])) //Save records that were changed. { $filename=$_POST['txtFilename']; //File on user's machine. $b=$_FILES['txtFilename']['name']; //$s='You are importing '.$_FILES['txtFilename']['tmp_name']; //$s.=', basename='.$b; //$s.=', txtFilename-name='.$_FILES['txtFilename']['name']; //crDebug($s); //DEBUG $dest='upload/'.$b; if (move_uploaded_file($_FILES['txtFilename']['tmp_name'], $dest)) { $filename=$_FILES['txtFilename']['name']; $s='Received '.$filename; crInfomsg($s); } else { $errmsg='File upload failed. Error is '.$_FILES['txtFilename']['error']; crError($_SERVER['PHP_SELF'].' line '.__LINE__,$errmsg,true); }
  16. First, my goals: - The user selects a text file on their local PC (or their local network drive) to process. - I want to read the file into an array and process it. I'm having trouble with this. Here is my code so far: <?php session_start(); $title='Import File v.10a'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php echo '<title>'.$title.'</title>'; ?> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <?php require_once('navmenu.php'); echo '<h2>'.$title.'</h2>'; ?> <!-- comment --> <?php // Connect to the database $dbc = mysqli_connect($host, $user, $password, $database); $errcnt=0; $models=array(); //Init array $bullarr=array(); $model=''; $partname=''; $partsubname=''; $image=''; $ptype=''; //Product type in {type} tag. if (isset($_POST['cmdImport'])) //Save records that were changed. { $filename=$_POST['txtFilename']; //File on user's machine. $s='You are importing '.$filename; crDebug($s); //DEBUG if (move_uploaded_file($_FILES['txtFilename']['tmp_name'], 'upload/')) { $filename=$_FILES['txtFilename']['name']; $s='Received '.$filename; crInfomsg($s); } else { $errmsg='File upload failed. Error is '.$_FILES['txtFilename']['error']; crError($_SERVER['PHP_SELF'].' line '.__LINE__,$errmsg,true); } if (!(file_exists($filename))) { $errmsg='File '.$filename.' does not exist. Cannot continue.'; crError($_SERVER['PHP_SELF'].' line '.__LINE__,$errmsg,true); } else { } } //if isset($_POST['cmdImport'] ?> <!--------------------------------------------------------> <form action="<?php echo $_SERVER['PHP_SELF'].'?'.SID; ?>" method="post"> <hr/> <label for="cbxBrand">Pick one Brand</label> <?php $oldbrandarr=array(); //Init array. //Do query and loop here. //Show brands from zzbrands. $query = "SELECT bzz ". "FROM zzb ". "ORDER BY br ". ";"; //crInfomsg($query); //DEBUG crCreateSelect($query, 'cbxBrand', 'brand') ?> <p>Input file: <input type="file" name="txtFilename" id="txtFilename" value="" size="80" /> <br/><input type="submit" value="Import" name="cmdImport" /> </form> </body> </html> My problem is I get an error each time "File upload failed" which is displayed above when I try to do move_uploaded_file(). I'm not experienced processing text files. Can someone help me or point me to a website? One more thing, the subdir "upload" is located at the same level as this php file. That is where the uploaded files will go temporarily.
  17. Do you want a Top Level Domains instead? There are the standard TLDs like: .edu, .com, .org, .biz and there is a TLD for each country. .uk for UK, .us for USA, .can for Canada, etc.
  18. This is related to how PHP processes checkboxes in a form. I have a checkbox in a form called chkNewpart: $s='<tr><td>Model: <td><input type="text" name="txtModelnum" id="txtModelnum" value="'.$row['modelnum'].'" size="20" maxlength=15 />'; $s.=' New part? <input type="checkbox" name="chkNewpart" value="'.$newpartvar.'" '; $s.='checked="'; if ($newpartvar==1) { $s.='checked'; } $s.='" />'; $s.='</tr>'; In my db, the field that holds this value is a tinyint, and the default is 1, which stands for true. So when I display the checkbox, if the value of the field is 1, then the box should be checked. That part works. The problem I have is when I uncheck the box and save the checkbox to a php variable, and then the database field. $newpartvar=$_POST['chkNewpart']; ... $query = "UPDATE parts SET modelnum='".$modelvar."', ". "prodcat='".$prodcatvar."', ". "prodname='".$prodnamevar."', ". "prodsubname='".$prodsubnamevar."', ". "newflag="; if ($newpartvar==1) { $query.="1"; //True } else { $query.="0"; //False } $query.=", "; $query.="updateuser='".$_SESSION['username']."', ". "updatedate=NOW() ". "WHERE partid=".$partidvar.";"; I get no errors but php doesn't seem to change the field value, when I look at it in PHP Admin. How do I handle the values of checkboxes properly? I'd like 1 to be true and 0 to be false.
  19. Thank you! I fixed it. I had copied this file from another app, which used a different database. I was simply using the wrong database name. Plus I am now using mysqli_error in crqryDelete().
  20. I'm trying to execute a SELECT query to see if a record exists before I delete it. Here is the code in my calling program, which calls my routine called crqryDelete(). $query='bid='.$bid; $num=crqryDelete('zzbrands',$query); //if (!$result) if ($num<=0) { $msg=mysql_error(); $msg.='Could not DELETE brand '.$brand.'<br/>'.$query; //There was an error. $msg.='num='.$num; crError($_SERVER['PHP_SELF'].' line '.__LINE__,$msg,true); mysqli_close($dbc); } Here is my utility program to delete the record. Note that 6 weeks ago this crqryDelete worked fine. //==================================================== function crqryDelete($table, $where) //Run a DELETE query. //Returns: records deleted //Ex: $table='parts' //$where='pid=10' { global $dbc; if (strlen($table)==0) { $s='You cannot have a blank table name in param 1. No action taken.'; crError(__FUNCTION__,$s,true); return 0; } if (strlen($where)==0) { $s='You cannot have a blank WHERE clause in param 2. No action taken.'; crError(__FUNCTION__,$s,true); return 0; } //First select records to get count of records affected. $n=0; //Do query and loop here. $query = "SELECT * FROM $table WHERE $where;"; if (!$result=mysqli_query($dbc,$query)) { $msg=mysql_error(); $s=$msg.$query; crError(__FUNCTION__,$s,true); } $num=mysqli_num_rows($result); if ($num<=0) { return $num; } $query='DELETE FROM '.$table.' WHERE '.$where; //crDebug('crqryDelete: ',$query); //DEBUG if (!$result=mysqli_query($dbc,$query)) { $msg=mysql_error(); $s=$msg.$query; crError(__FUNCTION__,$s,true); } return $num; //crqryDelete } Here is the error I'm getting when I run this code: ERROR in crqryDelete: SELECT * FROM zzbrands WHERE bid=13; What is wrong with this SELECT statement? Is "bid" a reserved word? The field "bid" is a longint, auto increment. Thanks.
  21. Thanks! Got it working. I did have to use the mysqli version.
  22. It's not working. I'm using: $dbc = mysqli_connect($host, $user, $password, $database); And: $partidvar=mysqli_insert_id($dbc); //Get key field of last INSERT statement. if (strlen($partidvar)==0) { $msg=mysql_error().'Could not get last partid.<br/>'.$query; //There was an error. crError($_SERVER['PHP_SELF'].' line '.__LINE__,$msg,true); } Should I use: mysqli_insert_id($dbc)?
  23. So that returns the key field value of the previous INSERT statement in SQL? The autoinc field is the only key field.
  24. - I am inserting a new record into a table called "parts". The key field is "partid", which is autoincremented. - After I do the insert, how do I get the value for partid for the new record? I cannot select the record because there are no unique combinations of fields to select on. Here is my code to insert the new record into table "parts". //Insert new part. $query="INSERT INTO parts (modelnum, prodcat, ". "prodname, prodsubname, createuser, createdate) " . "VALUES ( ". "'".$modelvar."', " . "'".$prodcatvar."', ". "'".$prodnamevar."', ". "'".$prodsubnamevar."', ". "'".$_SESSION['username']."', ". "NOW() ". ");"; $result=mysqli_query($dbc,$query); if (!$result) { $msg=mysql_error().'<br/>Could not run SELECT. '; //There was an error. crError($_SERVER['PHP_SELF'].' line '.__LINE__,$msg,true); } else { $s='Inserted new product cat='.$prodcatvar.', model='.$modelvar; crInfomsg($s); } } Thank you.
  25. Hmm. I made the changes you showed above. This JS function valDate is not even getting called because my alert() function inside it is not firing. What am I doing wrong? Here's my code. <script type="text/javascript"> function valDate(fieldObj) { var arr=new Array(); var dt=new Date(); arr=fieldObj.value.split('/'); alert('Arr length='.arr.length); //DEBUG if (arr.length < 3) //If missing year... { fieldObj.value+='/' + dt.GetFullYear().toString(); //Append current year } else { fieldObj.value='yay!'; } return; } //valDate </script> My html now looks like this: $s='<td><input type="text" name="txtDate[]" id="txtDate[]" '. 'value="" size="8" onblur="valDate(this)" />'; //$s.='<div type="text" id="datepicker"></div>'; echo "$s\n";
×
×
  • 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.