premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
echo " ".$row['subject']." ".$row['data']."<br>"; Will produce 3 spaces between the subject and data. Also note that you have {} instead of [ and ] Arrays should be called using the [ isntead of {.
-
Are you closing the with fclose ? As far as I can tell it should. You may want to use curl to fetch the feed as that tends to be quicker and possible more reliable. Also a note, for anyone trying to help, the url goes to pr0n, so be wary at work/school etc.
-
For it to display on a webpage, you would need to use and strpad will be your best friend. If it is to be displayed in a text file, strpad is still the way, but instead of just use the regular space character. echo " ". strpad($row{'subject'}, 10, " ") . $row{'data'}."<br>"; EDIT: I remember having issues with this using the so I am not sure if that will work in this case. If not just manually add them in.
-
Try this out. It uses the HEREDOC syntax to help with less confusion. I also removed all the extra going in and out of php and echos. This way you only have to echo once, and one echo is quicker than 20. <?php $date=date("m,d,Y"); $ID=$_GET['ID']; $result = mysql_query("SELECT * FROM clients WHERE ID = $ID"); while($myrow = mysql_fetch_assoc($result)) { $output = '"0","0","0","0028836"\n'; $output .= <<<INFO "1","37","1","{$myrow['First_Name']} {$myrow['Middle_Name']} {$myrow['Last_Name']}","{$myrow['Phys_Street']}", "{$myrow['Phys_City']}","{$myrow['Phys_Zip']}","34","","35","{$myrow['Phone']}\",\"1\",\"2\",\"CA - FSC RATER\" ,"{$date}","1641","32","{$myrow['Employer']}","{$myrow['Emp_Street']} {$myrow['Emp_City']} {$myrow['Emp_State']} {$myrow['Emp_Zip']}" ,"","","{$myrow['Mail_Street']}","{$myrow['Mail_City']}","{$myrow['Mail_Zip']}","2","{$myrow['Agent']}" ,"TV","0","1","1","0","0","0.00","0.00","0","0","0","{$date}" . '","P","","207","0","0","0" ,"{$myrow['First_Name']}","{$myrow['Last_Name']}","Topa","1168.00","{$date}","A","0","{$myrow['Emp_Street']}","{$myrow['Emp_City']}" ,"{$myrow['Emp_State']}","{$myrow['Emp_Zip']}","0.00","CA","207","1129.00","39.00","0.00","{$date}" INFO; } // unsure why this was in the loop... header("Content-Type: application/force-download"); header( "Content-Type:text/octet-stream" ); header('Content-disposition: attachment; filename="client.dat"'); echo $output; ?> Also moved the header items outside of the loop, I do not know why you put them in the loop in the first place.
-
<span class="style3"><a href="<?php echo $website; ?>" target="_blank"><?php echo $website; ?></a></span><br /></span><br /><br /> Yep...try it out. You may save yourself some time by trying it first
-
It has been discussed...as such you can find them by searching "profile" in the PHP Help forums. I will not do that for you. A quick google search yielded this: http://www.astahost.com/info.php/how-create-user-profile-page_t18716.html
-
The issue you are having is websites with just www that are hyperlinked will have the current site's address auto added. To prevent this, add http:// and it will be fine. But make sure your links in the DB do not have the http:// if they do this will cause an issue. <span class="style3"><a href="http://<?php echo $row_Recordset1['website']; ?>"><?php echo $row_Recordset1['website']; ?></a></span><br /></span><br /><br /> Alternatively, if you have mixed in the DB, this will solve that issue. <?php do { $website = (stristr($row_Recordset1['website'], "http://") !== false)?$row_Recordset1['website']:"http://" . $row_Recordset1['website']; ?> <tr> <td width="244"><span class="style4"><?php echo $row_Recordset1['company']; ?></span><br /> <span class="style3"><?php echo $row_Recordset1['address']; ?></span><br /> <span class="style3"><?php echo $row_Recordset1['city']; ?></span><span class="style3">,</span><span class="style3"><?php echo $row_Recordset1['state']; ?></span><br /> <span class="style3"><?php echo $row_Recordset1['phone']; ?></span><br /> <span class="style3"><a href="<?php echo $website; ?>"><?php echo $website; ?></a></span><br /></span><br /><br /> <td width="55" colspan="4" align="center" valign="middle"><?php echo "<img src=http://www.fortwaynerestaurant.net/images/".$row_Recordset1['photo'] ."> "; ?><br/></td> </tr> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> The ? and : in the $website statement is called the ternary operator and is basically a shortened If/Else statement.
-
Did you not try this out? It does exactly what you are asking. Except, instead of it being kept in an array as that form, it converts it at runtime so the data stays in it's raw form and is not manipulated till it needs to be displayed.
-
[SOLVED] Retrieving info from a table on a web page, how can I do that?
premiso replied to John_S's topic in PHP Coding Help
strip_tags on the data... <?php $cols = array(); // initiate the array. foreach($entries AS $entry) $cols[] = rim(strip_tags($entry)); // remove the html tags and trim for good measure. echo "<pre>", print_r($cols), "</pre>"; ?> -
keepin the form values even while reloading it
premiso replied to yami007's topic in PHP Coding Help
Do not try to, it is rubbish and bad programming. Can you post your current code (the one you modified to use sessions?)? Thanks. -
To elaborate, since you did not post your form, this is kind of difficult. Are the values you want to replace in the body coming from the form? If so, this may work: //foreach($HTTP_SESSION_VARS as $key => $value) { // print "\$HTTP_SESSION_VARS[".$key."] = $value \n"; // $mail_body=str_replace($key,$value,$mail_body); //} foreach ($_POST as $key => $val) { $mail_body=str_replace($key,$val,$mail_body); } $mail_body=str_replace("ipnumber",$ipnumber,$mail_body); // use quotes around items like that, leaving them off causes an undefined constant notice. Basically when you were defining the $mail_body and doing the replaces, you were using $formitem instead of $_POST['formitem']. For POST and GET data sent from URL/FORMS you should access them via $_POST or $_GET from now on, as the other will not work anymore.
-
I take it you are doing a full text search. MySQL FullText Search Reference Read up on it there. More predominately at the 11.8.1. Natural Language Full-Text Searches Check your test data, make sure that no more than 49% of the rows are being returned or else you will not get any results.
-
[SOLVED] getting a eval() to return a bool resault
premiso replied to M.O.S. Studios's topic in PHP Coding Help
I did not think output buffering would work, but I was wrong. Here is another way (I would still check/filter the syntax being eval'd for security reasons). <?php $syntaxCheck = array('$format = $x + $y;', '$format = $x .. $y ..;'); foreach ($syntaxCheck as $syntax) { if (validSyntax($syntax)) echo "{$syntax} contains valid syntax"; else echo "{$syntax} does not contain valid syntax"; echo "<br />"; } function validSyntax($php) { $evalStr = 'return;'; // Stop the browser from receiving output. ob_start(); $test = eval($php); $evaluput = ob_get_clean(); // Run if output was received if(!empty($evaluput)) { // if parse error is in the string, return false if(stristr($evaluput, "PARSE ERROR")) return false; } return true; } ?> Preference, at least in my opinion, would still be the CLI, so if that becomes available I would use that over this. As it does not actually execute the code, just parses it. -
[SOLVED] Parse Error: Unexpected $end - Error
premiso replied to JeanieTallis's topic in PHP Coding Help
Bottom left hand corner above the "Quick Reply". -
[SOLVED] Is it ok to have about 7 include files on your php pages?
premiso replied to limitphp's topic in PHP Coding Help
No, it will not. The .inc is optional, it is just a naming convention I use. You can have as many periods as you want in a file name, all the name cares about is the last x characters after the . which describe what type of file it is. -
[SOLVED] Count number of images in a directory
premiso replied to alconebay's topic in PHP Coding Help
Using glob would be much easier, especially since it allows for you to choose. Look into that, it would be something like: <?php $dir = "folder/".$client."/"; if(is_dir($dir)) { $images = glob($dir . "{*.jpg, *.JPG, *.jpeg}"); echo "There are " . count($images) . " inside of {$dir}."; } ?> -
[SOLVED] Is it ok to have about 7 include files on your php pages?
premiso replied to limitphp's topic in PHP Coding Help
If it was me, I would include the files in an include file. This way you only have one include to do each page: IE: maininclude.inc.php <?php include("inc_set_root.php"); //....for pages that get mod rewrited.... include("inc_connGreckle.php"); //....about 4 lines..... include("inc_global_functions.php"); //....actually, just one function in there right now...pretty short include("inc_login_script.php"); ?> index.php <?php include('maininclude.inc.php'); // now only 1 line required for each file ?> -
[SOLVED] getting a eval() to return a bool resault
premiso replied to M.O.S. Studios's topic in PHP Coding Help
A quick fix to my code: <?php $syntaxCheck = array('$format = $x + $y;', '$format = $x .. $y ..;'); foreach ($syntaxCheck as $syntax) { if (validSyntax($syntax)) echo "{$syntax} contains valid syntax"; else echo "{$syntax} does not contains valid syntax"; echo "<br />"; } function validSyntax($syntax) { $path = explode("/", $_SERVER['SCRIPT_FILENAME']); array_pop($path); $path = implode("/", $path); $fh=fopen("syntaxTest.php", "w"); fwrite($fh, "<?php\n{$syntax}\n?>"); fclose($fh); // note if the below does not work make sure php is in the environment variable as a path. exec("php -l {$path}/syntaxTest.php", $result, $res); unlink("syntaxTest.php"); return ($res == -1)?false:true; } ?> Modified the exec line. -
You are missing the second period on everything after the job name. Make it look exactly like the job id and job name for each sequential line.
-
[SOLVED] getting a eval() to return a bool resault
premiso replied to M.O.S. Studios's topic in PHP Coding Help
Your question is clear. The answer is even clearer. No you cannot. That is your answer. You may want to do some research on how exec works so you can use that to evaluate the code. With PHP CLI you can test code for errors. This way it is not necessarily ran, just parsed to make sure there are no issues with it. <?php $syntaxCheck = array('$format = $x + $y;', '$format = $x .. $y ..;'); foreach ($syntaxCheck as $syntax) { if (validSyntax($syntax)) echo "{$syntax} contains valid syntax"; else echo "{$syntax} does not contains valid syntax"; echo "<br />"; } function validSyntax($syntax) { $path = explode("/", $_SERVER['SCRIPT_FILENAME']); array_pop($path); $path = implode("/", $path); $fh=fopen("syntaxTest.php", "w"); fwrite($fh, "<?php\n{$syntax}\n?>"); fclose($fh); // note if the below does not work make sure php is in the environment variable as a path. exec("D:\wamp\bin\php\php5.2.9-1\php -l {$path}/syntaxTest.php", $result, $res); unlink("syntaxTest.php"); return ($res == -1)?false:true; } ?> Although I am against doing this for someone, I just wanted to see for myself if it would work. Which it does. -
echo'<P>JOB ID:</P>' . $data['job_id']; echo'<P> JOB NAME:</P>' . $data['job_name']; You had a semi-colon after the echo statement, instead use a period for concatenation and it should work for you.
-
array Take a look at the array functions, notably next. That will, however, move the array pointer. So you may have to use previous after you assign the next values to set the array pointer to what you expect it to be.
-
Please Read before posting here for PHP Help
premiso replied to revraz's topic in PHPFreaks.com Website Feedback
PLEASE READ BEFORE POSTING HERE It used to be in the PHP Help section, but was moved and now is only in this section. I am probably delusional, that is strict regards to this section...oh well -
[SOLVED] getting a eval() to return a bool resault
premiso replied to M.O.S. Studios's topic in PHP Coding Help
http://www.phpfreaks.com/forums/index.php/topic,245560.0.html Why did you create a new post? EDIT: Thanks for merging Thorpe. Take a look at my reply above and see if that does not help you. I am afraid this may be a lost cause for you. You may have to result to using exec functions to call PHP CLI, as that would create a new process and not throw a fatal error to the page. Note: Using eval on unknown code can be dangerous. I would suggest against it if possible or at least filtering it to avoid someone screwing with/up your server.