Jump to content

Grodo

Members
  • Posts

    74
  • Joined

  • Last visited

    Never

Everything posted by Grodo

  1. Ok I figured it to check against resources you have to use the is_resource function in php http://us2.php.net/manual/en/function.is-resource.php
  2. How can I run a check on $admin to see if the connection to the db was successful? $admin echos out Resource id #1 when the connection is successful or displays the error if it isnt. However I can not check if $admin=='Resource id #1' for some reason. It just tends to ignore that the check is even there. if(isset($_POST["submit"])) { $admin=openDB($_SERVER['SERVER_ADDR'],msql_database,$_POST['username'],$_POST['password']); } else { show_admin(); } and this is the openDB function function openDB($server,$db,$user,$password) { $MYSQL_Server = $server; $MYSQL_DB = $db; $MYSQL_User = $user; $MYSQL_Password = $password; // Connect to database $dbID = mysql_connect($MYSQL_Server, $MYSQL_User, $MYSQL_Password) or die("<p>Unable to connect to the ' . 'database server at this time.</p>"); mysql_select_db( $MYSQL_DB ) or die("'<p>Unable to locate Catalog Request ' . 'database at this time.</p>'"); return( $dbID ); } and this is the showAdmin function function show_Admin() { global $HTTP_POST_VARS; ?> <form method="post" action=""> <table bord"0" width="100%" cellpadding="5" cellspacing="0"> <tr> <td><b>Username</b></td> <td><input type="text" name="username" size="25"></td> </tr> <tr> <td><b>Password</b></td> <td><input type="text" name="password" size="25"></td> </tr> <tr> <td> </td> <td> <input type="submit" name="submit" value="Send"> <input type="reset" value="Reset"> </td> </tr> </table> <?php }
  3. Ok I figured it out had to use a ghetto if statement (HEY IT WORKS) Still open for suggestions! //Check if one of the boxes is selected If ($tm==1) { // Do Nothing } elseif ($fm==1) { // Do Nothing } elseif ($sm==1) { // Do Nothing } else { $print_again = true; $message[]="Please select a catalog"; }
  4. Hello Thanks for looking at my post... So here is the scoop. I have three checkboxes (toolmag,sinkmag,faucetmag). What I am trying to do is have php check if one or more of the checkboxes are checked. I akready got the validation code down now all that is left is to form the IF and Or statement. This is the part im lost one. I know that if statments can have multiple conditions. But how can you tell the if statement if this condition is not met go to the next and when non of the conditions meet go to the else. I know that in Java the operator was ||. Attached below is the checkbox html code as well as the php code for checkbox validation. <input type="checkbox" name="toolmag">Tool Catalog<BR> <input type="checkbox" name="sinkmag">Vanity / Stainless Steel Sink Catalog<BR> <input type="checkbox" name="faucetmag">Faucet Catalog<BR> // CheckBox Tool Cat if($_POST['toolmag']) { $tm=1; } else { $tm=0; } // CheckBox Sink Cat if($_POST['sinkmag']) { $sm=1; } else { $sm=0; } // CheckBox Faucet Cat if($_POST['faucetmag']) { $fm=1; } else { $fm=0; }
  5. Seems like my host is rubish I would love to see that loop work. I just cant get it
  6. Hi, Ok I have a fuction it works great however its really slow and lags the page. I was wondering what i could do to speed it up a bit. I was thinking to make a for loop to check variables such as this: $sizeBlah=sizeof($message); $listVars[fname] = "fname"; $listVars[lname] = "lname"; $listMessage[0] = "Please insert you first name"; $listMessage[1] = "Please insert you last name"; for ($blah=0;$blah <=$sizeBlah;$blah++) { global $HTTP_POST_VARS, $error, $print_again, $message; // Validate first name $error[$listVars[$blah]] = false; if($_POST[$listVars[$blah]]=="") { $error[$listVars[$blah]] = true; $print_again = true; $message[]=$listMessage[$blah]; } } However I cant get this to work function check_form() { global $HTTP_POST_VARS, $error, $print_again, $message; // Validate first name $error['fname'] = false; if($_POST["fname"]=="") { $error['fname'] = true; $print_again = true; $message[]="Please insert you first name<br>"; } // Validate last name $error['lname'] = false; if($_POST["lname"]=="") { $error['lname'] = true; $print_again = true; $message[]="Please insert you last name<br>"; } // Validate Address $error['address1'] = false; if($_POST["address1"]=="") { $error['address1'] = true; $print_again = true; $message[]="Please enter a valid address<br>"; } // Validate City $error['city'] = false; if($_POST["city"]=="") { $error['city'] = true; $print_again = true; $message[]="Please enter a valid city<br>"; } // Validate State $error['state'] = false; if($_POST["state"]=="") { $error['state'] = true; $print_again = true; $message[]="Please enter a valid State or Territory<br>"; } // Validate Country $error['country'] = false; if($_POST["country"]=="") { $error['country'] = true; $print_again = true; $message[]="Please enter a valid country<br>"; } // Validate Postal code $error['zip'] = false; if($_POST["zip"]=="") { $error['zip'] = true; $print_again = true; $message[]="Please enter a valid zip<br>"; } }
  7. Your not escaping your quotes and not passing a value this is my guess <?php print"<a href='delete.php?emp_id={$emp_id['emp_id']}'>Remove</a><br />";?></td> try this <?php print"<a href='delete.php?emp_id={$emp_id['.$emp_id.']}'>Remove</a><br />";?></td> I am still learning php but that what i assume is going on
  8. Ok thanks to every one for the help i received the problem was a simple logic error.... The hidden div was on top when the browser read it it saw that it was calling $message at the time $message was = NULL; and unfortunally the variables in php dont update after they have been read. For those following this thread here is the now working code. Always Thanking, GRODO <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <LINK REL=StyleSheet HREF="dimming.css" TYPE="text/css"> <SCRIPT LANGUAGE="JavaScript" SRC="dimmingdiv.js"> </script> <script language="javascript"> function displayWindow() { var w, h, l, t; w = 400; h = 200; l = screen.width/4; t = screen.height/4; // no title // displayFloatingDiv('windowcontent', '', w, h, l, t); // with title displayFloatingDiv('windowcontent', 'Floating and Dimming Div', w, h, l, t); } </script> <style type="text/css"> body, table { font-size:13px; font-family:verdana,arial,helvetica,sans-serif; color:#000; background-color:#FFF; } body { margin:50px; } input, select, textarea { font-size:13px; font-family:verdana,arial,helvetica,sans-serif; } h1 { font-family:Arial, Verdana, Helvetica, Lucida, sans-serif; font-size:22px; color:maroon; margin:0px 0px 30px 0px; } .formErrors { color:maroon; } </style> <title>Form Validation</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php $HTTP_POST_VARS = NULL; $print_again = NULL; $error = NULL; $message = NULL; function error_bool($error, $field) { if($error[$field]) { print("<td style=color:red>"); } else { print("<td>"); } } function show_form() { global $HTTP_POST_VARS, $print_again, $error; ?> <form method="post" action=""> <table bord"0" width="100%" cellpadding="5" cellspacing="0"> <tr> <?php error_bool($error, "fname"); ?><b>First Name *</b></td> <td><input type="text" name="fname" value="<?php $_REQUEST['fname'] ?>" size="25"></td> </tr> <tr> <?php error_bool($error, "lname"); ?><b>Last Name *</b></td> <td><input type="text" name="lname" value="<?php $_REQUEST['lname'] ?>" size="25"></td> </tr> <tr> <td>Email</td> <td><input type="text" name="email" value="<?php $_REQUEST['email'] ?>" size="25"></td> </tr> <tr> <td>Company</td> <td><input type="text" name="company" value="<?php $_POST['company'] ?>" size="25"></td> </tr> <tr> <?php error_bool($error, "address1"); ?><b>Address 1*</b></td> <td><input type="text" name="address1" value="<?php $_REQUEST['address1'] ?>" size="25"></td> </tr> <tr> <td>Address 2</td> <td><input type="text" name="address2" value="<?php $_REQUEST['address2'] ?>" size="25"></td> </tr> <tr> <?php error_bool($error, "city"); ?><b>City*</b></td> <td><input type="text" name="city" value="<?php $_REQUEST['city'] ?>" size="25"></td> </tr> <tr> <?php error_bool($error, "state"); ?><b>State / Territory*</b></td> <td><input type="text" name="state" value="<?php $_REQUEST['state'] ?>" size="25"></td> </tr> <tr> <?php error_bool($error, "country"); ?><b>Country*</b></td> <td><input type="text" name="country" value="<?php $_REQUEST['country'] ?>" size="25"></td> </tr> <tr> <?php error_bool($error, "zip"); ?><b>Postal Code*</b></td> <td><input type="text" name="zip" value="<?php $_REQUEST['zip'] ?>" size="25"></td> </tr> <tr> <td>Phone</td> <td><input type="text" name="phone" value="<?php $_REQUEST['phone'] ?>" size="25"></td> </tr> <tr> <td><b>Catalog</b></td> <td> <input type="checkbox" name="toolmag">Tool Catalog<BR> <input type="checkbox" name="sinkmag">Vanity / Stainless Steel Sink Catalog<BR> <input type="checkbox" name="faucetmag">Faucet Catalog<BR> </td> </tr> <tr> <td>Special Instructions</td> <td> <textarea name="message" cols="50" rows="8"><?php $_REQUEST['message'] ?></textarea> </td> </tr> <tr> <td> </td> <td> <input type="submit" name="submit" value="Send"> <input type="reset" value="Reset"> </td> </tr> </table> </form> <a href="javascript:displayWindow();">Here</a> <? } if(isset($_POST["submit"])) { check_form(); } else { show_form(); } // Function to check the form function check_form() { global $HTTP_POST_VARS, $error, $print_again, $message; // Validate first name $error['fname'] = false; if($_POST["fname"]=="") { $error['fname'] = true; $print_again = true; $message[]="Please insert you first name<br>"; } // Validate last name $error['lname'] = false; if($_POST["lname"]=="") { $error['lname'] = true; $print_again = true; $message[]="Please insert you last name<br>"; } // Validate Address $error['address1'] = false; if($_POST["address1"]=="") { $error['address1'] = true; $print_again = true; $message[]="Please enter a valid address<br>"; } // Validate City $error['city'] = false; if($_POST["city"]=="") { $error['city'] = true; $print_again = true; $message[]="Please enter a valid city<br>"; } // Validate State $error['state'] = false; if($_POST["state"]=="") { $error['state'] = true; $print_again = true; $message[]="Please enter a valid State or Territory<br>"; } // Validate Country $error['country'] = false; if($_POST["country"]=="") { $error['country'] = true; $print_again = true; $message[]="Please enter a valid country<br>"; } // Validate Postal code $error['zip'] = false; if($_POST["zip"]=="") { $error['zip'] = true; $print_again = true; $message[]="Please enter a valid zip<br>"; } if($print_again) { show_form(); echo '<div style="width: 518px; height: 400px;visibility:hidden" id="windowcontent"> <table > <tr> <td>Your Form Has The Following Errors:</td> </tr> <tr> <td>'.$message[0].'</td> </tr> <tr> <td>'.$message[1].'</td> </tr> <tr> <td>'.$message[2].'</td> </tr> <tr> <td>'.$message[3].'</td> </tr> <tr> <td>'.$message[4].'</td> </tr> <tr> <td>'.$message[5].'</td> </tr> <tr> <td>'.$message[6].'</td> </tr> </table> </div>'; echo "<SCRIPT LANGUAGE='javascript'>displayWindow();</SCRIPT>"; } else { show_form(); $message[]="All Fields are valid <br> Now, In this way you can validate the other textfield as well<br> You can insert data into table"; } } // for ($x=1;$x<=6;$x++) { echo "$message[$x]"; } ?> <!-- the following hidden div will be used by the script --> </body> </html>
  9. Alright! I got one of the messages to appear! However now the trick is to cycle through the array and display all errors. The problem was I was echoing and had a var with a semicolon ending the line echo ' Echo some stuff' .$message;. 'Some more stuff; So that error has been fixed
  10. I think I know what might be wrong... The div is at the top so when the browser reads it it sees $message and sets it to null so what i need to echo the div out escape quotes and then combine the rest this is my whole code I am still trying to figure out y its giving me an unexpected . error. (Isnt the . operator in php the same as + in js?) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <LINK REL=StyleSheet HREF="dimming.css" TYPE="text/css"> <SCRIPT LANGUAGE="JavaScript" SRC="dimmingdiv.js"> </script> <script language="javascript"> function displayWindow() { var w, h, l, t; w = 400; h = 200; l = screen.width/4; t = screen.height/4; // no title // displayFloatingDiv('windowcontent', '', w, h, l, t); // with title displayFloatingDiv('windowcontent', 'Floating and Dimming Div', w, h, l, t); } </script> <style type="text/css"> body, table { font-size:13px; font-family:verdana,arial,helvetica,sans-serif; color:#000; background-color:#FFF; } body { margin:50px; } input, select, textarea { font-size:13px; font-family:verdana,arial,helvetica,sans-serif; } h1 { font-family:Arial, Verdana, Helvetica, Lucida, sans-serif; font-size:22px; color:maroon; margin:0px 0px 30px 0px; } .formErrors { color:maroon; } </style> <title>Form Validation</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php $HTTP_POST_VARS = NULL; $print_again = NULL; $error = NULL; $message = NULL; function error_bool($error, $field) { if($error[$field]) { print("<td style=color:red>"); } else { print("<td>"); } } function show_form() { global $HTTP_POST_VARS, $print_again, $error; ?> <form method="post" action=""> <table bord"0" width="100%" cellpadding="5" cellspacing="0"> <tr> <?php error_bool($error, "fname"); ?><b>First Name *</b></td> <td><input type="text" name="fname" value="<?php $_REQUEST['fname'] ?>" size="25"></td> </tr> <tr> <?php error_bool($error, "lname"); ?><b>Last Name *</b></td> <td><input type="text" name="lname" value="<?php $_REQUEST['lname'] ?>" size="25"></td> </tr> <tr> <td>Email</td> <td><input type="text" name="email" value="<?php $_REQUEST['email'] ?>" size="25"></td> </tr> <tr> <td>Company</td> <td><input type="text" name="company" value="<?php $_POST['company'] ?>" size="25"></td> </tr> <tr> <?php error_bool($error, "address1"); ?><b>Address 1*</b></td> <td><input type="text" name="address1" value="<?php $_REQUEST['address1'] ?>" size="25"></td> </tr> <tr> <td>Address 2</td> <td><input type="text" name="address2" value="<?php $_REQUEST['address2'] ?>" size="25"></td> </tr> <tr> <?php error_bool($error, "city"); ?><b>City*</b></td> <td><input type="text" name="city" value="<?php $_REQUEST['city'] ?>" size="25"></td> </tr> <tr> <?php error_bool($error, "state"); ?><b>State / Territory*</b></td> <td><input type="text" name="state" value="<?php $_REQUEST['state'] ?>" size="25"></td> </tr> <tr> <?php error_bool($error, "country"); ?><b>Country*</b></td> <td><input type="text" name="country" value="<?php $_REQUEST['country'] ?>" size="25"></td> </tr> <tr> <?php error_bool($error, "zip"); ?><b>Postal Code*</b></td> <td><input type="text" name="zip" value="<?php $_REQUEST['zip'] ?>" size="25"></td> </tr> <tr> <td>Phone</td> <td><input type="text" name="phone" value="<?php $_REQUEST['phone'] ?>" size="25"></td> </tr> <tr> <td><b>Catalog</b></td> <td> <input type="checkbox" name="toolmag">Tool Catalog<BR> <input type="checkbox" name="sinkmag">Vanity / Stainless Steel Sink Catalog<BR> <input type="checkbox" name="faucetmag">Faucet Catalog<BR> </td> </tr> <tr> <td>Special Instructions</td> <td> <textarea name="message" cols="50" rows="8"><?php $_REQUEST['message'] ?></textarea> </td> </tr> <tr> <td> </td> <td> <input type="submit" name="submit" value="Send"> <input type="reset" value="Reset"> </td> </tr> </table> </form> <a href="javascript:displayWindow();">Here</a> <? } if(isset($_POST["submit"])) { check_form(); } else { show_form(); } // Function to check the form function check_form() { global $HTTP_POST_VARS, $error, $print_again, $message; // Validate first name $error['fname'] = false; if($_POST["fname"]=="") { $error['fname'] = true; $print_again = true; $message[]="Please insert you first name<br>"; } // Validate last name $error['lname'] = false; if($_POST["lname"]=="") { $error['lname'] = true; $print_again = true; $message[]="Please insert you last name<br>"; } // Validate Address $error['address1'] = false; if($_POST["address1"]=="") { $error['address1'] = true; $print_again = true; $message[]="Please enter a valid address<br>"; } // Validate City $error['city'] = false; if($_POST["city"]=="") { $error['city'] = true; $print_again = true; $message[]="Please enter a valid city<br>"; } // Validate State $error['state'] = false; if($_POST["state"]=="") { $error['state'] = true; $print_again = true; $message[]="Please enter a valid State or Territory<br>"; } // Validate Country $error['country'] = false; if($_POST["country"]=="") { $error['country'] = true; $print_again = true; $message[]="Please enter a valid country<br>"; } // Validate Postal code $error['zip'] = false; if($_POST["zip"]=="") { $error['zip'] = true; $print_again = true; $message[]="Please enter a valid zip<br>"; } if($print_again) { show_form(); echo '<div style="width: 518px; height: 287px;visibility:hidden" id="windowcontent"> <table > <tr> <td>Your Form Has The Following Errors:</td> </tr> <tr> <td>$message</td> </tr> <tr><td colspan="2"><br />Click the X to close</td></tr> </table> </div>'; echo "<SCRIPT LANGUAGE='javascript'>displayWindow();</SCRIPT>"; } else { show_form(); $message[]="All Fields are valid <br> Now, In this way you can validate the other textfield as well<br> You can insert data into table"; } } // for ($x=1;$x<=6;$x++) { echo "$message[$x]"; } ?> <!-- the following hidden div will be used by the script --> </body> </html>
  11. Ok i tried to move globals outside of the function and then my error highlighting stopped working. I put the globals back and boom error highlighting works. Seems like message is still coming null should I maybe make a $string = checkform(). Or is there something wrong with there globals global $HTTP_POST_VARS, $error, $print_again, $message;
  12. That doesnt seem like that the answer... But thanks! Now do I put <td> <?php foreach ($message as $v) { echo "-$v"; } ?> </td> ? Seems that $message is NULL but when i set a for loop in the function it displays the messages Could it be because the function is not returning anything?
  13. Well that expains it came back as NULL. Seems to me like the function is not setting $message which lists all the errors. Here is code for the function that should be set $message to the error. function check_form() { global $HTTP_POST_VARS, $error, $print_again, $message; // Validate first name $error['fname'] = false; if($_POST["fname"]=="") { $error['fname'] = true; $print_again = true; $message[0]="Please insert you first name<br>"; } // Validate last name $error['lname'] = false; if($_POST["lname"]=="") { $error['lname'] = true; $print_again = true; $message[1]="Please insert you last name<br>"; } // Validate Address $error['address1'] = false; if($_POST["address1"]=="") { $error['address1'] = true; $print_again = true; $message[2]="Please enter a valid address<br>"; } // Validate City $error['city'] = false; if($_POST["city"]=="") { $error['city'] = true; $print_again = true; $message[3]="Please enter a valid city<br>"; } // Validate State $error['state'] = false; if($_POST["state"]=="") { $error['state'] = true; $print_again = true; $message[4]="Please enter a valid State or Territory<br>"; } // Validate Country $error['country'] = false; if($_POST["country"]=="") { $error['country'] = true; $print_again = true; $message[5]="Please enter a valid country<br>"; } // Validate Postal code $error['zip'] = false; if($_POST["zip"]=="") { $error['zip'] = true; $print_again = true; $message[6]="Please enter a valid zip<br>"; } if($print_again) { show_form(); echo "<SCRIPT LANGUAGE='javascript'>displayWindow();</SCRIPT>"; } else { show_form(); $message="All Fields are valid <br> Now, In this way you can validate the other textfield as well<br> You can insert data into table"; } }
  14. Hello, Thank you for your time. In the code attached below it does not seem like the loop is being activated am I doing something wrong? $message is array and is marked as a global and contains up to a total of 6 values. I am really stumped on this one PLEASE HELP Thanks Grodo <div style="width: 518px; height: 287px;visibility:hidden" id="windowcontent"> <table > <tr> <td>Your Form Has The Following Errors:</td> </tr> <tr> <td><?php for ($xi=1;$xi<=6;$xi++) { echo "$message[$xi]"; } ?><td> </tr> <tr><td colspan="2"><br />Click the X to close</td></tr> </table> </div>
  15. I got it working on extemely inefficent code but if some one can figure out how to incorperate a function with a loop that would be awesome for the time being im just gonna be using the code posted below.... Who knows it might help some one out. <?php // Database info // Database: xxx_1234 // User: xxx_5678 // Passwd: xxpassxx // Table Name: xtable // MYSQL DB Host: 127.0.0.0 //Define Globals global $error; global $postVar; global $errored; global $fname; global $lname; global $address1; global $city; global $state; global $country; global $zip; // Connect to the database server $dbcnx = @mysql_connect('127.0.0.0', 'xxx_5678', 'xxpassxx'); if (!$dbcnx) { exit('<p>Unable to connect to the ' . 'database server at this time.</p>'); } // Select the Catalog request database if (!@mysql_select_db('xxx_1234')) { exit('<p>Unable to locate Catalog Request ' . 'database at this time.</p>'); } if ($_POST['company'] != NULL) { $company = $_POST['company']; $sql = "INSERT INTO xtable SET company='$company'"; mysql_query($sql); echo 'Successfully wrote' . $company .'to Database'; } else { include 'catalog.php'; } ?>
  16. Thanks for the reply 947740, The if statement still doesnt work. From what I seen it did trip the errored once... but after i reloaded it. It did not trip the errored flag. Also non of the values are setting I belive its a problem with $fname = $_POST[$postVar[0]]; However logically it seems correct. I got it working with a IF statement for each var but I was trying to make the code more effiecent and incorperate a loop.
  17. Hello, I would like to thank you ahead of time for looking at this post. I have a HTML form that has fields for First Name, Last Name, ect. The fields are named respectively to their variables (fname,lname, ect...). After the user submits the fields through post method the fields go through validation. The validation function is called NULLcheck(). This function takes each field and checks for a NULL value. If a NULL value is found it triggers the errored flag. All errors are stored in an array. The function returns the error to the $listError array when an error is detected. I have written many checks for this code and I have came to the conlusion the it does go through the NULLcheck() function but for some reason it does not assign values to the global variables. It also seems to me that the fuction keeps validating as true and never triggers the errored flag. I have attached my validating code below. Thanks for your time and helping me with this project, Grodo <?php //Define Globals global $error; global $postVar; global $errored; global $fname; global $lname; global $address1; global $city; global $state; global $country; global $zip; function NULLcheck() { // Define Errors $error[fname] = "Please enter your first name"; $error[lname] = "Please enter your last name"; $error[address1] = "Please enter a valid address"; $error[city] = "Please enter a valid city"; $error[state] = "Please enter a valid state or territory"; $error[country] = "Please enter a valid country"; $error[zip] = "Please enter a valid postal code"; // Define Variables $postVar[0] = "fname"; $postVar[1] = "lname"; $postVar[2] = "address1"; $postVar[3] = "city"; $postVar[4] = "state"; $postVar[5] = "country"; $postVar[6] = "zip"; //Check for Null Variables for ( $counter = 0; $counter <= 6; $counter += 1) { if ($_POST[$postVar[$counter]] != NULL) { $fname = $_POST[$postVar[0]]; $lname = $_POST[$postVar[1]]; $address1 = $_POST[$postVar[2]]; $city = $_POST[$postVar[3]]; $state = $_POST[$postVar[4]]; $country = $_POST[$postVar[5]]; $zip = $_POST[$postVar[6]]; } // If Null Values are found report error else { $errored = TRUE; return $error[$postVar[$counter]]; } } } $listError[] = NULLcheck(); // If Errored = Flase then No Errors are found if (!$errored) { echo 'No Errors'; } else { for ($i = 0; $i <=6; $i += 1) { echo $listError[$i]; } } ?>
  18. THANKS for the awesome reply Alecks! I didnt even know that those commands existed. Now correct me if I am wrong... strpos set the position of the string to read. substr removes all parts up to the begin scan activity line. the example you coded for me works perfectly! Now it time for phase two which I dont think would be to difficult and that is searching through the string... Ill attempt this in a few hours and post my results
  19. You caught me as i was editing my post... WOW you guys are extremely fast
  20. Thanks for the quick reply but that is not the solution... You were on the right track of what I wanted to do. The striptags() had no effect to the variable. I have also tried to set the strip_tags() to a variable via $page = strip_tags($getcon); and echo out ($page) but it did the same thing as strip_tags($getcon). My current code is <?php if($getcon = file_get_contents("http://www.fedex.com/Tracking?ascend_header=1&clienttype=dotcom&cntry_code=us&language=english&tracknumbers=222222222222222")) { strip_tags($getcon); } else { echo "Error: Could not connect to page..." } ?>
  21. http://onedotoh.sourceforge.net/ This is a real simple one! Easy to setup and everything
  22. I am looking for the easiest method to parse a webpage and extract the text from it. I realize that I could use the function get_file_contents() and then do a preg replace on all html tags. But is there an easier fuction to just get the plain text or is the only way of doing it is to use preg replace? What I am trying to do is open the Fedex website search a tracking number and then parse the text of the website to a string. After the text is parsed I will search through it and extract the status, tracking number, and date delivered. Problem with this code is that it returns the html coding <?php if($getcon = file_get_contents("http://www.fedex.com/Tracking?ascend_header=1&clienttype=dotcom&cntry_code=us&language=english&tracknumbers=222222222222222")) { echo $getcon; } else { echo "Error: Could not connect to page..." } ?>
  23. Thank You for all your help ginger robot! I found what i needed it can be found here: http://www.dynamicdrive.com/dynamicindex4/thumbnail.htm
  24. Ok, Thank You By chance you wouldn't know anywhere where I can get any additional help?
  25. could be that your missing a space $result = mysql_query($sql)or die(mysql_error()); try this $result = mysql_query($sql) or die(mysql_error());
×
×
  • 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.