pocobueno1388
Members-
Posts
3,369 -
Joined
-
Last visited
Never
Everything posted by pocobueno1388
-
You would use BETWEEN SELECT * FROM table WHERE `date` BETWEEN '$date1' AND '$date2'
-
[SOLVED] How to change where the "echo" appears
pocobueno1388 replied to weetabix's topic in PHP Coding Help
You had A LOT of unneeded else if statements. You were also calling the function every single time you added an error...which won't work. Change your code to this <?php if (!is_numeric($_POST['staffid'])) $error[] = 'Please enter a numeric staff id'; //Username must not be left empty if (empty($_POST['username'])) $error[] = 'You need to enter a username'; //Password must not be left empty if (empty($_POST['password'])) $error[] = 'You need to enter a username'; //Telephone number must not be empty and be numeric if (!is_numeric($_POST['telephone']) || empty($_POST['telephone'])) $error[] = 'Please enter a numeric telephone number'; //Position ID must be entered if (!is_numeric($_POST['positionid'])) $error[] = 'Please enter a numeric position id'; //First name shall be completed if (empty($_POST['firstname'])) $error[] = 'Please enter your first name'; //Last name shall be completed if (empty($_POST['surname'])) $error[] = 'Please enter your last name'; //Address as well if (empty($_POST['address'])) $error[] = 'Please enter your address'; //And postcode if (empty($_POST['postcode'])) $error[] = 'Please enter your postcode'; //Working hours must be numeric and not null if (!is_numeric($_POST['workhrs']) || empty($_POST['workhrs'])) $error[] = 'Please enter numeric working hours'; //E-Mail must be of a proper format if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email'])) $error[] = 'Please enter a valid email address'; if (!empty($error)){ show_form($error); exit; } ?> -
Change your code to this <?php if (isset($_POST['Submit'])){ if (eregi('^[[:digit:]]{3}\-[[:digit:]]{0,2}\-[[:digit:]]{4}$', $_POST['socials'])) { echo 'Valid Social Security Format'; } else { echo 'Invalid Social Security Format'; } } ?> <p>NOTE: Social secrity format is xxx-xx-xxxx</p> <form method="post" action="quiz.html" name="q1"> Social Securtiy <input type="text" name="socials" id="socials" /> <input type="submit" value="Submit" name="Submit" /> </form>
-
[SOLVED] How to change where the "echo" appears
pocobueno1388 replied to weetabix's topic in PHP Coding Help
So the errors display fine the first time, but when you recall the function to reload the page it only displays one error when there are more? Could you post the code to where you recall the function the second time? I'm having trouble figuring out what your trying to say...so I may be way off. -
[SOLVED] How to change where the "echo" appears
pocobueno1388 replied to weetabix's topic in PHP Coding Help
I'm not sure what you mean by that. Post the code your using. -
[SOLVED] How to change where the "echo" appears
pocobueno1388 replied to weetabix's topic in PHP Coding Help
Well, what happened? What didn't work about it? -
[SOLVED] How to change where the "echo" appears
pocobueno1388 replied to weetabix's topic in PHP Coding Help
Okay, you can do something like this with your function <?php function show_form($errors = FALSE){ ?> <form action="addStaff.php" method="post"> <table width="50%" height="54%" cellspacing="1"> <tr> <td height="59" width="476" colspan="4"> <p align="center">Add a new staff member</td> </tr> <?php if (isset($errors)){ echo '<tr><td><b>ERRORS</b><p>'; foreach ($errors as $error){ echo '-'.$error.'<br>'; } echo '</td></tr>'; } ?> <tr> <td height="44" width="76">Staff ID:</td> <td height="44" width="128"><input type = "Text" name="staffid"></td> <td height="44" width="119">First Name</td> <td height="44" width="135"><input type = "Text" name="firstname"></td> </tr> <tr> ?> You can now pass an array of errors to your function, and it will display them if there are any. Here is an example of how you would call the function in your case <?php if(is_numeric($_POST['staffid'])){ }else{ $error[] = "Please enter a numeric staff id"; $error[] = "You can do as many errors as you want"; show_form($error); exit; } ?> -
You never really stated the problem, but doing a search on google this is the regex I came up with ^\d{3}-\d{2}-\d{4}$ You may want to give that a try.
-
[SOLVED] How to change where the "echo" appears
pocobueno1388 replied to weetabix's topic in PHP Coding Help
It's hard to help you with your vague explanation. I'm assuming the table you want to display the error message in is in the show_form() function? If so, you can make the message a parameter of the function. Post your code to the show_form() function and explain more exactly what you want. -
The parse error is coming from this line echo "<b><u>Yo</u></b>".$aboutme."<br> Change it to echo "<b><u>Yo</u></b>".$aboutme."<br>";
-
I think "when" might be a mysql reserved word. Try changing it to this $query = "INSERT INTO `unauthorized` (UserID,`When`) Values ('{$_SESSION['Current_User']}', '$Date')"; mysql_query($query) or die(mysql_error().'<p>'.$query);
-
You didn't select anything from the database but the "cat", so change your query to this SELECT cat, name, url FROM bookmarks WHERE cat='php'
-
Use nl2br() on the data coming out of the database www.php.net/nl2br
-
[SOLVED] Number of input fields based on int
pocobueno1388 replied to 2tonejoe's topic in PHP Coding Help
<?php $query = mysql_query("SELECT number FROM table")or die(mysql_error()); $row = mysql_fetch_assoc($query); $number = $row['number']; //this is the number between 0-4 for ($i=0; $i<$number; $i++){ echo "<input name='text".$i."' value='Text' type='text' size='30' /><br>"; } ?> -
I honestly think you just need to keep pursuing the problem to figure out whats actually wrong with it. Don't just put a quick fix over it, because chances are it's going to come back and bite you again.
-
your most weird obsession or weird thing about you?
pocobueno1388 replied to kellz's topic in Miscellaneous
Yeah...even crashing and burning I'm so kidding, don't take that personally, haha. -
Did you try my suggestion?
-
Okay, look at your first lines of code <?php if (!isset($_SESSION)){ session_start(); } ?> That is saying if there are NO sessions, then call session start. That makes no sense, you want to use session start if there ARE sessions. So take away the exclamation point.
-
Put it anywhere it's going to be executed...since you put it in your connection script, it should have been executed. So the session is still dying? Hmm...I'm out of ideas for this one =/
-
[SOLVED] Can some one help with this error?
pocobueno1388 replied to herghost's topic in PHP Coding Help
Change these lines $sql = "select *, s.abbr as sabbr, co.abbr as cabbr from cities c,states s,countries co where s.state=$state and c.city=$city and co.country=$country"; $result = db_query ($sql); To $sql = "select *, s.abbr as sabbr, co.abbr as cabbr from cities c,states s,countries co where s.state='$state' and c.city='$city' and co.country='$country'"; $result = db_query($sql)or die(mysql_error() .'<p>QUERY: '.$sql); Post any errors you get. -
[SOLVED] Can some one help with this error?
pocobueno1388 replied to herghost's topic in PHP Coding Help
Post your code -
Run this code, and see if it fixes the problem ini_set("session.gc_maxlifetime","7200");
-
It's impossible for anyone to figure out your problem without just guessing if we don't have any code to look at. You never answered my question, are you sure your calling session_start() at the top of all your pages?
-
Are you using sessions or cookies? If your using sessions, make sure your calling session_start at the top of each page.
-
<?php $name = "Blah blah blah blah"; if (strlen($name) > $name = substr($name,0,.'...'; echo $name; ?>