c_shelswell
Members-
Posts
275 -
Joined
-
Last visited
Never
Everything posted by c_shelswell
-
Whats the best way to do this? : I need to make a page that will allow someone to upload a large file to a server. I need to use ftp to do this as the filesize will be much larger than my hosts php setting will allow. I'm trying to use this: [code]<form enctype="multipart/form-data" method="post" action="include/my_ftp.php"> <input name="file" type="file" size="40"> <input type="submit" name="upload" value="Upload">[/code] to browse and select a file to upload the thing is the method to upload on my other page requires the full file path [code]if (isset($_POST['upload'])) { $file = ($_FILES['file']['name']); putFile($file); } } } function putFile($file) { $conn = DoConn(); if (ftp_put($conn, "/www/images/name.gif", $file, FTP_BINARY)) { echo 'yes'; } else { echo 'nope'; } }[/code] as far as i can find out the $_FILES variable won't ever get the full file name. Is there a way of doing this? or even a better way of trying to do what i'm after. Thanks
-
Hi does anyone know how i might remove the file path from a string. I'm guessing i use eregi or something like that just can't figure out how to do it. say i have [b]"E:\Documents and Settings\The King\Desktop\annaalien.jpg"[/b] and i want to end up with just [b]"annaalien.jpg"[/b] the file path will be different each time. Many thanks
-
Hi does anyone know why i might be having a problem here. I've got a bit of php the brings up my ftp server list as link so i can download a file. it's working fine at the root level and when i click a file it will download it no probs to my c:/ drive. However when i go to the www. section of my ftp it won't download it. Here's my code: [code]function getFile() { $conn = DoConn(); $currDir =""; if (isset($_GET['currFile'])) { $currFile = $_GET['currFile']; if(ftp_get($conn, "c:/".$currFile, $currFile, FTP_BINARY)) [color=red]<< line 105[/color] { echo 'the file <b>'.$currFile.'</b> was succesfully downloaded.'; } else { echo 'the file <b>'.$currFile.'</b> could not be downloaded.'; } } }[/code] this is the error i get Warning: ftp_get() [function.ftp-get]: Can't open playlist.xml: No such file or directory in E:\Program Files\Apache Software Foundation\Apache2.2\htdocs\admin\my_ftp.php on line 105 i've marked line 105 cheers
-
you can't start a session with all that html at the top of the page. you would need to put <?php session_start(); ?> all the html stuff then back to <?php you code here
-
Hi i was wondering if someone might be able to help me with some CSS fomatting basically on a test site i'm making [url=http://www.oliperphonic.com]www.oliperphonic.com[/url] in the top menu bar i've got some link buttons on the right hand side and an item/price bit on the left. However when i start to reduced the size of the window the too start to clash. Can't quite figure out how to stop it. my css is [url]http://www.oliperphonic.com/require/sm_styles.css[/ulr] i'm sure lots of it's not great i'm just getting in to css. thanks for any help
-
Hi i'm really desperate to find a tutorial for a flash mp3 player that loads a track by clicking on a HTML link. I'm going to have loads of tracks and i need them to load to a flash player from a regular website. Does anyone have any ideas where i might be able to find out how to do this? Many thanks
-
refresh items on a page without reloading it? can it be done?
c_shelswell replied to c_shelswell's topic in PHP Coding Help
actually would a simple link directing back to the main page with a $_GET on it be the best? I know it's reloading but can't think of a better way to do it. -
this might help you it's a really good tutorial for a login page with remember fetures and the ability to set user levels. I've got it working with my site to allow people of varying degrees different access around my site. [url=http://www.evolt.org/article/PHP_Login_System_with_Admin_Features/17/60384/index.html]http://www.evolt.org/article/PHP_Login_System_with_Admin_Features/17/60384/index.html[/url]
-
Hi i'm looking to make a front page with items for sale. I'm intending on having 1 large "featured" bundle at the top then smaller pics and bundles underneath but with a "more info" button on them that when pressed will reload the featured bundle at the top of the page a replace it with the item clicked. I'm trying to do this all from the main page without frames. Is there a way to do this or even a site that anyone knows of that i could take a look at to do some research on it. Many thanks
-
Is there a better way to write this function?
c_shelswell replied to c_shelswell's topic in PHP Coding Help
excellent thanks very much i thought there must be a way of getting rid of the $i counters it didn't look very elegant. thanks again. -
I was just wondering if there was a better way to write this. My query should return a few results and i'm adding it to an array in the foreach but i'm having to use an $i++; to add the next item to the array. The code works and returns what i'm after just wondering if there's a slightly better way. thanks [code]function get_media_titles($mediaId) { $conn = db_connect(); $i=0; foreach ($mediaId as $key => $id) { $query="select media.title from media left join purchases using(media_id) where purchases.media_id='$id' limit 1"; $result= mysql_query($query); if (!$result) return false; $num_rows = @mysql_num_rows($result); if ($num_rows == 0) return false; if($result) { $titles[$i] = mysql_result($result, 0, 'title'); } $i++; } return $titles; }[/code]
-
Simple query in Mysql that i can't seem to get right! Joining tables
c_shelswell replied to c_shelswell's topic in MySQL Help
It seems if i don't have the "distinct" i get as many titles as there are purchases of that title in the purchases table. I'm only looking to get the name of it once. -
Simple query in Mysql that i can't seem to get right! Joining tables
c_shelswell replied to c_shelswell's topic in MySQL Help
Ooops managed to get it. I used this. [code]select distinct media.title, media.picture from media left join purchases on purchases.media_id=media.media_id where purchases.media_id=4;[/code] perhaps there's a better way? -
Hi i'm sure this has a very simple answer. I'm looking to query mysql joining two tables. basically i have: Media media_id - title - picture and Purchases media_id - quantity all im looking to do is query mysql for the title of the media_id i give to it from the purchases table. I'm getting some results but i provides me with the title as many times as the media_id appears in purchases i only need it once. Here's my code. [code]select media.title, media.picture from media left join purchases using (media_id) where purchases.media_id='4';[/code] i'm pretty new to mysql and this is really just a guess if anyone could help that would be great. Thanks very much
-
Very Basic Connection Question (very newbie)
c_shelswell replied to dlyles's topic in PHP Coding Help
try omiting the password when i log on to mysql at home its not set up to have a password for the root user. I was getting the same error until i just logged on as root. -
thanks very much for the replies. in the end i did this as i realised i need to have all the months inbetween the first and the last one regardless of them actually being in the initial array. for ($fm=$firstMonth; $fm < $lastMonth+1; $fm++) { $monthArray[$fm] = $fm; $days_in_month[$fm] = cal_days_in_month(CAL_GREGORIAN, $monthArray[$fm], $currYear); } Thanks again. Just one quick thing though whats the code for getting those nice formatted text boxes for dropping code in? Cheers
-
Hi i'm trying to find out each month in an array of dates I might have about 4000 different dates in the end all i need to do is find what months are present in the array. my array is currently: Array ( [0] => 2006-05-18 [1] => 2006-05-21 [2] => 2006-06-23 [3] => 2006-06-27 [4] => 2006-07-17 [5] => 2006-07-17 [6] => 2006-08-01 [7] => 2006-08-01 [8] => 2006-09-14 [9] => 2006-09-17 [10] => 2006-09-30 [11] => 2006-10-17 [12] => 2006-10-27 [13] => 2006-11-14 [14] => 2006-11-14 [15] => 2006-11-14 [16] => 2006-11-20 [17] => 2006-11-20 ) I thought i could use explode at "-" and then a foreach but i thought that might take a long time if i did have a lot of dates in the array. is there an easy way to do this? just so i get the output something like array (5, 6, 7, 8, 9, 10, 11) denoting months. many thanks
-
excellent thanks - that'll be why it was changing the time when i changed my pc's clock - silly me ;)
-
Hi is there anyway using php to get the actual date from a trusted source rather than it taking the date from a users computer clock? Can it be grabbed off the internet in anyway? Many thanks
-
brilliant thanks so much. I was trying to use a for statment too but it was the $row thing i was making a mess of. Couildn't get anything to display. I'll try this way. Thanks again
-
Hi i have this problem. I'm taking data from a mysql table and trying to output it formatted on my webpage. This is easy enough what i'm really stuck on is that i have many items and i want the first 3 to be formatted one way and the rest to appear a different way. the data to be formatted is taken from a function in a seperate file. I've basically got foreach ($media_array as $row){ i want it to be (basically) [b]"foreach ($media_array as $row '[i]until the point i tell it to stop[/i]')"[/b] any ideas would be great thanks the whole code is below. function display_bundles($media_array, $logImgUrl, $logUrl) { ?> <table width="80%" border=0> <tr> <td align="center"><h2>Featured Bundles</h2></td> <td> </td> <td align="right"> <a href="<?php echo $logUrl ?>"><img src="<?php echo $logImgUrl ?>" border=0/></a> <a href="./show_cart.php"><img src="../images/checkout.jpg" border=0/> </td> </tr> <?php if(!is_array($media_array)) { echo 'No bundles currently available'; return; } foreach ($media_array as $row) { $url = 'cart_add.php?media_id='.($row['media_id']).'&pic='.($row['picture']); $title = $row['title']; $pic = $row['picture']; echo '<tr><td align="center">'; // Displays and halfs actual image size the prints data if (@file_exists('./images/'.$pic.'')) { $size = GetImageSize('./images/'.$pic.''); if ($size[0]>0 && $size[1]>0) { echo '<img src="./images/'.$pic.'" width = '.$size[0]/2 .' height = '.$size[1]/2 .' /></td>'; echo '<td><div id="desc">'.$row['title'].'</div></td>'; echo '<td><div id="desc">'.$row['description'].'</div>'; echo '<br /><div id="price">Price £'.$row['price'].'</div>'; echo '<div id="buy_but">'; display_button ($url, 'buy', 'add to cart'); echo '</div></td>'; echo '</tr>'; } } } }
-
Ok i'm really new to this so i'm sure someone will provide a better answer (or even a correct one). I think that you can't set the headers if any text or html has been sent before you modify the header. I think header changes must come first. Hope that makes some sense. Cheers
-
Cart problem - adds more items on page refresh
c_shelswell replied to c_shelswell's topic in PHP Coding Help
Cool thanks very much i'll give that a go. cheers -
Hi I'm new here and new to PHP i'm getting stuck on what is probably a very easy solution. I've got a shopping cart i'm making that sends info via $_GET to the show_cart.php page it's all working fine only problem is that everytime you hit refresh it adds the last item to the cart again. I presume because the $_GET info is still there. I tried changing the header location so that after a user had clicked on one item the page would set itself to simply show_cart.php rather than show_cart.php?media_id=1 etc. but because i'm using sessions PHP complains that the headers are already set. I've pasted the code below if anyone has any ideas that would be great. Many thanks <?php session_start(); require ('./login/include/session.php'); include('./require/required_funcs.php'); $imgUrl = "./"; echo '<div id="header"><h1>Your Shopping Cart<h1></div>'; page_header('Your Shopping Cart', $imgurl); @$new=$_GET['media_id']; $pic = $_GET['pic']; if ($new){ if(!isset($_SESSION['cart'])){ $_SESSION['cart'] = array(); $_SESSION['items'] = 0; $_SESSION['total_price']='0.00'; } if(isset($_SESSION['cart'][$new])) { $_SESSION['cart'][$new]++; } else $_SESSION['cart'][$new] = 1; $_SESSION['total_price']= calculate_price($_SESSION['cart']); $_SESSION['items'] = calculate_items($_SESSION['cart']); } if(isset($_POST['save'])){ foreach ($_SESSION['cart'] as $media_id => $qty){ if ($_POST[$media_id]=='0') unset($_SESSION['cart'][$media_id]); else $_SESSION['cart'][$media_id] = $_POST[$media_id]; } $_SESSION['total_price']= calculate_price($_SESSION['cart']); $_SESSION['items'] = calculate_items($_SESSION['cart']); } page_header('Your Shopping Cart '.$_SESSION['items'].' items', $imgurl); if($_SESSION['cart'] && array_count_values($_SESSION['cart'])) { display_cart($_SESSION['cart']); } else { echo '<p>There are no items in your cart</p>'; echo '<hr />'; } display_button('index.php', 'continue-shopping', 'Continue Shopping'); if (isset($session->username)) { $url = "./purchase.php"; } else { $url = "./login/login.php"; } display_button($url, 'go-to-checkout', 'Go to Checkout'); html_footer(); ?>