Jump to content

wright67uk

Members
  • Posts

    454
  • Joined

  • Last visited

Everything posted by wright67uk

  1. Why do i get no results returned from the below form? Ive tested the string; SELECT phone FROM mytablename WHERE sg ='YES' ORDER BY companyName LIMIT 3 and the sql is fine in mysql admin, and returns the expected results. However in practice I seem to be having difficulties. Is my syntax out of place. All i get returned are the two words "Phone numbers: " Im trying with difficulty to learn php! please any pointers? <code> <!-- html only form.html--> <form method="get" action="phponlyform.php"> <input type="text" name="postcode" size="2" maxlength="2"/> <input type="submit" name="Submit"/> </form> <!-- phponlyform.php--> <?php mysql_connect("myusername","mydatabase… mysql_select_db("mydatabase") or die("Unable to select database"); $code = $_GET['postcode']; $result = mysql_query("SELECT phone FROM mytablename WHERE '$code' ='YES' ORDER BY companyName LIMIT 3") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo "Phone Numbers: ".$row['phone']; ?> <!-- eg. column name is SG and he value is YES --> </code>
  2. Hello! Im doing my very best to learn php. Im trying to create some php that will pull some values from mysql database which I have setup. If within my database i type the following sql statement; SELECT phone FROM treesurgeons WHERE EN ='YES' ORDER BY companyName LIMIT 3 Then i have three results returned. However my php file will only say; "Sorry your search "EN" returned no results". 'postcodestrip' is from a basic html form (on a different page). oes anybody hav any ideas where im going wrong? <html><body><?php $var = @$_GET['postcodestrip'] ; $trimmed = trim($var); $limit=3; if ($trimmed == "") {echo "<p>Please enter a search...postcode</p>"; exit;} if (!isset($var)) {echo "<p>We dont seem to have a postcode to go on!</p>"; exit;} mysql_connect("HOSTNAME HERE","USERNAME HERE","MYPASWORD"); mysql_select_db("MYDATABASE") or die("Unable to select database"); $query = "SELECT phone FROM treesurgeons WHERE %$trimmed% ='YES' ORDER BY companyName LIMIT 3"; $numresults=mysql_query($query); if ($numresults == 0) {echo "<h4>Results</h4>"; echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>";} ?></body></html>
  3. Im having trouble getting this form to work on my website. It all seems to work ok, however when i test it, i dont recieve any emails to my inbox. Godaddy seems to think that I am connecting to their server in the correct manner, but say that they cannot advise on customers codeing issues. I thought that somebody in this forum maybe able to give me some pointers? [<?php ini_set('sendmail_from', 'user@domain.tld'); ini_set('SMTP', 'relay-hosting.secureserver.net'); $subject = $_POST["subject"]; $message = $_POST["message"]; $from = $_POST["from"]; $name = $_POST["name"]; $phone = $_POST["phone"]; $verif_box = $_POST["verif_box"]; $subject = stripslashes($subject); $message = stripslashes($message); $from = stripslashes($from); $name = stripslashes($name); $phone = stripslashes($phone); $embody = "$name $phone $message"; if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){ mail("ed@treework.net", 'Online Form: '.$subject, $_SERVER['REMOTE_ADDR'].$embody, "From: $from"); setcookie('tntcon',''); } else if(isset($message) and $message!=""){ header("Location:".$_SERVER['HTTP_REFERER']."?subject=$subject&from=$from&message=$message&wrong_code=true"); exit; } else { echo "no variables received, this page cannot be accessed directly"; exit; } ?> <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>E-Mail Sent</title> <style type="text/css"> <!-- body,td,th { font-family: Arial, Helvetica, sans-serif; font-size: 12px; } --> </style></head> <body> Email sent. Thank you.<br /> <br /> Return to <a href="/">home page</a> ? </body> </html>]
×
×
  • 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.