Jump to content

usadarts

Members
  • Posts

    64
  • Joined

  • Last visited

    Never

Everything posted by usadarts

  1. Hello All, A form can be filled out and NOT have a file uploaded. If no file is selected, I do NOT want to run the following: $uploaddir = '../../flyers/'; $uploadfile = $uploaddir . basename($_FILES['filename']['name']); echo '<pre>'; if (move_uploaded_file($_FILES['filename']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n"; } else { echo "Possible file upload attack!\n"; } print "</pre>"; I added the below around the code, but does not work. if (basename($_FILES['filename']['name']) != ' '){ ...... } Any suggestions?
  2. Hello All, I have a field within a database that is set as a text field. When outputting, I want to force in comma's when needed. I do not need decimal positions. Do I have to convert this to a numeric field first? How would I go about doing this without changing the field attributes in the database itself? David
  3. Excellent....I got ride of most of the errors.....I just have this..... I will figure this out.....thanks again!
  4. I changed the $target_path = "uploads/"; to calendar I also have permissions for calendar set at 777 <input name="uploadedfile" type="file"> $target_path = "calendar/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; }
  5. Thank you for the link....... What is this telling me??
  6. Good Evening All, I have a form in which I need to be able to upload a file to a specified folder (uploads) and put the file name in a database field. How is this done? Any examples for me to view? Thanks, David
  7. Excellent again.....thank you kindly. David
  8. This works AWESOME.....thank you. Another question....same as the first actually: I also ran into a time when I had to add a link to the left column of the website and ended up updating 50+ webpages. I want the left cpimn information all in 1 file and would need to only update that file. I tried what nethnet stated, but did not work.
  9. I have some code to display a random image at the top of each webpage. I will be adding more images every so often. I really to not want to have to modify 50+ pages everytime I do this. I have the following code at the top of each page: <script language="JavaScript" type="text/javascript"> var images = [ ["<img src='/pictures/banner1.jpg' alt='Banner Image 1'>", 1], ["<img src='/pictures/banner2.jpg' alt='Banner Image 2'>", 2], ["<img src='/pictures/banner3.jpg' alt='Banner Image 3'>", 3], ["<img src='/pictures/banner4.jpg' alt='Banner Image 4'>", 4], ["<img src='/pictures/banner5.jpg' alt='Banner Image 5'>", 5], ["<img src='/pictures/banner6.jpg' alt='Banner Image 6'>", 6], ["<img src='/pictures/banner7.jpg' alt='Banner Image 7'>", 7], ] ;var randomValue = Math.random() * 7;var imageId = -1; for (i = 0; i < images.length; i++) { if (randomValue <= images[i][1]) { imageId = i; break; } } document.write(images[imageId][0]); </script> Is it possible to create a seperate page with just this information and have some kind of code to call this file? This way, in the future, I would only have to change 1 file instead of 50+
  10. I have a website that has about 50+ pages to it. I need to add a link to the left column of all the webpages. Does CSS help in a way to create a CSS file with the links and somehow attach it to each page. That way, in the future, if I need to add another link, all I would have to do is change the CSS file? Is this what CSS can be used for?
  11. I must be missing something, not sure what you mean.....I already have this code in there..... or die ('I cannot connect to the database because: ' . mysql_error()); on all relative queries
  12. Not sure if it has something to do with the RRN that i pass through, but when I modify the information, it does not change the database. index.php <html> <head> <script type="text/javascript"> <!-- function articleHandler(form){ var URL = "http://www.websites.com/cpanel/updatearticles?rrn="+articles.rrn.value; window.location.href = URL; } //--> </SCRIPT> <style type="text/css"> <!-- .style2 {color: #808080} --> </style> </head> <body> <center> <table width="75%" valign="top"> <tr> <td><?php $dbh=mysql_connect ("localhost", "xxxxxxxx", "xxxxxxxx") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("xxxxxxxx"); $query = "SELECT * FROM `articles` ORDER BY `date` DESC"; $result = mysql_query($query,$dbh) or die(mysql_error()); if (result){ echo "<center><form name=\"articles\">"; echo "<select name=\"rrn\" size=1 onChange=\"javascript:articleHandler()\">"; echo "<option value=''>Select Article To Update</option>"; while($row = mysql_fetch_array($result)) { echo "<option value='{$row['rrn']}'>{$row['date']} - {$row['title']}</option>"; } echo '</select></form></center>'; } ?> <?php $dbh=mysql_connect ("localhost", "xxxxxxxxx", "xxxxxxxx") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("xxxxxxxx"); $rrn = $_GET['rrn']; $queryr = "SELECT * FROM `articles` WHERE `rrn` = '$rrn'"; $resultr = mysql_query($queryr,$dbh) or die(mysql_error()); while($row = mysql_fetch_array($resultr)) { echo "<center><font size=+2>Add News Articles</font>"; echo "<form action=\"post.php?$rrn\" method=\"post\">"; echo "<textarea name=\"title\" cols=\"50\" rows=\"1\">"; echo $row['title']; echo "</textarea><br>"; echo "<textarea name=\"author\" cols=\"50\" rows=\"1\">"; echo $row['author']; echo "</textarea><br>"; echo "<textarea name=\"date\" cols=\"20\" rows=\"1\">"; echo $row['date']; echo "</textarea><br>"; echo "<textarea name=\"newcomments\" cols=\"100\" rows=\"50\">"; echo $row['info']; echo "</textarea><br>"; echo "<input type=\"submit\">"; echo "</form></center>"; } ?> </td> </tr> </table> </center> </body> </html> post.php code <?php $title = $_POST['title']; $author = $_POST['author']; $date = $_POST['date']; $info = $_POST['info']; $str = $info; $order = array("\r\n", "\n", "\r"); $replace = '<br />'; $newstr = str_replace($order, $replace, $str); $rrn = $_GET['rrn']; str_replace("/r/n","<br><br>",'$info'); $dbh=mysql_connect ("localhost", "xxxxxxxxxxx", "xxxxxxxx") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("xxxxxxxxx"); $insert = "UPDATE article SET title='$title', author='$author', date='$date', info='$newstr' WHERE rrn=$rrn"; $results = mysql_query($insert); echo "<center>Article Modified - <a href=\"../index.php\"><font size=\"4\">BACK TO CONTROL PANEL</font></A></center>"; echo ""; ?>
  13. Works good, thank you. However 1 small problem...... When the form loads, only the first word of the field is loading..... Example....within the database field is "Every Good Boy Does Fine" When I load the "title" field to the text field, "Every" is the only thing that appears. Any ideas???? echo "Title:<input type=\"text\" name=\"title\" size=\"50\" value={$row['title']}><br>";
  14. I need to load information from a database to a form to be modified. Below is the code to load the field title into a text field. Not working......what is wrong with the code below??? echo "Title:<input type=\"text\" name=\"title\" size=\"50\" value=$row['title']"><br>"; David
  15. Duh.....thanks chocopi for the help. I guess this teaches me to look over code more carefully before bothering you guys.
  16. Not quit there yet. Have a form that loads database information which could then be modified to update the database with the new information. The date changes fine, but the newcomments is not being past to the posthp.php. ModifyHP.php <?php $dbh=mysql_connect ("xxxxxxxx", "xxxxxxxx_xxxxxxxx", "xxxxxxxx") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("xxxxxxxx_xxxxxxxx"); $query = "SELECT * FROM `homepage`"; $result = mysql_query($query,$dbh) or die(mysql_error()); while($row = mysql_fetch_array($result)) { echo "<font size=+2>Modify Home Page</font>"; echo "<form action=\"posthp.php\">"; echo "<textarea name=\"newcomments\" cols=\"100\" rows=\"40\">"; echo $row['comments']; echo "</textarea>"; echo "<br>"; echo "<input type=\"submit\">"; echo "</form>"; } ?> posthp.php <?php $newcomments = $_POST['newcomments']; $date = date('ymd'); $dbh=mysql_connect ("xxxxxxxx", "xxxxxxxx_xxxxxxxx", "xxxxxxxx") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("xxxxxxxx_xxxxxxxx"); $sql = "UPDATE homepage SET date='$date', comments='$newcomments' WHERE rrn='1'"; $result = mysql_query($sql) or die('I cannot update database: "' . mysql_error()); echo "<center>Home Page Updated - <a href=\"index.php\"><font size=\"4\">BACK TO CONTROL PANEL</font></A></center>"; echo ""; ?>
  17. Receiving the following error: $sql = "UPDATE `homepage` SET `date` = $date, `comments` = $newcomments WHERE `rrn` =1";
  18. Now the POSTHP is not updating the database. This is all new to me, the update via webpage. Here is the POST code <?php $newcomments = $_POST['newcomments']; $date = date('ymd'); $dbh=mysql_connect ("xxxxxxxx", "xxxxxxxx_xxxxxxxx", "xxxxxxxx") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("xxxxxxxx_xxxxxxxx"); $update = "UPDATE `homepage` SET `date` = $date, `comments` = $newcomments WHERE `rrn` = 1"; $results = mysql_query($update); ?>
  19. Missed that. Fixed that line and a few other things. The page now loads, but nothing appears in the textarea. <?php $dbh=mysql_connect ("xxxxxxxx", "xxxxxxxx_xxxxxxxx", "xxxxxxxx") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("xxxxxxxx_xxxxxxxx"); $query = "SELECT * FROM `homepage`"; $result = mysql_query($query,$dbh) or die(mysql_error()); $comments = $_GET['comments']; while($row = mysql_fetch_array($result)) { echo "<form action=\"posthp.php\">"; echo "<textarea name=\"newcomments\" cols=\"100\" rows=\"20\">"; echo "$comments"; echo "</textarea>"; echo "<br>"; echo "<input type=\"submit\">"; echo "</form>"; } ?>
  20. This is what I have now and receiving the following error: <?php $dbh=mysql_connect ("xxxxxxxx", "xxxxxxxx_xxxxxxxx", "xxxxxxxx") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("xxxxxxxx_xxxxxxxx"); $query = "SELECT * FROM `homepage`"; $result = mysql_query($query,$dbh) or die(mysql_error()); $comments = $_GET['comments']; while($row = mysql_fetch_array($result)) { echo "<form action=\"posthp.php\">"; echo "<textarea name=\"newcomments\" cols=\"100\" rows=\"20\">"; echo "$comments" echo "</textarea>"; echo "<input type="submit" />"; echo "</form>"; } ?>
  21. I have a form in which I want to load information from a database within a textarea. I have the following code: <?php $dbh=mysql_connect ("localhost", "xxxxxxx_xxxxxxx", "xxxxxxx") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("xxxxxxx_xxxxxxx"); $queryr = "SELECT * FROM `page`"; $date = $_GET['date']; $comments = $_GET['comments']; ?> <form action="posthp.php" method="POST"> <textarea name="newcomments" cols="100" rows="20"><?php echo $comments; ?></textarea> <br> <input type="submit" name="Submit" value="Submit Form"> </form> Not working.....
  22. Not sure if I am explaining myself correctly. Here is the code from Index.php <?php $dbh=mysql_connect ("xxxxxxxx", "xxxxxxx_xxxxxxx", "xxxxxxx") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("xxxxxxx_xxxxxxx"); $rank = 0; $regionk = $_GET['region']; $assock = $_GET['assoc']; if($regionk != '' && $regionk != 'ALL') { $queryr = "SELECT * FROM `mens2007` WHERE `region` = '$regionk' and `regpts` > 0 ORDER BY `regpts` DESC"; $resultr = mysql_query($queryr,$dbh) or die(mysql_error()); } else if($assock != '' && $assock != 'ALL') { $queryr = "SELECT * FROM `mens2007` WHERE `assoc` = '$assock' and `natpts` > 0 ORDER BY `natpts` DESC"; $resultr = mysql_query($queryr,$dbh) or die(mysql_error()); } else{ $queryr = "SELECT * FROM `mens2007` WHERE `natpts` > 0 ORDER BY `natpts` DESC"; $resultr = mysql_query($queryr,$dbh) or die(mysql_error()); } $resultr = mysql_query($queryr,$dbh) or die(mysql_error()); $results_header =<<<HEADER <table cellspacing='1' align="center"> <tr> <td valign=bottom><b>Ranking</b></td> <td> </td> <td valign=bottom><b>Player</b></td> <td> </td> <td valign=bottom><b>Region</b></td> <td> </td> <td valign=bottom><b>Affiliation</b></td> <td> </td> <td align=right valign=bottom><b>Regional<br>Points</b></td> <td> </td> <td align=right valign=bottom><b>National<br>Points</b></td> HEADER; while($row = mysql_fetch_array($resultr)) { $rank = $rank + 1; $name = $row['firstname']." ".$row['lastname']; $region = $row['region']; $assoc = $row['assoc']; $regpts = $row['regpts']; $natpts = $row['natpts']; $results_details .=<<<DETAILS <tr> <td><font size="3">$rank</font></td> <td> </td> <td><font size="3"><a href="javascript:poptastic2('http://www.adodarts.com/rankings/mens2007new/individual.php?playername=$name');" style="text-decoration:none; color:black; font-size:normal;" onMouseOver="this.style.fontStyle='italic'; this.style.color='black'" onMouseOut="this.style.fontStyle='normal'; this.style.color='black'">$name</a></font></td> <td> </td> <td><font size="3">$region</font></td> <td> </td> <td><font size="3">$assoc</font></td> <td> </td> <td align=right><font size="3">$regpts</font></td> <td> </td> <td align=right><font size="3">$natpts</font></td> </tr> DETAILS; } $results_footer ="</table>"; echo $results_header; echo $results_details; echo $results_footer; ?> When clicking the name link in the above code, the popup window does appear but there is no information. I know the code in the individual.php is correct, because if I change $name to John Doe within the $query, it works. Here is the individual.php code <?php $dbh=mysql_connect ("xxxxxxx", "xxxxxxx_xxxxxxx", "xxxxxx") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("xxxxxx_xxxxxx"); $query = "SELECT * FROM `2007results` WHERE `playername` = '$name' LIMIT 0, 999"; $result = mysql_query($query,$dbh) or die(mysql_error()); $results_header =<<<HEADER $name <table cellspacing='1' align="center"> HEADER; while($row = mysql_fetch_array($result)) { $playername = $row['playername']; $tournament = $row['tournament']; $event = $row['event']; $placed = $row['placed'] ; $results_details .=<<<DETAILS <tr> <td>$tournament</td> <td>$event</td> <td>$placed</td> </td> </tr> DETAILS; } $results_footer ="</table>"; echo $results_header; echo $results_details; echo $results_footer; ?> Does it have something to do with a space within $name (ex: Joe Smith)
×
×
  • 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.