Jump to content

opel

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

opel's Achievements

Member

Member (2/5)

0

Reputation

  1. I have been working on a file upload script that will allow me to upload word documents, mp3's and PDF's into my site. I have been working on the following script but my validation stataments are causing the upload procedure to fail, any help or advise would be appreciated. <?php require_once('includes/inc_functions.php'); $target = "../files/"; if(isset($_POST['Submit'])) { //reads the name of the file the user submitted for uploading $image=$_FILES['file']['name']; // if it is not empty if ($image) { // get the original name of the file from the clients machine $filename = stripslashes($_FILES['file']['name']); // get the extension of the file in a lower case format $extension = getExtension($filename); $extension = strtolower($extension); // if it is not a known extension, we will suppose it is an error, print an error message //and will not upload the file, otherwise we continue if (($extension != "doc") && ($extension != "jpg") && ($extension != "pdf")) { echo '<h1>Unknown extension!</h1>'; $errors=1; } else { } } //If no errors registred, print the success message and show the thumbnail image created if(isset($_POST['Submit']) && !$errors) { ?> <link href="css/admin.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> function sendImg(img) { opener.document.add.image.value = img; window.close(); } </script> <h1>Thumbnail created Successfully!</h1> <img class="hand" onClick="sendImg('<?= $image_name ?>');" src="<?= $thumb_name ?>" alt="Thumnail"> <? } else { ?> <img src="../People/JunF.jpg" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <form name="newad" method="post" enctype="multipart/form-data" action=""> <table width="300" align="center" id="uploadImg"> <tr> <td colspan="2"><h1>Upload Files</h1></td> </tr> <tr> <td colspan="2"> <p align="center" style="font-size:10px;">You can upload files with the <strong>.MP3</strong> extension using this form. Please make sure that all your MP3's have been ID3 tags or they will not display in the flash player.</p></td> </tr> <tr> <td>Please choose a file :</td> <td><input name="file" type="file" /></td> </tr> <tr> <td colspan="2"><div align="center"> <input type="submit" value="Upload File" name="Submit" /> </div></td> </tr> <tr> <td colspan="2"><div align="center"><a href="javascript:window.close()" title="Close Window">Close Window</a></div></td> </tr> </table> </form> </div> </body> </html><? } // end else ?> If you go to this page, http://www.recommendedcosmetics.com/admin/files2.php you will see I am getting an error with unexpected $end.
  2. Is it possible to grab textual content from an external site and display it on your own site? I look after a site from my club night and we use another club community site that has users sign up that they will be attending. I simply want to grab that snippet of textual information from the community site and display it on my own site. I had a tutorial on this a year or so ago but can't find it and not sure what the technical term is I should be searching or googling for. tHanks
  3. I only know enough PHP/MySQL to edit and chop up code. I would struggle to make a forum.  :(
  4. I am trying to find a lightweight message board system for a sites that have under 300 forum members. I have used Invison and things in the past but they are pretty hard to integrate into a existing site layout. CAn anyone reccomend a reliable bulletin board system that can be easily skinned, I am looking for something like BBpress but allows uses to post image links in their message body. Cheers
  5. Still trying to learn some PHP and getting stuck again. I am trying to create a switch statement that looks at a URL and displays some HTML formated content. Below is what I have so far but I'm getting stuck on how to identify the URL as I have pages that start with the same word e.g news-list.php, news-detail.php and I would like the condition content to display for anything that starts "news". [code]<?php switch (condition) {   case "header("Location: ../central/news");" : <p>This will be my content for the news section</p>   break; case "header("Location: ../central/links");" : <p>This will be my content for the links section</p>   break;   default :   <p>This will be my default message</p>   break;   } ?>[/code] Thanks for any help or tips you can offer me.
  6. I have been working on an admin system and using links and link categories as the basis for learning PHP and SQL. I've run into a problem with the links category delete pages. What I want to do is filter out only categories that have no links assosciate with a category. Only these linkless categories can be deleted. The information for the links and categories are in 2 separate tables. The SQL statement I have at the moment works perfectly for filtering out the categories that have no links assosciate with it. However as the statement is set up it displays a NULL value for the category_id therefor I have no value to pass to the delete confirm page and script. This is the SQL statement and PHP Script I am working on at the moment. Can anyone tell me how I can get this script to work and pass out the correct category ID's please. [b]SQL [/b] [code]<?php mysql_select_db($database_CMconn, $CMconn); $query_rsLinkCatDelete = "SELECT DISTINCT categories.category_id, categories.category_name, categories.category_desc, tbl_links.category_id FROM categories LEFT JOIN tbl_links ON (categories.category_id = tbl_links.category_id)"; $rsLinkCatDelete = mysql_query($query_rsLinkCatDelete, $CMconn) or die(mysql_error()); $row_rsLinkCatDelete = mysql_fetch_assoc($rsLinkCatDelete); $totalRows_rsLinkCatDelete = mysql_num_rows($rsLinkCatDelete); ?>[/code] [b]PHP[/b] [code]  <table> <tr > <th>Category</th> <th>Delete </th> </tr> <?php do { ?>   <tr>     <?php if ($row_rsLinkCatDelete['category_id'] == 0) { // Show if recordset empty ?>       <td class="item"><?php echo $row_rsLinkCatDelete['category_name']; ?></td>       <td class="button"><a title="Delete This Item" href="linkCat_delete_detail.php?ID=<?php echo $row_rsLinkCatDelete['category_id']; ?>">Delete</a></td>       <?php } // Show if recordset empty ?></tr>   <?php } while ($row_rsLinkCatDelete = mysql_fetch_assoc($rsLinkCatDelete)); ?> </table>[/code]
  7. thanks for your help  ;D
  8. yes exactly, I am using Dreamweaver and it only lets you redirect a page. I would like to echo a success statement based on the update being true. Sorry never replied sooner never got a notifcation from the forum to my email.
  9. I have set up a page redirect from an insert from which has "addpage.php?update=true" I am trying to create an if statement to put on the addpage.php that will echo a statement to let users know the transaction worked. I have tried to start the statement but it doesnt seem to work, can anyone help? [code]<?php if header("Location: addlink.php?update=true") echo "Your article has been submitted"; ?>[/code]
  10. my problem seems to be that I have not matched a variable to the database set up but I cant see where I have gone wrong?
  11. I have attached a screen grab and pasted copy of the code. The error appears when I click the submit form and the update script is activated. [code]Notice: Undefined index: inpID in /Users/andrewcetnarskyj/Sites/GunkAdmin/central/updatescripts/updatelinks.php on line 4 Notice: Undefined index: inpTitle in /Users/andrewcetnarskyj/Sites/GunkAdmin/central/updatescripts/updatelinks.php on line 5 Notice: Undefined index: inpDescription in /Users/andrewcetnarskyj/Sites/GunkAdmin/central/updatescripts/updatelinks.php on line 6 Notice: Undefined index: inpLinkUrl in /Users/andrewcetnarskyj/Sites/GunkAdmin/central/updatescripts/updatelinks.php on line 7 Notice: Undefined index: inpCat in /Users/andrewcetnarskyj/Sites/GunkAdmin/central/updatescripts/updatelinks.php on line 8 Notice: Undefined index: inpDisplay in /Users/andrewcetnarskyj/Sites/GunkAdmin/central/updatescripts/updatelinks.php on line 9 You have successfully edited a link, click here to edit another link[/code] [attachment deleted by admin]
  12. I have been trying to my update script to post the changes to the Database, but it just is not happening  ??? I've read through every book and tutorial I have but can't see where I am going wrong. Could anyone who thinks they can help have a look please. The error I am getting says that I have an undefined index. I have attached the file and update script that I'm using. [b]Update form[/b] [code]<?php $id=$_GET['id']; mysql_select_db($dbname, $conn); $query="SELECT * FROM tbl_links, categories WHERE tbl_links.category_id = categories.category_id AND link_id=$id"; $result= mysql_query($query) or die("error querying database"); $num= mysql_num_rows($result); mysql_close(); $i=0; while ($i < $num) {$linkID=mysql_result($result,$i,"link_id"); $categoryID=mysql_result($result,$i,"category_id"); $linkTitle=mysql_result($result,$i,"link_title"); $linkDescription=mysql_result($result,$i,"link_desc"); $linkURL=mysql_result($result,$i,"link_url"); $linkDisplay=mysql_result($result,$i,"link_display"); ?> <form action="updatescripts/updatelinks.php"> <input type="hidden" name="inpID" value="<? echo "$linkID"; ?>"> <table cellpadding="5"> <tr> <th width="120">Field Name</th> <th width="378">Field Inputs</th> </tr> <tr> <td width="120"><div align="right"><strong>Category :</strong></div></td> <td> <select name="inpCat">   <?php mysql_select_db($dbname, $conn); $query_rsLinks = "SELECT * FROM categories ORDER BY category_name ASC"; $rsLinks = mysql_query($query_rsLinks, $conn) or die(mysql_error()); $row_rsLinks = mysql_fetch_assoc($rsLinks); $totalRows_rsLinks = mysql_num_rows($rsLinks);   do {  ?>   <option value="<?php echo $row_rsLinks['category_id']?>"><?php echo $row_rsLinks['category_name']?></option>   <?php } while ($row_rsLinks = mysql_fetch_assoc($rsLinks));   $rows = mysql_num_rows($rsLinks);   if($rows > 0) {       mysql_data_seek($rsLinks, 0);   $row_rsLinks = mysql_fetch_assoc($rsLinks);   } include ('../connections/dbclose.php'); ?> </select> </td> </tr> <tr> <td width="120"><div align="right"><strong>Title :</strong></div></td> <td><input type="text" name="inpTitle" value="<? echo $linkTitle ?>" class="inputbox" size="72" /></td> </tr> <tr> <td width="120"><div align="right"><strong>Description :</strong></div></td> <td><input type="text" name="inpDescription" value="<? echo $linkDescription ?>" class="inputbox" size="72" /></td> </tr> <tr> <td colspan="2">&nbsp;</td> </tr> <tr> <td width="120"><div align="right"><strong>Link URL <em>('http;//' not required)</em> :</strong></div></td> <td><input type="text" name="inpLinkUrl" value="<? echo $linkURL ?>" class="inputbox" size="72" /></td> </tr> <tr> <td colspan="2">&nbsp;</td> </tr> <tr> <td width="120"><div align="right"><strong>Display Link :</strong></div></td> <td><input name="inpDisplay" type="checkbox" value="<? echo $linkDisplay ?>" class="inputbox" checked="CHECKED"/></td> </tr> <tr> <td colspan="2">&nbsp;</td> </tr> <tr> <td width="120"><div align="right"><strong>Click to submit :</strong></div></td> <td><input type="submit" value="Add This Link" name="add" id="add"/></td> </tr> </table> </form> <? ++$i; } ?> [/code] [b]Update Post Script[/b] [code]<? include ('../../connections/dbconn.php'); $linkID = $_POST['inpID']; $linkTitle = $_POST['inpTitle']; $linkDesc = $_POST['inpDescription']; $linkUrl = $_POST['inpLinkUrl']; $linkCategory = $_POST['inpCat']; $linkDisplay = $_POST['inpDisplay']; $query = "UPDATE tbl_links SET link_title='$linkTitle', link_desc='$linkDesc', link_url='$linkUrl', category_id='$linkCategory', link_display='$linkDisplay' WHERE link_id='$linkID'"; mysql_select_db($dbname, $conn) or die( "Unable to select database"); mysql_query($query); echo "<p class='message'>You have successfully edited a link, click here to <a href='edit_link.php'>edit another link</a></p>"; mysql_close(); ?>[/code]
  13. fixed it there were some errors with my SQL [code]<?php $id=$_GET['id']; mysql_select_db($dbname, $conn); $query="SELECT * FROM tbl_links, categories WHERE tbl_links.category_id = categories.category_id AND link_id=$id"; $result= mysql_query($query) or die("error querying database"); $num= mysql_num_rows($result); mysql_close(); $i=0; while ($i < $num) {$linkID=mysql_result($result,$i,"link_id"); $categoryID=mysql_result($result,$i,"category_id"); $linkTitle=mysql_result($result,$i,"link_title"); $linkDescription=mysql_result($result,$i,"link_desc"); $linkURL=mysql_result($result,$i,"link_url"); $linkDisplay=mysql_result($result,$i,"link_display"); ?> <form action="updatescripts/updatelinks.php"> <input type="hidden" name="ud_id" value="<? echo "$linkID"; ?>"> <table cellpadding="5"> <tr> <th width="120">Field Name</th> <th width="378">Field Inputs</th> </tr> <tr> <td width="120"><div align="right"><strong>Category :</strong></div></td> <td> <select name="inpCat">   <?php mysql_select_db($dbname, $conn); $query_rsLinks = "SELECT * FROM categories ORDER BY category_name ASC"; $rsLinks = mysql_query($query_rsLinks, $conn) or die(mysql_error()); $row_rsLinks = mysql_fetch_assoc($rsLinks); $totalRows_rsLinks = mysql_num_rows($rsLinks);   do {  ?>   <option value="<?php echo $row_rsLinks['category_id']?>"><?php echo $row_rsLinks['category_name']?></option>   <?php } while ($row_rsLinks = mysql_fetch_assoc($rsLinks));   $rows = mysql_num_rows($rsLinks);   if($rows > 0) {       mysql_data_seek($rsLinks, 0);   $row_rsLinks = mysql_fetch_assoc($rsLinks);   } include ('../connections/dbclose.php'); ?> </select> </td> </tr> <tr> <td width="120"><div align="right"><strong>Title :</strong></div></td> <td><input type="text" name="inpTitle" value="<? echo $linkTitle ?>" class="inputbox" size="72" /></td> </tr> <tr> <td width="120"><div align="right"><strong>Description :</strong></div></td> <td><input type="text" name="inpDescription" value="<? echo $linkDescription ?>" class="inputbox" size="72" /></td> </tr> <tr> <td colspan="2">&nbsp;</td> </tr> <tr> <td width="120"><div align="right"><strong>Link URL <em>('http;//' not required)</em> :</strong></div></td> <td><input type="text" name="inpLinkUrl" value="<? echo $linkURL ?>" class="inputbox" size="72" /></td> </tr> <tr> <td colspan="2">&nbsp;</td> </tr> <tr> <td width="120"><div align="right"><strong>Display Link :</strong></div></td> <td><input name="inpDisplay" type="checkbox" value="<? echo $linkDisplay ?>" class="inputbox" checked="CHECKED"/></td> </tr> <tr> <td colspan="2">&nbsp;</td> </tr> <tr> <td width="120"><div align="right"><strong>Click to submit :</strong></div></td> <td><input type="submit" value="Add This Link" name="add" id="add"/></td> </tr> </table> </form> <? ++$i; } ?>[/code]
  14. I altered my PHP code as I realisied that my id wasn't being passed properly but no I am getting Error querying Database. [code]<?php $id=$_GET['id']; mysql_select_db($dbname, $conn); $query=" SELECT * FROM tbl_links WHERE id=$id"; $result=mysql_query($query) or die("error querying database"); $num=mysql_num_rows($result); mysql_close(); $i=0; while ($i < $num) {$linkID=mysql_result($result,$i,"link_id"); $categoryID=mysql_result($result,$i,"category_id"); $linkTitle=mysql_result($result,$i,"link_title"); $linkDescription=mysql_result($result,$i,"link_desc"); $linkURL=mysql_result($result,$i,"link_url"); $linkDisplay=mysql_result($result,$i,"link_display"); ?>[/code]
  15. I am trying to get my update script to work but for some reason I am getting an error when I try to pull the page content based on the id. The error say that there is an undefined index but I have checked my table names and everything is fine? ??? [code]<?php $id=$_GET['link_id']; mysql_select_db($dbname, $conn); $query=" SELECT * FROM tbl_links WHERE ID='$id'"; $result=mysql_query($query) or die("error querying database"); $num=mysql_num_rows($result); mysql_close(); $i=0; while ($i < $num) {$linkID=mysql_result($result,$i,"link_id"); $categoryID=mysql_result($result,$i,"category_id"); $linkTitle=mysql_result($result,$i,"link_title"); $linkDescription=mysql_result($result,$i,"link_desc"); $linkURL=mysql_result($result,$i,"link_url"); $linkDisplay=mysql_result($result,$i,"link_display"); ?> <form action="updatescripts/updatelinks.php"> <input type="hidden" name="ud_id" value="<? echo "$linkID"; ?>"> <table cellpadding="5"> <tr> <th width="120">Field Name</th> <th width="378">Field Inputs</th> </tr> <tr> <td width="120"><div align="right"><strong>Category :</strong></div></td> <td> <select name="inpCat">   <?php mysql_select_db($dbname, $conn); $query_rsLinks = "SELECT * FROM categories ORDER BY category_name ASC"; $rsLinks = mysql_query($query_rsLinks, $conn) or die(mysql_error()); $row_rsLinks = mysql_fetch_assoc($rsLinks); $totalRows_rsLinks = mysql_num_rows($rsLinks);   do {  ?>   <option value="<?php echo $row_rsLinks['category_id']?>"><?php echo $row_rsLinks['category_name']?></option>   <?php } while ($row_rsLinks = mysql_fetch_assoc($rsLinks));   $rows = mysql_num_rows($rsLinks);   if($rows > 0) {       mysql_data_seek($rsLinks, 0);   $row_rsLinks = mysql_fetch_assoc($rsLinks);   } include ('../connections/dbclose.php'); ?> </select> </td> </tr> <tr> <td width="120"><div align="right"><strong>Title :</strong></div></td> <td><input type="text" name="inpTitle" value="<? echo $linkTitle ?>" class="inputbox" size="72" /></td> </tr> <tr> <td width="120"><div align="right"><strong>Description :</strong></div></td> <td><input type="text" name="inpDescription" value="<? echo $linkDescription ?>" class="inputbox" size="72" /></td> </tr> <tr> <td colspan="2">&nbsp;</td> </tr> <tr> <td width="120"><div align="right"><strong>Link URL <em>('http;//' not required)</em> :</strong></div></td> <td><input type="text" name="inpLinkUrl" value="<? echo $linkURL ?>" class="inputbox" size="72" /></td> </tr> <tr> <td colspan="2">&nbsp;</td> </tr> <tr> <td width="120"><div align="right"><strong>Display Link :</strong></div></td> <td><input name="inpDisplay" type="checkbox" value="<? echo $linkDisplay ?>" class="inputbox" checked="CHECKED"/></td> </tr> <tr> <td colspan="2">&nbsp;</td> </tr> <tr> <td width="120"><div align="right"><strong>Click to submit :</strong></div></td> <td><input type="submit" value="Add This Link" name="add" id="add"/></td> </tr> </table> </form> <? ++$i; } ?>[/code]
×
×
  • 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.