Jump to content

croakingtoad

Members
  • Posts

    65
  • Joined

  • Last visited

    Never

Everything posted by croakingtoad

  1. never mind...changed the way i was doing it.
  2. Greetings! I am querying a database and after a little magic it outputs a variable called - $HomeStyle Now, this is a migration script so I am migrating from a database that has a field length of 3000 to a database that has a field length of 250. Here's a sample value: $HomeStyle= "Adirondack-style,Cabin,Cedar shake,Conventional,Cottages,Farmhouse,Lake"; //Obviously this is less than the needed field length, but let's just pretend so we can save space! So how would I take the value of $HomeStyle, reduce it to 250 AND eliminate any characters after the last comma (including the last comma)? (So we don't have incomplete words.) Thanks for your guidance!
  3. great, but how do I get it to only return the first 10 characters in $new?
  4. I have a var named $DeveloperTelephone that is being pulled from a database and the string value could be formatted like-- 540-111-1111 (540) 111-1111 866-111-1111 or 828-111-1111 I need to first remove all the dashes and parents and then count the first 10 digits to make that the new value. So the third value above would become-- 8661111111 How would I accomplish that please and thanks?!
  5. I tried nickk's version but when I use the following-- foreach ($SVarray as $varName => $varVal) { $$varName = $varVal; echo "$DevName"; } it echoes out the value of the first rows column through every iteration instead of different values for $DevName. What do I need to change to have it assign the current columns value for that row in each iteration?
  6. Is there an easy way (other than manually setting the vars) to set var names as the database column name? I have a database that I am querying and then turning into an array like below-- # perform the query $SVresult = mssql_query($SVquery) or die("Cannot query database"); # fetch the data from the database $SVarray = mssql_fetch_array($SVresult) or die("Cannot process array"); $SVcount = count($SVarray); echo "Count: $SVcount <br /><br />"; # begin master loop through array for ($i = 0; $i <= $SVcount; $i++) { //print "$SVarray[$i]<br>"; print_r("$SVarray[$i] <br />"); } #end master loop through array Instead of having the vars returned having a value of say $SVarray[1] instead having a value of ColumnName or ColumnName[1]? Hope that makes sense. Thanks!
  7. I am able to execute this command through MSSQL - insert into LotPricing values(500,500,500) but when I try to execute it through PHP I get the following error-- Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> ADODB.Recordset<br/><b>Description:</b> Operation is not allowed when the object is closed.' in D:\hosting\member\croakingtoad\site1\test.php:47 Stack trace: #0 D:\hosting\member\croakingtoad\site1\test.php(47): variant->Close() #1 {main} thrown in D:\hosting\member\croakingtoad\site1\test.php on line 47 Here's the code I have-- //create an instance of the ADO connection object $conn = new COM ("ADODB.Connection") or die("Cannot start ADO"); //define connection string, specify database driver $connStr = "PROVIDER=SQLOLEDB;SERVER=".$ovServer.";UID=".$ovUser.";PWD=".$ovPass.";DATABASE=".$ovDB; $conn->open($connStr); //Open the connection to the database //declare the SQL statement that will query the database $query = 'insert into LotPricing (PriceLow,PriceHigh,Description) VALUES (500,500,500)'; //execute the SQL statement and return records $rs = $conn->execute($query); /* Line 47 */ What am I doing wrong here? The table has 4 columns- PricingID, PriceLow, PriceHigh, Description PricingID is a unique key with Identity turned on, i.d. start is 1 and i.d. seed is 1 Please help! Thanks!
  8. I had another developer send me a backup of a database but it doesn't appear to be a sql dump. It was in a zip file but when uncompressed the file is a .bak file. I tried opening it with a text editor and it isn't a text file like a .sql file would be. Any idea what I have here? I know from them it is a mysql backup but I don't want to look like a fool and ask them what it is. And then how do I go about restoring it?!
  9. That only allows you three comparisons...I want the full five they offer only on their own site.
  10. I've tried several times to get this to work and nothing I have tried has been successful. I want to scrape the below url-- http://www.alexa.com/data/details/traffic_details/instantaction.com?site0=virginia.edu&site1=vt.edu&site2=ncsu.edu&site3=psu.edu&site4=umd.edu&y=r&z=3&h=300&w=610&u%5B%5D=virginia.edu&u%5B%5D=vt.edu&u%5B%5D=ncsu.edu&u%5B%5D=psu.edu&u%5B%5D=umd.edu&x=2008-03-20T13%3A39%3A43.000Z&check=alexa.com&signature=53LsuknqIBOvifzf%2FUFCNr6WyLI%3D&range=6m&size=Medium for the following image to write to my own server once a day-- <img src="http://widgets.alexa.com/traffic/graph/?r=6m&y=r&z=3&h=300&w=610&u%5B%5D=virginia.edu&u%5B%5D=vt.edu&u%5B%5D=ncsu.edu&u%5B%5D=psu.edu&u%5B%5D=umd.edu&x=2008-03-20T13%3A40%3A54.000Z&check=www.alexa.com&signature=VH1glT4ZwCzDnpmKzXEEsG9isNs%3D" id="alexagraph"/> I've tried using the tools found here-- http://www.troywolf.com/articles/php/class_http/ but haven't been able to get anywhere. I'll post what I had below-- $http = 'http://www.alexa.com/data/details/traffic_details/instantaction.com?site0=virginia.edu&site1=vt.edu&site2=ncsu.edu&site3=psu.edu&site4=umd.edu&y=r&z=3&h=300&w=610&u%5B%5D=virginia.edu&u%5B%5D=vt.edu&u%5B%5D=ncsu.edu&u%5B%5D=psu.edu&u%5B%5D=umd.edu&x=2008-03-20T13%3A39%3A43.000Z&check=alexa.com&signature=53LsuknqIBOvifzf%2FUFCNr6WyLI%3D&range=6m&size=Medium'; $uri = urlencode($http); echo "Step 1<br /><br />"; require_once("assets/php/class_http.php"); $h = new http(); if (!$h->fetch($uri, "daily")) { echo "<h2>There is a problem with the http request!</h2>"; echo $h->log; exit(); } and here's the response I rec'd- New http() object instantiated. -------------------------------- fetch() called url: http%3A%2F%2Fwww.google.com%2Flogos%2Fspring08.gif Filename: /www/virtualhosts/www.dashboard.unirel.vt.edu/http_5f3bca03a10708837ce5ed5e2500b772 getFile_ts() called /www/virtualhosts/www.dashboard.unirel.vt.edu/http_5f3bca03a10708837ce5ed5e2500b772 does not exist cache has expired getFromUrl() called Could not open connection. Error -1215900454:
  11. Awesome, thanks for the help! SOLVED
  12. That's a good start but I need some logic in there to determine which was is the newest and order them to oldest. An if/else strategy may not be the most efficient way to do that?
  13. I am starting with three chunks of code wrapped in a <li> and want to order it based on a date in a variable. Here's what I have for variables in a separate file that is called in with require_once() - $hkLongDate = "02/25/2008"; $vtLongDate = "02/27/2008"; $totLongDate = "02/29/2008"; The code that I want to sort based on the above date is basically three <li> items like below - $hkList = "<li>Item Blue</li>"; $vtList = "<li>Item Orange</li>"; $totList = "<li>Item Green</li>"; I'm just not sure of the best way to associate the var from the first list with the var from the second list and then have it sort by the date value in the first var. Advice?
  14. I just realized I can substitute $_POST for $values. Works like a charm!!! Thanks so much!
  15. Apologies, yes you did. I had to go back and reread because I hadn't used your solution but obviously now I see it is the better choice. Here is what you said to use- $fields = array('foo','bar','bob'); $values = array('this is foo','this is bar','this is bob'); $sql = "INERT INTO tbl (" . implode(",",$fields) . ") VALUES ('" . implode("','",$values) . "')"; My $values array is coming from a user submission (ie: $_POST['foo']). How would I implode the $POST vars into the VALUES portion of the sql query?
  16. I am building a mysql query dynamically but when it comes time to execute the query it is only returning the text representation of the variable. I have the following code- for ($i = 0; $i < count($array); $i++) { //removes characters in $chars from $array items $chars = array(" ", "&", "(", ")", "/", "-"); $trim = str_replace($chars, "", $array[$i]); $query1 .= "$trim, "; $query2 .= "'$" . "_POST[$trim]', "; } $query1 = substr("$query1", 0, -2); $query2 = substr("$query2", 0, -2); $query = "INSERT INTO 2007_results (name, email, ip, $query1) VALUES ('$name', '$email', '$ip',$query2)"; //mysql_query($query); //echo mysql_errno($sql) . ": " . mysql_error($sql) . "\n"; //troubleshooting echo $_POST['AllergyImmunology']; echo "<br />Query is - $query<br /><br />"; echo "Query1 is - $query1<br /><br />"; echo "Query2 is - $query2"; The result of this is below- test Query is - INSERT INTO 2007_results (name, email, ip, AllergyImmunology, Anesthesiology, Cardiology) VALUES ('Marty', 'test@test.com', '70.188.11.41','$_POST[AllergyImmunology]', '$_POST[Anesthesiology]', '$_POST[Cardiology]') Query1 is - AllergyImmunology, Anesthesiology, Cardiology Query2 is - '$_POST[AllergyImmunology]', '$_POST[Anesthesiology]', '$_POST[Cardiology]' What I want to see is Query 1 showing the variable values submitted by the user. Instead what I'm seeing is the variable that I have built but that isn't being parsed as a variable (no doubt to my error). How do I insert $query2 into $query and have it parsed so I have the values of the variable I built and not the variable name. Does that make sense? Thanks in advance!
  17. Currently I have a for() loop building a query for me. The code is as below- for ($i = 0; $i < count($array); $i++) { //removes characters in $chars from $array items $chars = array(" ", "&", "(", ")", "/", "-"); $trim = str_replace ($chars, "", $array[$i]); $query1 .= "$trim, "; $query2 .= "'$" . "_POST[$trim]', "; } $query1 = str_replace ("_1", "", $query1); $query = "INSERT INTO 2007_results (name, email, ip, $query1) VALUES ('$name', '$email', '$ip'," . $query2 . ")"; mysql_query($query); This is producing a $query that looks like this-- $query = "INSERT INTO 2007_results (name, email, ip, query1.1, query1.2, ) VALUES ('foo', 'foo@bar.com', '127.0.0.1', 'result1', 'result2', )"; Obviously that is producing a SQL error because of the extra comma and space inserted at the end of each iteration. The question is, how to remove the inserted ", " on the last iteration? There are many more inserted vars as part of $query1; I just shortened it for this example. Thanks in advance!
  18. What I'm trying to do is avoid having to write the name of every $_POST returned by the form to be processed (or in this case emailed with phpmail). I know what the html input names are going to be because I dynamically create them using an array. I then want to use the same array to create dynamic variables for the part of the script that will process the form submission. Here is my array- $array = array("Allergy & Immunology", "Anesthesiology", "Cardiology", "Chiropractic", "Dentistry", "Dermatology", "Emergency Medicine", "Endocrinology", "Family Practice", "Gastroenterology", "Geriatrics", "Hematology/Oncology", "Internal Medicine", "Neurology", "Nephrology", "Nurse Practitioner", "Obstetrics & Gynecology", "Ophthalmology", "Optometry", "Osteopathy", "Orthopaedic", "Surgery", "Otolaryngology (ENT)", "Pain Management", "Pediatrics", "Physician Assistant (PA)", "Plastic Surgery", "Physical Medicine", "Podiatry", "Pulmonary", "Psychiatry", "Rheumatology", "Surgery - Cardiac", "Surgery - General", "Surgery - Neurosurgery", "Surgery - Vascular", "Urology"); So here is what I'm using to iterate through the array and create the form inputs- <form action="bedside-manner.php" name="form1" method="post"> <? $ip = $_SERVER["REMOTE_ADDR"]; for ($i = 0; $i < count($array); $i++) { //removes characters in $chars from $array items $chars = array(" ", "&", "(", ")", "/"); $trim = str_replace ($chars, "", $array[$i]); if ($i & 2 != 0) { echo "<fieldset>"; } else { echo " <fieldset style=\"float: left;\">"; } echo " <legend>$array[$i]</legend> <input type=\"text\" name=\"$trim_1\" size=\"30\" /> <label>1st</label> <br /> <input type=\"text\" name=\"$trim_2\" size=\"30\" /> <label>2nd</label> <br /> <input type=\"text\" name=\"$trim_3\" size=\"30\" /> <label>3rd</label> </fieldset> "; } ?> <div style="clear: both;"> </div> <input type="hidden" value="<? echo $ip; ?>" name="ip" /> <input type="submit" value="Submit" name="submit" /> </form> <? } ?> Then when the user submits the form, I am trying to do the below to capture the $_POST values without having to explicitly define each of them. I'd rather create dynamic variables to do the job for me like below (which still isn't working - <? if ( isset($_POST['submit']) ) { $to = "foo@gmail.com"; $subject = "Best in Bedside Awards Submission"; $message = " From - $name $ip $email "; for ($i = 0; $i < count($array); $i++) { //removes characters in $chars from $array items $chars = array(" ", "&", "(", ")", "/"); $trim = str_replace ($chars, "", $array[$i]); //Dynamically build $_POST variables from array $one = $_POST[$trim . "_1"]; $two = $_POST[$trim . "_2"]; $three = $_POST[$trim . "_3"]; //troubleshooting.. if ($i == 0) { echo $_POST['AllergyImmunology_1']; echo "1 = $one"; echo "2 = $two"; echo "3 = $three"; } $message .= "$array[$i]"; $message .= "1st- $one"; $message .= "2nd- $two"; $message .= "3rd- $three"; } $headers .= "To: $to" . "\r\n"; $headers .= "From: $name <$email>" . "\r\n"; //mail($to, $subject, $message, $headers);*/ $thanks = "Thank you for your submission. Be sure to watch for our Fall issue with The Best in Bedside Manners awards!"; echo "$message"; } else { ?> Right now the output of the above bit of code when the form is submitted is simply-- 1 = 2 = 3 = From - 70.188.0.64 Allergy & Immunology1st- 2nd- 3rd- Anesthesiology1st- 2nd- 3rd- Cardiology1st- 2nd- 3rd- Chiropractic1st- 2nd- 3rd- Dentistry1st- 2nd- 3rd- Dermatology1st- 2nd- 3rd- Emergency Medicine1st- 2nd- 3rd- Endocrinology1st- 2nd- 3rd- Family Practice1st- 2nd- 3rd- Gastroenterology1st- 2nd- 3rd- Geriatrics1st- 2nd- 3rd- Hematology/Oncology1st- 2nd- 3rd- Internal Medicine1st- 2nd- 3rd- Neurology1st- 2nd- 3rd- Nephrology1st- 2nd- 3rd- Nurse Practitioner1st- 2nd- 3rd- Obstetrics & Gynecology1st- 2nd- 3rd- Ophthalmology1st- 2nd- 3rd- Optometry1st- 2nd- 3rd- Osteopathy1st- 2nd- 3rd- Orthopaedic1st- 2nd- 3rd- Surgery1st- 2nd- 3rd- Otolaryngology (ENT)1st- 2nd- 3rd- Pain Management1st- 2nd- 3rd- Pediatrics1st- 2nd- 3rd- Physician Assistant (PA)1st- 2nd- 3rd- Plastic Surgery1st- 2nd- 3rd- Physical Medicine1st- 2nd- 3rd- Podiatry1st- 2nd- 3rd- Pulmonary1st- 2nd- 3rd- Psychiatry1st- 2nd- 3rd- Rheumatology1st- 2nd- 3rd- Surgery - Cardiac1st- 2nd- 3rd- Surgery - General1st- 2nd- 3rd- Surgery - Neurosurgery1st- 2nd- 3rd- Surgery - Vascular1st- 2nd- 3rd- Urology1st- 2nd- 3rd-
  19. Okay, I implemented your suggestions and here's what i have now- for ($i = 0; $i < count($array); $i++) { //removes characters in $chars from $array items $chars = array(" ", "&", "(", ")", "/"); $trim = str_replace ($chars, "", $array[$i]); //Build $_POST variable from array $one = $_POST[$trim . "_1"]; $two = $_POST[$trim . "_2"]; $three = $_POST[$trim . "_3"]; //troubleshooting.. if ($i == 0) { echo $_POST['AllergyImmunology-1']; echo "1 = $one"; echo "2 = $two"; echo "3 = $three"; } $uno = ${$one}; $dos = ${$two}; $tres = ${$three}; $message .= "$array[$i]"; $message .= "1st- $uno"; $message .= "2nd- $dos"; $message .= "3rd- $tres"; } I still am not getting the values of $uno, etc. nor $one, etc. when I echo them out...?
  20. I have a form that is passing $_POST values to itself on submit. The values are predictable based on the data in an array. So what I'm trying to do is dynamically build the POST variables which I have done like this-- //removes characters in $chars from $array items $chars = array(" ", "&", "(", ")", "/"); $trim = str_replace ($chars, "", $array[$i]); //Build $_POST variable from array $one = "$" . "_POST['" . "$trim" . "-1']"; $two = "$" . "_POST['" . "$trim" . "-2']"; $three = "$" . "_POST['" . "$trim" . "-3']"; The above works fine and creates a text string representing the var. Where I run into the problem is executing that string as PHP. Here's what I have that isn't working-- $uno = ${$one}; $dos = ${$two}; $tres = ${$three}; $message .= "$array[$i]"; $message .= "1st- $uno"; $message .= "2nd- $dos"; $message .= "3rd- $tres"; When I echo out $message none of the $uno, $dos or $tres vars show up. Just blank. When I echo out $one, $two or $three from the first set of code though I am getting a var like-- $_POST['allergy-1'] Any ideas what I'm doing wrong?
  21. Hmm...but I was hoping for a shortcut to keep from having to manually pull all the vars out of there. $trim is the var. Is there another way of doing that?
  22. I am getting this error- Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/health1/public_html/bedside-manner.php on line 43 with this bit of code- 35 for ($i = 0; $i < count($array); $i++) { 36 37 //removes characters in $chars from $array items 38 $chars = array(" ", "&", "(", ")", "/"); 39 $trim = str_replace ($chars, "", $array[$i]); 40 41 $message .= " 42 $array[$i] 43 1st $_POST['$trim-1'] 44 2nd $_POST['$trim-2'] 45 3rd $_POST['$trim-3'] 46 47 "; 48 49 } This is a bit of code I have to try to handle the results of a form submit without having to manually code every var into the phpmail message. These values are handled the same way in the creation of the form. Just as an FYI, here's what my form looks like but it is not where I'm having the problem-- for ($i = 0; $i < count($array); $i++) { //removes characters in $chars from $array items $chars = array(" ", "&", "(", ")", "/"); $trim = str_replace ($chars, "", $array[$i]); if ($i & 2 != 0) { echo "<fieldset>"; } else { echo " <fieldset style=\"float: left;\">"; } echo " <legend>$array[$i]</legend> <input type=\"text\" name=\"$trim-1\" size=\"30\" /> <label>1st</label> <br /> <input type=\"text\" name=\"$trim-2\" size=\"30\" /> <label>2nd</label> <br /> <input type=\"text\" name=\"$trim-3\" size=\"30\" /> <label>3rd</label> </fieldset> "; } This form is submitting to itself...
  23. That was it. Left out the method. It's too late to be forgetting my html Thanks so much!
×
×
  • 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.