Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-18-2012, 09:45 PM   PM User | #16
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,513
Thanks: 45
Thanked 439 Times in 428 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
But as I said to you earlier:

Quote:
Originally Posted by tangoforce View Post
Well that won't really help much. Unless you print the path to the image in the html, how do you expect to test it?
you need to print the file path and filename in your html now instead of the static image you've hard coded.

Please will you change this:
<img src="<?php bloginfo('template_url'); ?>/images/pic_02.jpg" />

To this:
<img src="<?php bloginfo('template_url'); print $pic; ?>" />

If you won't do that, then how do you expect to get this working?
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Users who have thanked tangoforce for this post:
gazaian1 (09-20-2012)
Old 09-19-2012, 02:01 AM   PM User | #17
gazaian1
New Coder

 
Join Date: Aug 2011
Posts: 52
Thanks: 24
Thanked 0 Times in 0 Posts
gazaian1 is an unknown quantity at this point
Quote:
Originally Posted by Len Whistler View Post
A good way to debug PHP is to View Page Source and see what is missing in the HTML. I use FireFox to view the page source, I don't know about IE or Opera.



---
Thanks alot i get this error when i put the full path of the image directory for the image to be uploaded to:

Warning: move_uploaded_file(http://speedycarloans.ca/wp-content/...timonial/2.jpg) [function.move-uploaded-file]: failed to open stream: HTTP wrapper does not support writeable connections in /home/jbeck451/public_html/wp-content/themes/speedy/testimonial_code.php on line 21

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpigr46X' to 'http://speedycarloans.ca/wp-content/themes/speedy/testimonial/2.jpg' in /home/jbeck451/public_html/wp-content/themes/speedy/testimonial_code.php on line 21

Last edited by gazaian1; 09-19-2012 at 02:07 AM..
gazaian1 is offline   Reply With Quote
Old 09-19-2012, 10:38 PM   PM User | #18
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,513
Thanks: 45
Thanked 439 Times in 428 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Thats because you can't use move_uploaded_file() to move files onto a http:// address like you have tried to do.

Think about it for a moment.. If you could, you'd be able to upload files onto any part of facebook, codingforums, msn, yahoo etc that you wanted. Their servers are all password protected so do you really think PHP could move any file to any http:// address? No!

You must provide a operating system path instead just like the ones in the error message itself.
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Users who have thanked tangoforce for this post:
gazaian1 (09-20-2012)
Old 09-20-2012, 02:00 AM   PM User | #19
gazaian1
New Coder

 
Join Date: Aug 2011
Posts: 52
Thanks: 24
Thanked 0 Times in 0 Posts
gazaian1 is an unknown quantity at this point
Thank you guys for the help i got through my issue by storing http and url in a variable then adding it to my out pay from the database to get a full path to source.

Hope this helps someone else

PHP Code:
<?php   
                        $per_page 
4;

                        
$pages_query mysql_query("SELECT COUNT(id) FROM testimonial WHERE active='1'")or die(mysql_error());
                        
$pages ceil(mysql_result($pages_query0) / $per_page);

                        
$page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1;
                        
$start = ($page 1) * $per_page;
                    
                        
$query mysql_query("SELECT id, name, comment, picture FROM testimonial WHERE active='1' LIMIT $start, $per_page") or die(mysql_error());
                        
$count=mysql_num_rows($query);
                        
                        
$uploadDir 'wp-content/themes/speedy/testimonial/'//Image Upload Folder
                        
$path 'http://speedycarloans.ca/';
                        
$fileName addslashes($_FILES['pict']['name']);
                        
                        
$filePath addslashes$path $uploadDir $fileName);
                        
                        
                        
                        
$count=1;
                        while (
$query_row mysql_fetch_array($query)){
                        
$pic=$query_row['picture'];
                        include(
'path.php');
                        
?>
                        
                      <?php if($count==1){ ?>
                        <div class="boxhide">
                        <div class="testmon_box">
                      <?php ?>
                      <?php if($count<=1){ ?>    
                      <div class="TESMON_INNERBOX">
                       
                         
                                
                      <div class="pic_block">
                            <?php if($pic !=$uploadDir){?>
                                <img src="<?php echo $path $pic?>" />
                            <?php } else{?><img src="<?php bloginfo('template_url'); ?>/images/pic_02.jpg" /><?php ?>
                            
                      </div>
                        
                       <div class="test_cont_block">

                          <p> <?php echo $result=$query_row['comment']; ?></p>

                         <span class="danam"> 
                        Date of Posting: <?php echo date('l, F j, Y'); ?><br/>

                        <strong>Posted by: <?php echo $result=$query_row['name']; ?></strong>

                         </span>
                         
                       </div>
                            
                             
                             
                       <div class="clear"> </div>

                        </div>

                    

                        </div>
                       <?php }?>
                              
                       <?php }?>
                     
                      <div class="pagin_nav">
                         <?php if ($pages >=&& $page <= $pages){
                           for (
$x=1$x<=$pages$x++){
                                echo (
$x == $page) ? '<strong><a class="pagi" href="?page='.$x.'">'.$x.'</a></srtong> ' '<a class="pagi" href="?page='.$x.'">'.$x.'</a> ';
                              
                           }
                         }
?>
                     </div>
                     </div>
gazaian1 is offline   Reply With Quote
Old 09-20-2012, 02:04 AM   PM User | #20
gazaian1
New Coder

 
Join Date: Aug 2011
Posts: 52
Thanks: 24
Thanked 0 Times in 0 Posts
gazaian1 is an unknown quantity at this point
Quote:
Originally Posted by tangoforce View Post
Thats because you can't use move_uploaded_file() to move files onto a http:// address like you have tried to do.

Think about it for a moment.. If you could, you'd be able to upload files onto any part of facebook, codingforums, msn, yahoo etc that you wanted. Their servers are all password protected so do you really think PHP could move any file to any http:// address? No!

You must provide a operating system path instead just like the ones in the error message itself.
Thanks for the help again i have another question how can i get a single result form a mysql database and have it automatically changed with ajax on the front end.
gazaian1 is offline   Reply With Quote
Old 09-20-2012, 04:57 AM   PM User | #21
Len Whistler
Senior Coder

 
Len Whistler's Avatar
 
Join Date: Jul 2002
Location: Vancouver, BC Canada
Posts: 1,323
Thanks: 26
Thanked 100 Times in 100 Posts
Len Whistler is on a distinguished road
gazaian1 ..... Before you go further I highly recommend you clean up your code. It looks like you google bits of code and stick them together.

You don't need all those PHP opening and closing tags, you have include('path.php') inside a database query loop, and I would take out all the tabs and spaces and indent the code in a more presentable way.


--------------
__________________
Leonard Whistler
Len Whistler is offline   Reply With Quote
Users who have thanked Len Whistler for this post:
gazaian1 (09-21-2012)
Reply

Bookmarks

Tags
html, php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:54 AM.


Advertisement
Log in to turn off these ads.