Jump to content

hellonoko

Members
  • Posts

    213
  • Joined

  • Last visited

Posts posted by hellonoko

  1. My below code works perfectly fine for uploading images. But when I change the file type to audio/mpeg for mp3s does it does not work.

     

    Does not error either.

     

    Any ideas?

     

    Thanks for your time.

     

    <?php
    
    //include "admin_menu.php";
    
    ini_set('display_errors', 1);
    error_reporting(E_ALL);
    
    ?>
    
    
    <title>Upload Image</title><form name="form1" method="post" action="upload_image.php" enctype="multipart/form-data">
    <input name="imagefile" type="file" size="100">
    
    <input type="submit" name="Submit" value="Upload"> 
    
    
    <?php
    
    //$submit = $_POST['Submit'];
    if (empty($_FILES['imagefile']))
    	{
    		echo "<br><br>";
    		echo "Please choose a image to upload...";
    		die;
    	}
    
    if(!empty( $_POST['Submit'] ))
    {
    
    	//If the Submitbutton was pressed do:
    
    	if ($_FILES['imagefile']['type'] == "audio/mpeg")
    	{
    
    		$_FILES['imagefile']['name'] = str_replace(" ", "_", $_FILES['imagefile']['name']);
    
    		copy ($_FILES['imagefile']['tmp_name'], "music/".$_FILES['imagefile']['name']) or die ("Could not copy"); 
    
    		echo "<br><br>"; 
            	//echo "<b>Name: </b>".$_FILES['imagefile']['name'].""; 
    		//echo "<br>";
            	//echo "<b>Size: </b>".$_FILES['imagefile']['size'].""; 
            	//echo "<br>";
    		//echo "<b>Type: </b>".$_FILES['imagefile']['type'].""; 
            	//echo "<br><br>";
    		echo "<b>File Uploaded...</b>"; 
            }
    
     	else 
     	{
                echo "<br><br>";
                //echo "Could Not Copy... (".$_FILES['imagefile']['name'].")<br>";
    		echo "Could Not Copy... <br>";
    		die;
         	}
    }   
    
    echo "<br>";
    //$image_to_thumbnail = $_FILES['imagefile']['name'];
    //echo $image_to_thumbnail;
    
    //include "resize_image.php";
    
    //echo "<br>";
    //echo "<img src=http://www.artbytoni.com/images/thumbs/t_".$image_to_thumbnail." />";
    //echo "<br>";
    //echo "<img src=http://www.artbytoni.com/images/full/".$image_to_thumbnail." />";
    ?> 
    
    </form>

  2. Can anyone advise as to why my below nested query code is not working?

     

    Error is : Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\www\accordion\accordion\phpaccordion.php on line 340

    Thanks!

     

    			<?php
    
    			$query = "SELECT * FROM items";
    
    			$result = mysql_query($query);
    			$rows = mysql_num_rows($result);
    
    			for ($i=0; $i <$rows; $i++)
    			{
    				$row = mysql_fetch_array($result);
    
    				//echos each item from DB
    
    				echo		"<h1 class='accordion_toggle'>"  .$row[title]."</h1>";
    				echo		"<div style='height: auto; display: none;' class='accordion_content'>";
    				echo		"<h2>".$row[title]."</h2>";
    
    				echo		"<form id=add_note' name='add_note' method='get' action='phpaccordion.php'>";
    				echo			"<input name='action' type='hidden' value='add_note'>";
    				echo			"<input name='note_content' type='text' value='new note'>";
    				echo			"<input name='child_of' type='hidden' value=".$row[id].">";
    				echo			"<input type='image' src='images/plus.gif' alt='New Note'>";
    				echo		"</form>";
    
    				echo		"<p>".$row[content]."</p>";
    
    
    							$query2 = "SELECT * FROM main_item WHERE childof = '$row[id]'";
    
    							$result2 = mysql_query($query2);
    							$rows2 = mysql_num_rows($result2);
    
    							for ($i2=0; $i2 <$rows2; $i2++)
    							{
    								$row2 = mysql_fetch_array($result2);
    
    								echo "+".$row2[content]."";
    
    							}	
    				echo		"<form id=".$row[id]." name='delete' method='get' action='phpaccordion.php'>";
    				echo		"<input name='item_to_delete' type='hidden' value=".$row[id]." />";
    				echo		"<input type='hidden' name='action' value='delete'>";
    				echo		"<p><input type='image' SRC='images/x.gif' ALT='Delete'></p>";
    				//echo		"<input type='submit' value='Delete'>";
    				echo		"<p></P>";
    				echo		"</form>";
    				echo		"</div>";
    
    			}
    		?>

  3. I have a feeling im formatting this query string wrong and thats why it is not working.

     

    Any ideas?

     

    Thanks

     

    if ( isset($current_category) )
    {
    	$query = "SELECT count(*) FROM gallery WHERE category == ".$current_category."";
    }
    else
    {
    	$query = "SELECT count(*) FROM gallery";
    }
    
    $result = mysql_query($query);
    $query_data = mysql_fetch_row($result);
    $numrows = $query_data[0];
    
    echo $numrows;
    exit();

  4. Here is my code again. Not sure what im missing. But it is not inserting. No errors either...

     

    Thanks.

     

    <?php
    
    include 'dbconnect.php';
    
    $title = $HTTP_GET_VARS[title];
    $description = $HTTP_GET_VARS[description];
    $media = $HTTP_GET_VARS[media];
    $price = $HTTP_GET_VARS[price];
    $imagelink = $HTTP_GET_VARS[image_link];
    
    $action = $HTTP_GET_VARS[action];
    
    echo $title;
    echo "<br>";
    echo $description;
    echo "<br>";
    echo $media;
    echo "<br>";
    echo $price;
    echo "<br>";
    echo $image_link;
    echo "<br>";
    
    if ($action == "Add")
    {
    	$query = "INSERT INTO gallery (title, description, media, price, image) VALUES ($title, $description, $media, $price, '.jpg')" or die (mysql_error('Error, insert query failed'));
    	$result = mysql_query($query);
    }
    
    
    ?>
    
    <form name="add_gallery_item" method="get" action="add_gallery_item.php">
      <label>
      title:
    <input type="text" name="title" id="title">
      </label>
      <p>description:  
        <label>
        <input type="text" name="description" id="description">
        </label>
      </p>
      <p>media:
        <label>
        <input type="text" name="media" id="media">
        </label>
    </p>
      <p>price:
        <label>
        <input type="text" name="price" id="price">
        </label>
      </p>
      <p>imagelink:
        <label>
        <select name="image_link" id="image_link">
        </select>
        </label>
      </p>
      <p>
        <label>
        <input type="submit" name="action" id="add_item" value="Add">
        </label>
      </p>
    </form>
    

  5. My bellow code is causing carriage returns/<br>'s between the end of the form and the last line:

    echo $row[category];

     

    This also happens if I join the last two lines:

    echo "</form>" . echo $row[category];

     

    echo "<form id=delete_category name=delete_category method=post action=categories.php>";
    	echo "<input name=action type=submit value=Delete >"; 
    	echo "<input name=id type=hidden value=".$row[id].">";
    	echo "</form>";
    	echo $row[category];

     

    Any suggestions?

     

    Thanks.

  6. Using the below code:

     

    <?php
    
    $dictionary = fopen('US.dic','r');
    
    while (!feof($dictionary))
    {
    $lines[] = fgets($dictionary, 24004096);
    }
    
    fclose($dictionary);
    
    ?> 

     

    I receive this error:

    Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 24004097 bytes) in C:\www\dic\d.php on line 8

     

    The file is 1,185K

     

    I am using WAMP for server. Do I need to change some settings or is there a better way to load large files.

     

    Thanks

  7. I am not sure what your pointing out here Archadian?

     

    echo "<br><br>";
    		echo ""; 
            	echo "<b>Name: </b>".$_FILES['imagefile']['name'].""; 
    		echo "<br>";
            	echo "<b>Size: </b>".$_FILES['imagefile']['size'].""; 
            	echo "<br>";
    		echo "<b>Type: </b>".$_FILES['imagefile']['type'].""; 
            	echo "<br><br>";
    		echo "<b>Copy Done....</b>"; 

     

    The problem is that my code was working. And then for no reason it stopped working. When i added the code at the bottom of the page that is commented out.

     

    Jessi:

     

    I may just go for a restart and reinstall of WAMP

     

     

  8. Returns:

    Parse error: parse error, unexpected T_IF in C:\www\artbytoni.com\admin\upload_image.php on line 21

     

    After adding:

     

    <?php
    
    $submit = $_POST['submit']
    
    if(isset( $submit ))
    {
    	//If the Submitbutton was pressed do:

     

    And the error reporting.

  9. The problem is that the code was working perfectly.

     

    Then suddenly started displaying code on page.

     

    And then when I added in the full <?php tag stopped displaying but stopped working.

     

    This is on both my machine and my host.

     

    I will add the proper POST in.

  10. my php page is suddenly displaying half code half what it should display.

     

    I made a few minor changes to the code but nothing really.

     

    Running this off of WAMP. Not getting any errors.

     

    What causes this?

     

    "; echo ""; echo "Name: ".$_FILES['imagefile']['name'].""; echo "

    "; echo "Size: ".$_FILES['imagefile']['size'].""; echo "

    "; echo "Type: ".$_FILES['imagefile']['type'].""; echo "

     

    "; echo "Copy Done...."; } else { echo "

     

    "; echo "Could Not Copy, Wrong Filetype (".$_FILES['imagefile']['name'].")

    "; } } // echo "

     

    "; // $image_to_thumbnail = $_FILES['imagefile']['name']; // echo $image_to_thumbnail; //include "resize_image.php"; ?>

     

     

     

    Acctual code:

     

    <?php
    
    include "admin_menu.php";
    
    ?>
    
    
    <title>Upload Image</title><form name="form1" method="post" action="" enctype="multipart/form-data">
    <input name="imagefile" type="file" size="100">
    
    <input type="submit" name="Submit" value="Upload"> 
    
    
    <?
    
    if(isset( $Submit ))
    {
    	//If the Submitbutton was pressed do:
    
    	if ($_FILES['imagefile']['type'] == "image/jpeg")
    	{
    		copy ($_FILES['imagefile']['tmp_name'], "../images/full/".$_FILES['imagefile']['name']) or die ("Could not copy"); 
    
    		echo "<br><br>";
    		echo ""; 
            	echo "<b>Name: </b>".$_FILES['imagefile']['name'].""; 
    		echo "<br>";
            	echo "<b>Size: </b>".$_FILES['imagefile']['size'].""; 
            	echo "<br>";
    		echo "<b>Type: </b>".$_FILES['imagefile']['type'].""; 
            	echo "<br><br>";
    		echo "<b>Copy Done....</b>"; 
            }
    
     else 
     {
                echo "<br><br>";
                echo "Could Not Copy, Wrong Filetype (".$_FILES['imagefile']['name'].")<br>";
         }
    }   
    
    //	echo "<br><br>";
    //	$image_to_thumbnail = $_FILES['imagefile']['name'];
    //	echo $image_to_thumbnail;
    
    //include "resize_image.php";
    ?> 
    
    </form>

  11. I am trying to make the below image resizing code save to a different directory than the one the .php file is in.

     

    I have tried a few things but without success. Any ideas?

     

     

    
    <?php
    
    //Name you want to save your file as
    $file = 'original.jpg';
    
    $save = 't_'.$file;
    
    echo "Creating file: $save";
    
    $size = 0.45;
    
    // header('Content-type: image/jpeg') ;
    list($width, $height) = getimagesize($file) ;
    
    $modwidth = $width * $size;
    $modheight = $height * $size;
    $tn = imagecreatetruecolor($modwidth, $modheight) ;
    $image = imagecreatefromjpeg($file) ;
    
    imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
    
    // Here we are saving the .jpg, you can make this gif or png if you want
    //the file name is set above, and the quality is set to 100%
    
    imagejpeg($tn, $save, 100) ;
    ?> 

     

    Thanks,

    Ian

  12. I have two tables.

    One is a list of URLs and information about them uniqueID/url/categoryCode/description

    The other is the different categories uniqueID/name

     

    I am trying to go through my list of URLS and dispay the correstponding category name

     

    For example if i have the URL www.phpfreaks.net in my urls table and its categoryID is 4

    I want to the reference to my category table and if one of the fields id # is 4 which represents.. Web Design.

     

    I want to be able to display Web Design rather than 4.

     

    Below is my code wich I am sure is not the best way to do it and for some reason it only works for the first item.

     

    <?php
    
    include 'dbconnect.php';
    
    $query = "SELECT * FROM urls";
    $result = mysql_query($query);
    $rows = mysql_num_rows($result); 	
    
    $c_query = "SELECT * FROM categories";
    $c_result = mysql_query($c_query);
    $c_rows = mysql_num_rows($c_result); 	
    
    
    
    for ($i=0; $i <$rows; $i++)
    {
    
    	$row = mysql_fetch_array($result);
    	//echo $category_result;
    
    	//$id_from_url_info = 10;
    
    	for ($c=0; $c <$c_rows; $c++)
    	{
    		$c_row = mysql_fetch_array($c_result);
    
    		if ( $row[category] == $c_row[id])
    		{
    			echo $c_row[category];
    		}
    
    	}
    
    	echo	$row[category];
    	echo	"<br>";
    	echo	$row[url];
    	echo	"<br>";
    	echo	$row[description];
    	echo	"<br><br>";	
    
    }
    
    ?>

     

     

    Here is one example someone gave me. But that would only return a blank page.

     

    <?php
    
    include 'dbconnect.php';
    
    
    $sql="SELECT * FROM urls, categories WHERE categories.id = urls.category";
    
    $result = mysql_query($sql);
    
    while($row = mysql_fetch_array($result ))
    {
    	echo $row['category'];
    	echo "<br>";
    	echo $row['name'];
    	echo "<br>";
    	echo $row['url'];
    
    
    }
    
    ?>

     

    Any ideas?

     

    Thanks,

    Ian

  13. That looks like what I want but it only returns :::::::

    I also needed to turn then query into this:

     

    	$sql="SELECT * FROM urls, categories WHERE categories.id = urls.category";

     

    But that returned the same thing.

     

    Basically there is a list of URLS and their information in one table for example:

     

    ID: 9

    URL: www.phpfreaks.net

    category: 4

    desription: a useful site

     

    when I run through the list of entries in the URL table and i reach the CATEGORY field (4)

     

    I want to cross reference to the CATEGORIES table where the entries look like.

     

    ID: 4

    Category: coding websites

     

    So that instead of displaying 4 as the category for www.phpfreaks.net my code looks up the name for category 4 is and displays.. coding websites

     

    This way later on if i want to charge the category name i can.

     

    Does that explain it clearly?

     

    Thanks,

    Ian

     

     

  14. well i couldnt see how the first one works and i couldn't get the second one to work.

     

    here is what i am trying to do. but it only works on the first time through the loop for some reason.

     

    and im sure this is really bad way to do this.

     

    <?php
    
    include 'dbconnect.php';
    
    $query = "SELECT * FROM urls";
    $result = mysql_query($query);
    $rows = mysql_num_rows($result); 	
    
    $c_query = "SELECT * FROM categories";
    $c_result = mysql_query($c_query);
    $c_rows = mysql_num_rows($c_result); 	
    
    
    
    for ($i=0; $i <$rows; $i++)
    {
    
    	$row = mysql_fetch_array($result);
    	//echo $category_result;
    
    	//$id_from_url_info = 10;
    
    	for ($c=0; $c <$c_rows; $c++)
    	{
    		$c_row = mysql_fetch_array($c_result);
    
    		if ( $row[category] == $c_row[id])
    		{
    			echo $c_row[category];
    		}
    
    	}
    
    	echo	$row[category];
    	echo	"<br>";
    	echo	$row[url];
    	echo	"<br>";
    	echo	$row[description];
    	echo	"<br><br>";	
    
    }
    
    ?>

  15. I have two tables in my database: categories and urls

     

    categories has the fields ID and CATEGORY where ID is a unique identifier.

     

    urls has the fields ID CATEGORY URL and DESCRIPTION where ID is a unique identifier and CATEGORY is the the identifier from the categories table.

     

    I am not sure how to write a script so that when I list all the entries in URLS i can display the matching label for the category ID rather than the #.

     

    Thanks

    Ian

×
×
  • 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.