473,799 Members | 3,052 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
26 2410
Markus
6,050 Recognized Expert Expert
@matheussousuke
Wherever you are outputting strings (and they are not showing correctly).
Nov 6 '09 #11
matheussousuke
249 New Member
Well, true is, I found that script on forum, dont remember witch, had to correct a lot of things, it was worst than that.


Let's go to the point, all I wanted was a simple script that could upload a image to mysql and show it on page. And this script "does" all of this.


So if someone could give a script with that simple task, I would be really greatful, I'm not being rude, I'm tellgin that cause I spent more than 4 hours looking on google for a script that could do what I need.

The goal is put a option on my site where the user can be able to manage the index logo diretly from the admin area by using image upload function.
Nov 6 '09 #12
code green
1,726 Recognized Expert Top Contributor
What Markus is referring to is lines such as this
Expand|Select|Wrap|Line Numbers
  1. echo '<td><img src="post.php?imgid=.$rs[0]." 
  2. width=100 height=100></td></tr>n'; 
You have wrapped the whole line in single quotes so the variable inside will not be parsed.
In fact the variable is concatenated but the quotes are not opened or closed
This is better
Expand|Select|Wrap|Line Numbers
  1. echo '<td><img src="post.php?imgid='.$rs[0].'" 
  2. width=100 height=100></td></tr>n'; 
You need to correct all lines such as this
Nov 9 '09 #13
matheussousuke
249 New Member
I'm using a image upload script without mysql, it works perfectly, all I want is to show its image on my site index.

The script works like this:

It simple upload a image with the name logo. with extension in front (eg. logo.png).

What I need is a way to show it on index with a code such as img src


eg.:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?
  3. echo '<img src="admin/fotos/logo.   I need a way to put a extension variable here, so, undepeding on extension format, it will always show image file, rembering that the name is aways "logo.".
  4.  
  5. ">';
  6. ?>
  7.  
  8.  
  9.  
Nov 9 '09 #14
code green
1,726 Recognized Expert Top Contributor
It has been explained to you what you are doing wrong in your thread http://bytes.com/topic/php/answers/876650-php-script
Nov 9 '09 #15
maheswaran
190 New Member
Have u checked that logo extension got coorectly for example logo.png. If you echo any values using single code, for example
Expand|Select|Wrap|Line Numbers
  1. <?
  2.  echo '<img src="admin/fotos/logo.".$ext."">
  3. ?>
  4.  
  5. then you must add ". ." in variables.
  6.  
Nov 11 '09 #16
Markus
6,050 Recognized Expert Expert
@maheswaran
That won't work - and will definitely throw an error.

The correct PHP would look like:
Expand|Select|Wrap|Line Numbers
  1. <?
  2.  echo "<img src='admin/fotos/logo" . $ext . "'>";
  3. ?>
  4.  
Furthermore, please do not double post your questions.
Nov 11 '09 #17
maheswaran
190 New Member
i think your code is wrong
Nov 11 '09 #18
Markus
6,050 Recognized Expert Expert
@maheswaran
Would you care to clarify?
Nov 11 '09 #19
Dormilich
8,658 Recognized Expert Moderator Expert
the dot between file name and file extension is missing. there is also the required alt attribute missing.
Nov 11 '09 #20

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

Similar topics

6
12988
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
3256
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
4820
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
2961
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
2973
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
3829
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
2491
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
3688
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
3618
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
47492
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
10482
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10225
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7564
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
6805
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
5463
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
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4139
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
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.