-
Posts
498 -
Joined
-
Last visited
Never
Everything posted by jesushax
-
well this line $selected = "SELECT * FROM $tbl_name WHERE username='$myusername' and password='$myapassword'"; you have no reference to the variables $myusername and $myapassword, im presuming you have an extra 'A' in there but wha tyou need to do is either post the username and password in the url which i dont advise or on the checklogin.php page create $_SESSION["username"] = stripslashes($myusername); and the same for password then you will have the username and password stored in a session then on the members_area.php you can call the sessions $myusername = $_SESSION["username"] then your SQL will work, also when using sessions add session_start(); at the top of the page after the <?php tag hope this helps
-
hi all hope i make sense here, personally i dont see how it can be done, but will ask if anyones got an idea anyway. at the moment everyone in the directory is listed alphabetically, which is unfair on members really, only ones beginging with A are every going to make the front page, i need a more fair way of doing it. i though of using random, then everyone would get a go, but with using pagnation if a user clicked page 2 another set of random records would appear, not the orginal random list. how could we create a random list and keep that list for pagnation? below current code $Trade = urldecode($_GET["Trade"]); $max = 10; $p = @$_GET['p']; if(empty($p)) { $p = 1; } $limits = ($p - 1) * $max; $SQL = mysql_query("SELECT * FROM tblDirectory2 WHERE Sect1_2 LIKE '%$Trade%' ORDER BY Sect1_4 ASC LIMIT ".$limits.",$max") or die (mysql_error()); $totalres = mysql_result(mysql_query("SELECT COUNT(CompanyID) AS tot FROM tblDirectory2 WHERE Sect1_2 LIKE '%$Trade%' "),0); $totalpages = ceil($totalres / $max); Thanks
-
hi all, When posting my form to be processed, register.php if certain fields arent filled in redirecst the user back to the form with error text but all the data they already inputted is lost is there an easy way to recall this data? Thanks
-
done it <?php $CurrentYear = date("Y"); $StartYear = 1985; $CompanyAge = $CurrentYear - $StartYear; echo $CompanyAge; ?>
-
hi all, what im trying to find out how to do is from a year eg, 1985 a script to work out that that person is 24 anyone know how? thanks
-
hi all my code below, updates my table according to form data it recieves, what ive found out though, if a user unticks a checbox or deltes text in a field, the data is not posted so a user cant update any checkboxes, is there away that a form can post all its fields even if the field has nothing in it? i know if i put each post in a variable i can do it that way becuase the variable will be empty but a way for the below code to work, the whole point of my code below was to save me typing out 100s of variables Cheers case "part5"; $ID = $_SESSION["DirectoryID"]; $posts = $_POST; $SQL = "UPDATE tblDirectory2 SET "; foreach($posts as $key=>$value){ $SQL .= "`".mysql_real_escape_string($key)."`='".mysql_real_escape_string($value)."', "; } $SQL = rtrim($SQL,", "); $SQL .=" WHERE `CompanyID`='$ID'"; echo "<p>".$SQL."</p>"; mysql_query($SQL) or die (mysql_error()); header("Location: /new_directory/reg_completed.php"); exit(); break;
-
[SOLVED] posting variable into a function doesnt work?
jesushax replied to jesushax's topic in PHP Coding Help
still didnt work though :| hmmmmmm -
[SOLVED] posting variable into a function doesnt work?
jesushax replied to jesushax's topic in PHP Coding Help
ahhh yes! stupid me! lol -
hi all the below code, when putting a variable value above the finction then running the function, it doesnt work, is it becuase unctions are the first thing run on a page? (so the error doesnt appear in the table) <?php function ShowForm() { ?> <div class="text"> <h2>Staff Log In </h2> <form id="form" method="post" action="/includes/login.php" class="menu"> <table width="544"> <tr> <td>Username:</td> <td><input name="txtUserName" type="text" size="20" /></td> <td rowspan="5"> </td> </tr> <tr> <td>Password:</td><td><input name="txtPassword" type="password" size="20" /></td> </tr> <tr> <td> </td> <td><input name="submit" type="submit" value="Login" /></td> </tr> <tr> <td colspan="2"><?php echo $error; ?></td> </tr> <tr> <td colspan="2">Lost your password? <a href="/admin/lostpass.php">Click Here</a></td> </tr> </table> </form> </div> <?php } switch(@$_GET["action"]) { Case "adminonly": include($_SERVER['DOCUMENT_ROOT'] . '/includes/connection.php'); include($_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'); $error = '<span style="padding-top:30px; color:#FF0000; ">'; $error .= '<strong>Error:</strong><br /> You need to be a member of staff to access these pages.'; $error .= '</span>'; ShowForm();
-
if statement help, excuting code once something has ended
jesushax replied to jesushax's topic in PHP Coding Help
That got it thanks yeah the linebreaks where for readability of the source cheers again -
if statement help, excuting code once something has ended
jesushax posted a topic in PHP Coding Help
hi all below is my code it works fine apart from if the loop of rows ended on a number less than 6 at the moment i get three columsn fine then the last colum only has 3 <li></li>s in so its not putting the final, </ul> and </div> on it i cant think of how to check if there is less than 6 at the end without making it put a </ul></div> after every record anyone help? $SQL = mysql_query("SELECT * FROM tblTrades ORDER BY 'trades' DESC") or die(mysql_error()); $col = 1; $colMax = 6; while($list=mysql_fetch_array($SQL)) { if ($col == 1) { echo '<div class="columns">'."\n"; echo "<ul>\n"; } echo '<li>'.$list["trades"].'</li>'."\n"; if ($col == $colMax) { echo " </ul>\n"; echo " </div>\n"; $col = 1; } else { $col++; } if ($col > $colMax) { echo " </ul>\n"; echo " </div>\n"; } } -
else if($userstats3[food]>=5) { <------ missing print "<br>"; print "Manpower: +1<br>"; print "Research: +1<br>"; print "<br>"; print "Cost:<br>"; print "Food: -5<br>"; print "Peasants: -1<br>"; print "<form action='peasant2labor.php?ID=$user3stats[iD]' method='post'>"; print "<input type='text' name='scipts' size='6'><br>"; print "<input type='submit' name='submit' value='submit'></form>"; print "</td></tr></table>"; print "</td>"; }<------ missing }
-
first when collecting information from a form you dont use $_GET, you use $_POST so your code will be $email = $_POST["email"]; etc so $con_id = $_POST["first_name"]; and the parts inbetween the [""] are the fieldnames from the form so for your dropdown list <select name="first_name"> <option>fred</option> <option>jason</option> </select> then the variable $con_id would pick up fred or jason which ever was slected hope that helps Alex
-
gotcha, thank alot
-
but will LIKE get them if the word Architects is anywhere in the field not just at the begining? thanks
-
hi all what im tryign to do is, find a value in a field to return results by eg mysql_query("SELECT 8 * FROM tblDirectory WHERE Sect1_2='Has the value Architects inside it'") or die(mysql_error()); the field Sect1_2 has values delimited by commas "Architects, Builders, Joiners, Plumbers," so i would like to be able to return all results that have the word Architects in how would i do that? Thanks
-
[SOLVED] SQL error i cant spot it can you help?
jesushax replied to jesushax's topic in PHP Coding Help
sorted, silly me, should of recognised that!! :| Thankyou though -
hi all i have an error below can anyone spot it? the debug is first UPDATE tblDirectory2 SET (`Sect2_1`='1,000,000,000', `Sect2_2`='1,000,000,000', `Sect2_3`='1,000,000,000', `Sect2_4`='1,000,000,000', `Sect2_5`='1,000,000,000', `Sect3_1`='More than 1.5m', `Sect3_2`='1', `Sect3_3`='More than 1.5m', `Sect3_4`='More than 1.5m', `Sect3_5`='CIS 6', `Sect4_1`='Genius foundations, creator life', `Sect4_2`='website gurus', `Sect4_3`='sasuages certified' WHERE `CompanyID`='4') You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(`Sect2_1`='1,000,000,000', `Sect2_2`='1,000,000,000', `Sect2_3`='1,000,000,000'' at line 1
-
what is the error?
-
[SOLVED] need some idea, for updating database
jesushax replied to jesushax's topic in PHP Coding Help
sorted out the security issue, so for all of my datbase input i should have it mysql_real_escape_string on everything and it in ``? i hadnt added the where statement yet, done that now but if i have ,,1,,,,1,1 etc i have another script for putting those values into a list, where it searches for text between commas $TradesField = $row["Sect1_2"]; $trades = array_map('trim',explode(',',rtrim($TradesField,','))); $st = 0; $len = 3; $part = array_slice($trades,$st,$len); while (!empty($part)) { echo '<ul><li>' . implode('</li><li>',$part) . "</li></ul>\n"; $st += $len; $part = array_slice($trades,$st,$len); } -
hi all below is my code for updating my database the field Sect1_2 is updated from multiple checkboxes the multiple checkboxes insert values into the field Trades sperated by a comma so say a user wanted to update the field Trades they would essentially have to tick all the boxes again, i dont want to do that what i though i would do, was put the current value of the trades into a hidden field then check that none of the checboxes have been checked (this i dont know how to do) then if they havent been checked then post the hidden field back into the db, this sound like a good idea and can anyone help me do the checkboxes bit? Thanks $posts = $_POST; for($i=1; $i<=21; $i++) { unset($posts['T'.$i]); } $SQL = "UPDATE tblDirectory2 SET ("; foreach($posts as $key=>$value){ $SQL .= "`$key`='$value', "; } $const = "T" ; for ($i=1;$i<=21;$i++){ $var = trim($_POST[$const.$i]) ; if(!empty($var)) { $trades .= $_POST[$const.$i] . "," ; } } $SQL .="`Sect1_2`='".mysql_real_escape_string($trades)."')"; echo "<p>".$SQL."</p>";
-
[SOLVED] turn field results sperated by comma into list
jesushax replied to jesushax's topic in PHP Coding Help
PMSL!!! Loving your sense of humour!!! well she is isnt she lol -
[SOLVED] turn field results sperated by comma into list
jesushax replied to jesushax's topic in PHP Coding Help
that did it, thank you both very much -
[SOLVED] turn field results sperated by comma into list
jesushax replied to jesushax's topic in PHP Coding Help
it comes out Architects / Designers, no trailing spaces