473,786 Members | 2,849 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP script

matheussousuke
249 New Member
May someone help me correct this script? there a few ' and " and ; in the wrong places:


Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include "./comm.inc"; 
  3. connectdb(); 
  4. $sql = "SELECT imgid,imgtype FROM tblimage ORDER BY imgid";  
  5.  
  6. $result = @mysql_query($sql) or die(mysql_error());  
  7.  
  8. echo '<table border=1>n';  
  9. echo '<tr><th>imgid</th><th>imgtype</th><th>imgdata</th></tr>n';  
  10. while ($rs=mysql_fetch_array($result)) {  
  11.   echo '<tr><td>.$rs[0].</td>';  
  12.   echo '<td>.$rs[1].</td>';  
  13.   echo '<td><img src="post.php?imgid=.$rs[0]."" width=100 height=100></td></tr>n';  
  14. echo '</table>n';  
  15.  
  16. ?>
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
Nov 6 '09 #1
26 2406
matheussousuke
249 New Member
I'll post here the other two codes:

post.php -->

Expand|Select|Wrap|Line Numbers
  1. <?  
  2. if (!isset($submit)) {  
  3. ?>  
  4. <form method="POST" action="" enctype=multipart/form-data>  
  5. <table>  
  6. <tr><td>Type</td><td><select name="imgtype"><option value="image/gif">GIF</option><option  
  7. value="image/jpeg">JPEG</option></select></td></tr>  
  8. <tr><td>File</td><td><input type="file" name="imgfile"></td></tr>  
  9. <tr><td></td><td><input type="submit" name="submit" value="upload"><input type="reset" value="reset"></td></tr>  
  10. </table>  
  11. </form>  
  12. <?  
  13. } else {  
  14.         include "./comm.inc"; 
  15.         connectdb(); 
  16.         $hndl=fopen($imgfile,"rb");  
  17.         $imgdata=''; 
  18.         while(!feof($hndl)){ 
  19.                 $imgdata.=fread($hndl,2048);  
  20.         } 
  21.  
  22. {
  23.         $imgdata=addslashes($imgdata);  
  24.  
  25.         $sql = 'INSERT INTO tblimage VALUES(NULL,". $imgtype .",". $imgdata .")';  
  26.  
  27.         @mysql_query($sql) or die(mysql_error());  
  28.  
  29.         fclose($hndl);  
  30.  
  31.         echo '<a href="view.php">view image</a>';  
  32. }  
  33. ?> 
  34.  
  35.  


And




upload.php -->





Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if (!isset($submit)) {
  3. ?>
  4. <form method="POST" action="" enctype=multipart/form-data>
  5. <table>
  6. <tr><td>Tipo</td><td><select name="imgtype"><option value="image/gif">GIF</option><option
  7. value="image/jpeg">JPEG</option></select></td></tr>
  8. <tr><td>File</td><td><input type="file" name="imgfile"></td></tr>
  9. <tr><td></td><td><input type="submit" name="submit" value="upload"><input type="reset" value="reset"></td></tr>
  10. </table>
  11. </form>
  12. <?
  13. } else {
  14.         include "./comm.inc";
  15.         connectdb();
  16.         $hndl=fopen($imgfile,"rb");
  17.         $imgdata='';
  18.         while(!feof($hndl)){
  19.                 $imgdata.=fread($hndl,2048);
  20.         }
  21.  
  22.         $imgdata=addslashes($imgdata);
  23.  
  24.         $sql = 'INSERT INTO tblimage VALUES(NULL,", $imgtype .",". $imgdata .")';
  25.  
  26.         @mysql_query($sql) or die(mysql_error());
  27.  
  28.         fclose($hndl);
  29.         echo '<a href="view.php">view image</a>';
  30. }
  31. ?>
Nov 6 '09 #2
code green
1,726 Recognized Expert Top Contributor
This is a rather tiresome task you have set.
Do you think it is fair to expect people to trail through your code looking for syntax errors.
If you put some debugging in your code you might help yourself to find the problem
Nov 6 '09 #3
matheussousuke
249 New Member
sorry, I just though....
Nov 6 '09 #4
matheussousuke
249 New Member
whell, I fexed a little things in view.php, and upload.php is correct, maybe the trouble is just in post, and dont get any error using the scripts, that's the problem but the image doesnt appear when I open view.php
Nov 6 '09 #5
matheussousuke
249 New Member
I'll post a photo here
Nov 6 '09 #6
matheussousuke
249 New Member
This is how it appears on the browser:






And this is how I left view.php:


Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include "./comm.inc"; 
  3. connectdb(); 
  4. $sql = "SELECT imgid,imgtype FROM tblimage ORDER BY imgid";  
  5.  
  6. $result = @mysql_query($sql) or die(mysql_error());  
  7. {
  8. echo '<table border=1>n';  
  9. echo '<tr><th>imgid</th><th>imgtype</th><th>imgdata</th></tr>n';  
  10. while ($rs=mysql_fetch_array($result))
  11.  
  12.   echo '<tr><td>".$rs[0]."</td>';  
  13.   echo '<td>".$rs[1]."</td>';  
  14.   echo '<td><img src="post.php?imgid=.$rs[0]." width=100 height=100></td></tr>n';  
  15. echo '</table>n';
  16.  
  17.  
  18. }
  19.  
  20. ?>
Nov 6 '09 #7
matheussousuke
249 New Member
True is I'm not getting any bug anymore, but, it just doesn't appears.
Nov 6 '09 #8
Markus
6,050 Recognized Expert Expert
Variables are not parsed within single quoted strings. You'll have to concatenate the string or use double quotes:

Expand|Select|Wrap|Line Numbers
  1. $name = "Mark";
  2. // Works
  3. echo "My name is $name";
  4. // Also works
  5. echo 'My name is ' . $name;
  6. // Doesn't work: prints "My name is $name"
  7. echo 'My name is $name';
  8.  
Also, in future please provide all error details. Simply asking us to 'look at' something and deduce what is wrong with it simply isn't the proper way to ask a question to a bunch of volunteers.

Mark.
Nov 6 '09 #9
matheussousuke
249 New Member
@Markus


Do I have to do that to view.php, post.php, upload.php, or both?
Nov 6 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

6
12987
by: Mike Daniel | last post by:
I am attempting to use document.write(pageVar) that displays a new html page within a pop-up window and the popup is failing. Also note that pageVar is a complete HTML page containing other java scripts. Being a javascript newbie and after significant testing, I suspect that the document.write fails after finding a </script> within pageVar. Does a trick exist that enables one to slightly alter pageVar whereby enabling...
1
3255
by: bayouprophet | last post by:
Cant get menu script to to put linked page in the same frame. I am new to Java and I am wondering what am I doing wrong? below are my java applet file, frame.html file, and my text file and one of my link file that should load next to the menu on the same page. And Thank You in advance. Here is my menu applet: <html>
1
4819
by: Allen | last post by:
I am trying to add an additional photo/hyperlink to the company web site (I didn't create it) without any luck. The mouseover feature 'highlights' pics by swapping them with another pic using this command in some type of array. I added the mailbox in the lower left corner (see link below)http://www.aamechanical.com/indextemp.htm but I cannot get it to swap. Here is the code for the page: Thanks for your help in advance
3
2959
by: Water Cooler v2 | last post by:
Questions: 1. Can there be more than a single script block in a given HEAD tag? 2. Can there be more than a single script block in a given BODY tag? To test, I tried the following code. None of the script gets executed. Can someone please give me a direction as to what I may be missing? Thanks.
2
2972
by: bilaribilari | last post by:
Hi all, I am using Tidy (C) for parsing html pages. I encountered a page that has some script as follows: <script> .... var abc = "<script>some stuff here</" + "script>"; .... </script>
19
3827
by: thisis | last post by:
Hi All, i have this.asp page: <script type="text/vbscript"> Function myFunc(val1ok, val2ok) ' do something ok myFunc = " return something ok" End Function </script>
3
2490
by: rsteph | last post by:
I have a script that shows the time and date. It's been working on my site for quite a while now. Suddenly it stops showing up, after getting my drop down menu to work. If I put text between the <div id="datetime"></div> tags, the text shows up, but the javascript output being sent to those some divs doesn't seem to want to work. It should be showing up in the middle of the content pane, just below the first table box. (set by .css) Here's...
3
3685
by: Angus | last post by:
I have a web page with a toolbar containing a Save button. The Save button can change contextually to be a Search button in some cases. Hence the button name searchsavechanges. The snippet of html is: <a class="searchsavechanges btn btn3d tbbtn" href="javascript:" style="position:static"> <div id="TBsearchsavechanges">Search</div> </a>
7
3616
by: imtmub | last post by:
I have a page, Head tag Contains many Scripts and style sheet for Menu and Page. This code working fine and displaying menus and page as i wanted. Check this page for reference. http://www.marco.com.cn/web-content/marco_re10.html -------------------------------------------------------------- <head> <!-- InstanceBeginEditable name="doctitle" --> <title>Marco</title> <!-- InstanceEndEditable -->
1
47489
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
0
9496
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9961
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4066
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3669
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.