Jump to content

jcbones

Staff Alumni
  • Posts

    2,653
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by jcbones

  1. What does your database structure look like. You could be sending the database data that it isn't expecting for that column.
  2. You can copy/paste however. Right? Post what you have tried, and tell us specifically where you need help. I promise, this will go much faster, and you will get much better replies.
  3. You can create an anchor on an image, but you cannot put an image as the reference in an anchor. You could eliminate the mail anchor, and instead handle that server side with PHPMailer. The reason I suggest this is that even if you change the output, the source will always have the email address, and the source is what is scraped.
  4. No problem. We realize how difficult it is to explain things so that others may understand. Hopefully, most realize how hard it is to try and understand when you aren't looking over their shoulder at what they are looking at.
  5. I tested the updated function that was posted in post #6 above, it renders the counties/cities in 3 separate columns as you desire. I do notice that you are not using the function posted in post #6. Perhaps, you could look at that post again carefully, and compare it to what you have.
  6. No, the auto increment field will populate itself, BUT you will get errors if you don't follow a couple of rules. 1. If you run an insert query, and don't specify column names, you must provide a value for each and every column. That would change your query to: based off of adding one auto increment column at the BEGINNING of the table. $r = mysql_query("insert into points values ('','${v[0]}', ${v[1]}, '$At') on duplicate key update Points = Points + ${v[1]}"); 2. If you specify the column names, you can skip the columns that are auto populated. OR column names are made up, and probably do not reflect your column names. $r = mysql_query("insert into points(Name,Points,Location) values ('${v[0]}', ${v[1]}, '$At') on duplicate key update Points = Points + ${v[1]}");
  7. I'm in a giving mood tonight, see if this helps. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Update My Phone Number</title> </head> <body bgcolor="White" > <table width="640"> <tr><td><hr width="640" size="2" color="Red" align="left"></td></tr> <tr><td align="left"><font size="+3"><strong>Update Employee Telephone Numbers</strong></font></td></tr> <tr><td><hr width="640" size="2" color="gray" align="left"></td></tr> </table> <br> <?php $employee = (!empty($_POST['employee'])) ? htmlentities($_POST['employee'],ENT_QUOTES) : NULL; $department = (!empty($_POST['department'])) ? htmlentities($_POST['department'],ENT_QUOTES) : NULL; $work = (!empty($_POST['work'])) ? htmlentities($_POST['work'],ENT_QUOTES) : NULL; $cell = (!empty($_POST['cell'])) ? htmlentities($_POST['cell'],ENT_QUOTES) : NULL; $home = (!empty($_POST['home'])) ? htmlentities($_POST['home'],ENT_QUOTES) : NULL; $pager = (!empty($_POST['pager'])) ? htmlentities($_POST['pager'],ENT_QUOTES) : NULL; $message = (!empty($_POST['message'])) ? htmlentities($_POST['message'],ENT_QUOTES) : NULL; $form_block = " <FORM METHOD=\"post\" ACTION=\"\"> <p><strong>Employee name: <font size=\"-1\"><em>(Exactly as it should be listed)</em></font> <font color=\"#FF0000\">**Required</font></strong><br> <INPUT TYPE=\"text\" NAME=\"employee\" VALUE=\"$employee\" SIZE=\"75\" MAXLENGTH=\"100\"></p> <p><strong>Department: <font size=\"-1\"><em>(Exactly as it should be listed)</em></font> <font color=\"#FF0000\">**Required</font></strong><br> <INPUT TYPE=\"text\" NAME=\"department\" VALUE=\"$department\" SIZE=\"75\" MAXLENGTH=\"50\"></p> <p><strong>Work Phone Number <font color=\"#FF0000\">**Required</font></strong><br> <INPUT TYPE=\"text\" NAME=\"work\" VALUE=\"$work\" SIZE=\"15\" MAXLENGTH=\"15\"></p> <p><strong>Cell Phone Number <font color=\"#FF0000\">**Required -- enter \"na\" for not applicable</font></strong><br> <INPUT TYPE=\"text\" NAME=\"cell\" VALUE=\"$cell\" SIZE=\"15\" MAXLENGTH=\"15\"></p> <p><strong>Home Phone Number <font color=\"#FF0000\">**Required -- enter \"na\" for not applicable</font></strong><br> <INPUT type=\"text\" Name=\"home\" VALUE=\"$home\" SIZE=15 \" MAXLENGTH=\"15\"> </p> <p><strong>Pager Number <font color=\"#FF0000\">**Leave blank if you don't have a pager</font></strong><br> <INPUT type=\"text\" Name=\"pager\" VALUE=\"$pager\" SIZE=15 MAXLENGTH=\"15\"> </p> <p><strong>Comments:</strong><br> <TEXTAREA NAME=\"message\" ROWS=5 COLS=50 WRAP=virtual>$message</TEXTAREA></p> <br> <p><em>Please wait for confirmation - this may take a few seconds.</em></p> <INPUT type=\"hidden\" name=\"op\" value=\"ds\"> <p><INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Click here to send this report\"></p> <br> </FORM> "; $send = 'yes'; if (empty($_POST['op']) || $_POST['op'] != "ds") { //they need to see the form echo "$form_block"; } else if (!empty($_POST['op']) && $_POST['op'] == "ds") { if ($employee == "") { $err[] = "<font color=red>Please enter employee name! **REQUIRED</font><br>"; $send = "no"; } if ($department == "") { $err[] = "<font color=red>Please enter your department! **REQUIRED</font><br>"; $send = "no"; } if ($work == "") { $err[] = "<font color=red>Please enter your work phone! **REQUIRED</font><br>"; $send = "no"; } if ($cell == "") { $err[] = "<font color=red>Please enter your cell phone! ** REQUIRED, enter \"na\" for not applicable</font><br>"; $send = "no"; } if ($home == "") { $err[] = "<font color=red>Please enter your home phone! *REQUIRED, enter \"na\" for not applicable!</font><br>"; $send = "no"; } if ($send != "no") { // it's okay to send $msg = "Please update the following phone numbers for: \t$employee\n\n"; $msg .= "Employee name:\t$employee\n\n"; $msg .= "Department:\t$department\n\n"; $msg .= "Work:\t$work\n\n"; $msg .= "Cell:\t$cell\n\n"; $msg .= "Home:\t$home\n\n"; $msg .= "Pager:\t$pager\n\n"; $msg .= "Comments:\t$message\n\n"; $to = "me@me.com"; $subject = "Phone Update: \t$employee, - \t$department\n"; $mailheaders = "From: UpdateMyPhone\n\n"; mail($to, $subject, $msg, $mailheaders); echo "<h1><font color=blue>Thank you! Your phone update has been filed. </font></h1><br> $form_block "; } else if ($send == "no") { foreach($err as $error) { echo $error; } echo $form_block; } } ?> </body> </html> Like This PS. You should be checking for variable types (validation), as well as sanitation.
  8. Even using your supplied array, the function returns the correct 3 columns. Source <h2>Independent cities of Virginia</h2> <table width='100%'> <tr> <td valign='top' width='33%'> <a href='services.php?city=1'>Alexandria</a><br /> <a href='services.php?city=2'>Bristol</a><br /> <a href='services.php?city=3'>Buena Vista</a><br /> <a href='services.php?city=4'>Charlottesville</a><br /> <a href='services.php?city=5'>Chesapeake</a><br /> <a href='services.php?city=6'>Colonial Heights</a><br /> <a href='services.php?city=7'>Covington</a><br /> <a href='services.php?city=8'>Danville</a><br /> <a href='services.php?city=9'>Emporia</a><br /> <a href='services.php?city=26'>etersburg</a><br /> <a href='services.php?city=10'>Fairfax</a><br /> <a href='services.php?city=11'>Falls Church</a><br /> <a href='services.php?city=12'>Franklin</a><br /> </td> <td valign='top' width='33%'> <a href='services.php?city=13'>Fredericksburg</a><br /> <a href='services.php?city=14'>Galax</a><br /> <a href='services.php?city=15'>Hampton</a><br /> <a href='services.php?city=16'>Harrisonburg</a><br /> <a href='services.php?city=17'>Hopewell</a><br /> <a href='services.php?city=18'>Lexington</a><br /> <a href='services.php?city=19'>Lynchburg</a><br /> <a href='services.php?city=20'>Manassas</a><br /> <a href='services.php?city=21'>Manassas Park</a><br /> <a href='services.php?city=22'>Martinsville</a><br /> <a href='services.php?city=23'>Newport News</a><br /> <a href='services.php?city=24'>Norfolk</a><br /> <a href='services.php?city=25'>Norton</a><br /> </td> <td valign='top' width='33%'> <a href='services.php?city=27'>Poquoson</a><br /> <a href='services.php?city=28'>Portsmouth</a><br /> <a href='services.php?city=29'>Radford</a><br /> <a href='services.php?city=30'>Richmond</a><br /> <a href='services.php?city=31'>Roanoke</a><br /> <a href='services.php?city=32'>Salem</a><br /> <a href='services.php?city=33'>Staunton</a><br /> <a href='services.php?city=34'>Suffolk</a><br /> <a href='services.php?city=35'>Virginia Beach</a><br /> <a href='services.php?city=36'>Waynesboro</a><br /> <a href='services.php?city=37'>Williamsburg</a><br /> <a href='services.php?city=38'>Winchester</a><br /> <a href='services.php?city=0'></a><br /> </td> </tr> </table> Compare this to your source.
  9. Since arrays are a very powerful tool in most programming and scripting languages, yes, I would suggest learning about them.
  10. Well, I'll mark it solved on the last relevant post then.
  11. Opening windows is client side, which would be javascript. You could use css to raise a <div>, and achieve the same results.
  12. No it doesn't. In fact, this is explained in the manual.
  13. In your second script, PHP may be having a hard time parsing this out: <?phpsession_start(); Change it to: <?php session_start(); Now see if $_SESSION['patchurl'] is set.
  14. We don't download files, is it really that hard to copy/ paste?
  15. Show us what you have tried, and we can guide you from there. We cannot and will not design and build anything for you in the help section. You would need to go to freelance for that.
  16. I agree Psycho, but for some reason when I was cruising your function, I missed the whole "return empty string if there is no data" line. Your function had that covered, it was my bad on calling that out when I shouldn't have. There was some undefined variables, but I know those were spoilers to make the OP use the errors that he SHOULD have turned on. I was just in a helping mood. Myotch, I tested the returns from the function for the columns. They were returned as they should be. Perhaps you could give us an update on the exact code you are now working with. I wonder also if you could give us a print_r of the $cityData variable, at the very bottom of the script. echo '<pre>' . print_r($cityData,true) . '</pre>'; //place at the very bottom of your script, run the script, then copy paste the results:
  17. There are a couple of different options that you need to look at. 1. Is the number always going to be an integer, or can a float be used? 2. Do you need to add type casting to it, or are you just going to test the string. is_numeric will return true on more than just integers or floats, and possibly allow results that you do not want. There are however a list of functions that test strings to see if they are specific types, a quick search of the manual should yield results (perhaps "character type checking"). However, these listing of functions will not pass a float. If that is an area that you wish to explore, perhaps you are stuck with a regex pattern to get the correct responses.
  18. As a further note, you should have already migrated away from mysql to either mysqli or PDO. It would be a travesty if I didn't mention that to you.
  19. Sorry, I read the code wrong. There are a couple of problems in the function, compare it to this one: function-by Psycho function createEntityOutput($stateName, $headerFormat, $entityData, $entityFormat, $columns) { //If no records, return empty string if(!count($entityData)) { return ''; } //Create the output $output = "<h2>" . sprintf($headerFormat, $stateName) . "</h2>\n"; $output .= "<table width='100%'>\n"; //Create needed variables $recTotal = count($entityData); $recPerCol = ceil($recTotal / $columns); $colWidth = floor(100 / $columns); $recCount = 0; //Create entity output $output .= "<tr>\n"; foreach($entityData as $data) { //Open new column, if needed if(++$recCount%$recPerCol==1) { $output .= "<td valign='top' width='{$colWidth}%'>\n"; } //Create output for single entitiy $output .= sprintf($entityFormat, $data['id'], $data['name']); //Close column, if needed if($recCount%$recPerCol==0 || $recCount==$recTotal) { $output .= "</td>\n"; } } $output .= "</tr>\n"; $output .= "</table>\n"; return $output; } Then: Replace while($cityData[] = mysql_fetch_assoc($result)) {} $cityTable = createEntityOutput($stateName, "Independent cities of %s", $cityData, "<a href='services.php?city=%d'>%s</a><br />\n", 3); With $cityTable = NULL;if(mysql_num_rows($result) > 0) { while($cityData[] = mysql_fetch_assoc($result)) {} $cityTable = createEntityOutput($stateName, "Independent cities of %s", $cityData, "<a href='services.php?city=%d'>%s</a><br />\n", 3);}
  20. Continuation of above post. When you have the table built like above: Populate the user_badges table with the id from the user table in the user_id column, and the id from the badges table in the badges_id column (NOT the badgesid column). To clarify, you will not need to use the badgesid column from the badges table to tie any tables together. Step 3. When you get the desired results from the database, you can return to PHP to code your script.
  21. EDIT: Chromium hates me. I'll be back with FF. I gave you an idea with a specific query (that works). Step 1: Get it working in your database, before you try to code anything in PHP. So, load up your database software (phpmyadmin), or enter the console manually. Step 2: Create a table called user_badges, here is the schema. CREATE TABLE IF NOT EXISTS `user_badges` ( `user_id` int(11) NOT NULL, `badges_id` int(11) NOT NULL )
  22. How I would do it is 2 tables: 2. badges 3. user_badges (which would be a two column table of: user_id, badge_id Then: UN-TESTED SELECT name, description, base FROM badges WHERE id IN ( SELECT badge_id FROM user_badges WHERE user_id = $current_user );
  23. Sanitation and validation are VERY important parts of database/ web interface procedure. Using PDO or MySQLi would go a long way in these procedures. Keeping your sites free of intruders.
  24. I agree with Jazzman, you should be using absolute paths, and data type casting. Proper technique now, will lead to less frustration later.
  25. You shouldn't be getting any independent cities from the database, unless they exist in the state you are requesting. This would point to a database problem. Perhaps normalization is in order, or there is an error in the input of the cities table.
×
×
  • 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.