-
Posts
82 -
Joined
-
Last visited
spanner206's Achievements
Member (2/5)
0
Reputation
-
o yh and how would i double check if the id is hidden
-
god im crap at this thank you so much for pointing that out mac_gyver
-
the view source is <select name="typeofbusiness"> <option value=''> - select type of business -</option> <option value=''></option> </select> so they is quite a bit missing this is my current code <td>Type of Business:</td> <td> <select name="typeofbusiness"> <option value=''> - select type of business -</option> <?php $sql = "SELECT tbl_typeofbusiness.id, tbl_typeofbusiness.Agent FROM tbl_typeofbusiness;"; $res = mysqli_query($con, $sql) or die (mysqli_error($con)); while (list($id, $tob) = mysqli_fetch_row($res)); { echo "<option value='$id'>$tob</option>\n"; } ?> </select>
-
btw no errors are showing up
-
right ive done that and ive realised ive made the most rookie mistake ever by searching for the wrong table.... 3 DAYS IVE BEEN LOOKING AT THE SAME PROBLEM. anyway last problem the data is still not being pulled from the database into the drop down box any ideas?
-
yh ive tried that and for some reason everything under or die will stop working e.g. ive got about 5 -6 other fields under type of business and they will not appear, in the form. when i do this no error occurs aswell and still nothing is being pulled from the database any ideas???
-
O aswell no values are showing in the drop down box
-
hopefully this will be the end of this little project but ive been trying to do this for a while now i need to get 2 different collumns one of which is hidden which will be the ID one has the value of the field e.g. test, im hopefully down to the last error. ( ! ) Warning: mysqli_fetch_row() expects parameter 1 to be mysqli_result, boolean given in C:\wamp\www\AddLeads\addeadstemplate.php on line 254 Call Stack # Time Memory Function Location 1 0.0000 186408 {main}( ) ..\addeadstemplate.php:0 2 0.0156 194880 mysqli_fetch_row ( ) ..\addeadstemplate.php:254 <tr> <td>Type of Business:</td> <td> <select name="typeofbusiness"> <option value=''> - select type of business -</option> <?php $sql = "SELECT tbl_typesofbusiness.id, tbl_typesofbusiness.Agent FROM tbl_typesofbusiness"; $res = mysqli_query($con, $sql) or (mysqli_error($con)); while (list($id, $tob) = mysqli_fetch_row($res)); { echo "<option value='$id'>$tob</option>\n"; } ?> </select> </td> <td><span class="error">* <?php if (isset($errors['typeofbusiness'])) echo $errors['typeofbusiness']; ?></span></td> </tr> i can get rid of the error bie adding 'or die' on line 253 other than just or but what this does is stop everything under or die stops working cause ive got another 6 or 7 fields under type of business aswell as this no error occurs so im confused to hell, hopefully its not to complicated any help will be greatly appreciated
-
2 collumns 1 hidden pulled from a table HELP!
spanner206 replied to spanner206's topic in PHP Coding Help
yh sorry about that a couple of minuites before u sent that i put a space in and it kinda worked ile put this version in now -
2 collumns 1 hidden pulled from a table HELP!
spanner206 replied to spanner206's topic in PHP Coding Help
o and theres nothing being pulled from the database :/ -
2 collumns 1 hidden pulled from a table HELP!
spanner206 replied to spanner206's topic in PHP Coding Help
right scratch that i just figured that one out now theres no error at all and half of my html form is missing???? -
2 collumns 1 hidden pulled from a table HELP!
spanner206 replied to spanner206's topic in PHP Coding Help
( ! ) Warning: mysql_error() expects parameter 1 to be resource, object given in C:\wamp\www\AddLeads\addeadstemplate.php on line 252 Call Stack # Time Memory Function Location 1 0.0000 186392 {main}( ) ..\addeadstemplate.php:0 2 0.0312 194824 mysql_error ( ) ..\addeadstemplate.php:252 -
2 collumns 1 hidden pulled from a table HELP!
spanner206 replied to spanner206's topic in PHP Coding Help
now i got the same error on 252 /: -
2 collumns 1 hidden pulled from a table HELP!
spanner206 replied to spanner206's topic in PHP Coding Help
<!DOCTYPE HTML> <html> <head> <style> .error {color: #FF0000;} </style> </head> <body> <?php $con = mysqli_connect("localhost","root","","nib"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // define variables and set to empty values $id = $companyname = $firstname = $address1 = $address2 = $county = $city = $postcode = $email = $website = $clubphone = $homephone = $mobilephone = $typeofbusiness = $renewaldate = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { $errors = array(); if (empty($_POST["companyname"])) { $errors['companyname'] = "Please Enter Your companyname"; }elseif(preg_match_all("/[(?\/<>*:.@)]/i",$_POST['companyname'],$matches)){ // list of invalid characters #echo '<pre>',print_r($matches),'</pre>'; $invalid_characters = implode($matches[0]); $errors['companyname'] = 'Cannot use '.$invalid_characters; } elseif(strlen($_POST['companyname']) > 220) { $errors['companyname'] = 'Company name must be less then 220 characters'; } elseif(strpos($_POST['companyname'], 'The ') !== false) { $errors['companyname'] = 'Company Names cant start with The'; } elseif(strpos($_POST['companyname'], 'the ') !== false) { $errors['companyname'] = 'Company Names cant start with the'; } elseif(strpos($_POST['companyname'], 'THE ') !== false) { $errors['companyname'] = 'Company Names cant start with THE'; } if (empty($_POST["typeofbusiness"])) { $errors['typeofbusiness'] = "Please Enter Your type of business"; } elseif(strpos($_POST['typeofbusiness'], '/') !== false) { $errors['typeofbusiness'] = 'Cannot use /'; } else { $typeofbusiness = test_input($_POST["typeofbusiness"]); } if (empty($_POST["firstname"])){ $errors['firstname'] = "Please Enter Your First Name"; }elseif(preg_match_all("/[(?\/<>*:.@)]/i",$_POST['firstname'],$matches)){ // list of invalid characters #echo '<pre>',print_r($matches),'</pre>'; $invalid_characters = implode($matches[0]); $errors['firstname'] = 'Cannot use '.$invalid_characters; } if (empty($_POST["address1"])){ $errors['address1'] = "Please Enter Your address1"; }elseif(preg_match_all("/[(?\/<>*:.@)]/i",$_POST['address1'],$matches)){ // list of invalid characters #echo '<pre>',print_r($matches),'</pre>'; $invalid_characters = implode($matches[0]); $errors['address1'] = 'Cannot use '.$invalid_characters; } if (empty($_POST["address2"])) {$address2 = test_input($_POST["address2"]);} if (empty($_POST["county"])){ $errors['county'] = "Please Enter Your county"; }elseif(preg_match_all("/[(?\/<>*:.@)]/i",$_POST['county'],$matches)){ // list of invalid characters #echo '<pre>',print_r($matches),'</pre>'; $invalid_characters = implode($matches[0]); $errors['county'] = 'Cannot use '.$invalid_characters; } if (empty($_POST["city"])){ $errors['city'] = "Please Enter Your county"; }elseif(preg_match_all("/[(?\/<>*:.@)]/i",$_POST['city'],$matches)){ // list of invalid characters #echo '<pre>',print_r($matches),'</pre>'; $invalid_characters = implode($matches[0]); $errors['city'] = 'Cannot use '.$invalid_characters; } if (empty($_POST["postcode"])){ $errors['postcode'] = "Please Enter Your postcode"; }elseif(preg_match_all("/[(?\/<>*:.@)]/i",$_POST['postcode'],$matches)){ // list of invalid characters #echo '<pre>',print_r($matches),'</pre>'; $invalid_characters = implode($matches[0]); $errors['postcode'] = 'Cannot use '.$invalid_characters; } else { $postcode = test_input($_POST["postcode"]); } $sql = sprintf("SELECT COUNT(*) as total FROM tbl_club_contacts WHERE postcode = '%s' ", $con->real_escape_string($postcode)); $result = $con->query($sql); $row = $result->fetch_assoc(); if ($row['total'] > 0) { $errors['postcode'] = "The name '$postcode' already exists."; } if (empty($_POST["email"])) { $errors['email'] = "Please Enter Your email"; } elseif(strpos($_POST['email'], '/') !== false) { $errors['email'] = 'Cannot use /'; } else { $email = test_input($_POST["email"]); } if (empty($_POST["website"])) { $errors['website'] = "Please Enter Your website"; } elseif(strpos($_POST['website'], '/') !== false) { $errors['website'] = 'Cannot use /'; } else { $website = test_input($_POST["website"]); } if (empty($_POST["clubphone"])) { $errors['clubphone'] = "Please Enter Your clubphone"; } elseif(preg_match_all("/[(?\/<>*:.@a-z)]/i",$_POST['clubphone'],$matches)){ // list of invalid characters $invalid_characters = implode($matches[0]); $errors['clubphone'] = 'Cannot use '.$invalid_characters; } else { $clubphone = test_input($_POST["clubphone"]); } if (empty($_POST["homephone"])) { $errors['homephone'] = "Please Enter Your home phone"; } elseif(preg_match_all("/[(?\/<>*:.@a-z)]/i",$_POST['homephone'],$matches)){ // list of invalid characters #echo '<pre>',print_r($matches),'</pre>'; $invalid_characters = implode($matches[0]); $errors['homephone'] = 'Cannot use '.$invalid_characters; } else { $homephone = test_input($_POST["homephone"]); } if (empty($_POST["mobilephone"])) { $errors['mobilephone'] = "Please Enter Your mobilephone"; } elseif(preg_match_all("/[(?\/<>*:.@a-z)]/i",$_POST['mobilephone'],$matches)){ // list of invalid characters #echo '<pre>',print_r($matches),'</pre>'; $invalid_characters = implode($matches[0]); $errors['mobilephone'] = 'Cannot use '.$invalid_characters; } else { $mobilephone = test_input($_POST["mobilephone"]); } if (empty($_POST["renewaldate"])) { $errors['renewaldate'] = "Please Enter Your renewaldate"; } elseif(strpos($_POST['renewaldate'], '/') !== false) { $errors['renewaldate'] = 'Cannot use /'; } else { $renewaldate = test_input($_POST["renewaldate"]); } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <h2>Add Leads</h2> <p><span class="error">* required field.</span></p> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <table border = "0"> <tr> <td>Company Name:</td><td> <input type="text" name="companyname"></td> <td><span class="error">* <?php if (isset($errors['companyname'])) echo $errors['companyname']; ?></span></td> </tr> <tr> <td>Type of Business:</td> <td> <select name="typeofbusiness"> <option value=''> - select type of business -</option> <?php $sql = "SELECT id, Agent FROM tbl_typesofbusiness"; $res = mysqli_query($con, $sql); while (list($con, $id, $typeofbusiness) = mysqli_fetch_row($res)) { echo "<option value='$id'>$typeofbusiness</option>\n"; } ?> </select> </td> <td><span class="error">* <?php if (isset($errors['typeofbusiness'])) echo $errors['typeofbusiness']; ?></span></td> </tr> <tr> <td>First Name:</td><td> <input type="text" name="firstname"></td> <td><span class="error">* <?php if (isset($errors['firstname'])) echo $errors['firstname']; ?></span></td> </tr> <tr> <td>Address 1:</td><td> <input type="text" name="address1"></td> <td><span class="error">* <?php if (isset($errors['address1'])) echo $errors['address1']; ?></span></td> </tr> <tr> <td>Address 2:</td><td><input type="text" name="address2"></td> <tr> <td>Post Code:</td> <td><input type="text" name="postcode"></td> <td><span class="error">* <?php if (isset($errors['postcode'])) echo $errors['postcode']; ?></span></td> </tr> <tr> <td>County:</td> <td> <select name="county"> <option>-- please select one --</option> <option>Bedfordshire</option> <option>Berkshire</option> <option>Bristol</option> <option>Buckinghamshire </option> <option>Cambridgeshire </option> <option>Cheshire</option> <option>City of London</option> <option>Cornwall</option> <option>Cumbria </option> <option>Devon</option> <option>Derbyshire </option> <option>Dorset</option> <option>County Durham</option> <option>East Riding of Yorkshire</option> <option>East Sussex</option> <option>Essex</option> <option>Gloucestershire </option> <option>Greater London</option> <option>Greater Manchester</option> <option>Hampshire</option> <option>Herefordshire</option> <option>Hertfordshire</option> <option>Isle of Wight</option> <option>Kent</option> <option>Lancashire</option> <option>Leicestershire</option> <option>Lincolnshire</option> <option>Merseyside</option> <option>Norfolk</option> <option>North Yorkshire</option> <option>Northamptonshire </option> <option>Northumberland </option> <option>Nottinghamshire </option> <option>Oxfordshire </option> <option>Rutland </option> <option>Shropshire </option> <option>Somerset </option> <option>South Yorkshire </option> <option>Staffordshire </option> <option>Suffolk </option> <option>Surrey </option> <option>Tyne and Wear</option> <option>Warwickshire </option> <option>West Midlands </option> <option>West Sussex</option> <option>West Yorkshire </option> <option>Wiltshire</option> <option>Worcestershire</option> </td> <td><span class="error">* <?php if (isset($errors['county'])) echo $errors['county']; ?></span></td> </tr> <tr> <td>City:</td> <td> <select name="city"> <option>-- please select one --</option> <option>Derby</option> <option>test2</option> <option>test3</option> <option>test4</option> <option>test5</option> <option>test6</option> <option>test7</option> <option>test8</option> <option>test9</option> <option>test10</option> </td> <td><span class="error">* <?php if (isset($errors['city'])) echo $errors['city']; ?></span></td> </tr> <tr> <td>Email:</td> <td><input type="text" name="email"></td> <td><span class="error">* <?php if (isset($errors['email'])) echo $errors['email']; ?></span></td> </tr> <tr> <td>Website:</td> <td><input type="text" name="website"></td> <td><span class="error">* <?php if (isset($errors['website'])) echo $errors['website']; ?></span></td> </tr> <tr> <td>Club phone:</td> <td><input type="integer" name="clubphone"></td> <td><span class="error">* <?php if (isset($errors['clubphone'])) echo $errors['clubphone']; ?></span></td> </tr> <tr> <td>Home phone:</td> <td><input type="integer" name="homephone"></td> <td><span class="error">* <?php if (isset($errors['homephone'])) echo $errors['homephone']; ?></span></td> </tr> <tr> <td>Mobile Phone:</td> <td><input type="integer" name="mobilephone"></td> <td><span class="error">* <?php if (isset($errors['mobilephone'])) echo $errors['mobilephone']; ?></span></td> </tr> <tr> <td>Renewal Date:</td> <td><input type="date" name="renewaldate"></td> <td><span class="error">* <?php if (isset($errors['renewaldate'])) echo $errors['renewaldate']; ?></span></td> </tr> <tr> <td><input type="submit" name="submit" value="Submit"></td> </tr> <?php if($_SERVER['REQUEST_METHOD'] == "POST" && count($errors) == 0) { // Do it { $con = mysqli_connect("localhost","root","","nib"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql="INSERT INTO tbl_club_contacts (ID, CompanyName, FirstName, Address1, Address2, County, City, PostCode, Email, Website, ClubPhone, HomePhone, MobilePhone, TypeofBusiness, RenewalDate ) VALUES ('$_POST[id]''$_POST[companyname]','$_POST[firstname]','$_POST[address1]','$_POST[address2]','$_POST[county]','$_POST[city]','$_POST[postcode]','$_POST[email]','$_POST[website]','$_POST[clubphone]','$_POST[homephone]','$_POST[mobilephone]','$_POST[typeofbusiness]','$_POST[renewaldate]')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); echo "record added"; } mysqli_close($con); } // end if $errors == 0 } ?> </form> </body> </html> lol forgot code -
2 collumns 1 hidden pulled from a table HELP!
spanner206 replied to spanner206's topic in PHP Coding Help
this is the whole code that ive been using since the start, i think the error is something to do with a query fault any ideas???