473,385 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Checking for two conditionals - not working

155 100+
On my image process page I want to first check to see that the picture title ($item_title) isn't in use, if not the script moves to the next conditional.

Now we check to make sure that the image name ($image) isn't already in the database. (The file name is $image and the table row is image_name.) If the image name isn't in the database the script continues.

I have tested for the picture title and the script will fail and return an error message if the picture title is in use. But I it doesn't work for the image name.

I use an image that I know is already in the database, so the script should terminate and display an error message, it's terminating but I'm not getting an error message. The information isn't being entered, as I have both $item_title and $image_name set as unique keys in the database table.

Here's the code:
Expand|Select|Wrap|Line Numbers
  1. $item_title = escape_data($_POST['item_title']);
  2. $image = escape_data($_POST['image']);
  3.  
  4. // Make sure the image title is available.
  5. $query = "SELECT id FROM jodie_pictures
  6. WHERE item_title='$item_title'";
  7. $result = mysql_query ($query) or die(mysql_error());
  8. if (mysql_num_rows($result) == 0)
  9. {
  10.  
  11. // Make sure the image image_name isn't already in the database.
  12. $query = "SELECT id FROM jodie_pictures
  13. WHERE image_name='$image'";
  14. $result = mysql_query ($query) or die(mysql_error());
  15. if (mysql_num_rows($result) == 0)
  16. {
  17.  
  18. // Max allowed size of the image (in bytes): 
  19. $maxUploadSize = 2100000;
  20.  
  21.  
  22.  --- more code goes here to process image ---
  23.  
  24. }
  25. else
  26. { // image_name is already in use
  27. echo "<span style='color:red; font-weight:bold; font-size:16px;'>
  28. ERROR!</span><br /><br />
  29. The image <strong>$image</strong> is already in the database. Hit your &quot;Back&quot; button and choose a new image.<br />";
  30. footer();
  31. exit();
  32. }
  33.  
  34. }
  35. else
  36. { // item_title is already in use
  37. echo "<span style='color:red; font-weight:bold; font-size:16px;'>
  38. ERROR!</span><br /><br />
  39. The Picture Title <strong>$item_title</strong> is already in use. Hit your &quot;Back&quot; button and enter a new title.<br />";
  40. footer();
  41. exit();
  42. }
Any ideas as to what I'm doing wrong?

Thanks
Jun 2 '09 #1
3 1222
code green
1,726 Expert 1GB
Echo the value of the POST data and test the result of the query.
Also echo out $query to see what it actually6 says.
Jun 2 '09 #2
prabirchoudhury
162 100+
hey .. query working fine .. find out what 'code_green' said.. check $_POST data ... :)
Jun 2 '09 #3
Atli
5,058 Expert 4TB
I'm with them.
Your code looks fine, so the problem must be with the input.

Maybe your escape_data function is doing something it's not supposed to be doing?
Jun 2 '09 #4

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

Similar topics

1
by: FHuang | last post by:
Ok, I'm having some trouble with conditionals, for some reason PHP is screwing them up. First off, here is the code: <?php $username = "fred"; $userdata = "./$username.txt"; $fp =...
15
by: Joshua Ginsberg | last post by:
Is there any plan to include inline conditionals in Python? For example: def isNegative(x): return x < 0 ? True : False Thanks! -jag --
1
by: Paul Dale | last post by:
Hi All, I know that several of you will probably want to reply "you should write a parser", and I may. For that matter any tips on theory in that direction would be appreciated. However, if...
3
by: steven | last post by:
Is it possible to combine conditionals to call out data? I have a list of records that include a date. I can call out all dates after the date after tomorrow: IIf(Date()+1)<,...,... And I can...
4
by: Leon Lambert | last post by:
I would appreciate it if someone could help me understand NaN handling with respect to conditionals in IL code. I am playing with a small IL interpreter and having a little problem with it....
11
by: .Net Sports | last post by:
I need to convert some C# ?Conditionals over to vb.net (most likely in vb.net using If..Then statements), but the C#2VBNETconverter by KamalPatel isn't converting them: string PurchaseType =...
6
by: chopin | last post by:
I am working in Access 2003 in Windows XP. I am using Visual Basic for Applications, using DAO to write my modules. What I need to do is write a module that will compare each row to see if they are...
5
by: Hul Tytus | last post by:
comp.lang.c c programs & shell conditionals How is a unix shell script made to respond to the value returned by a program compiled from c code? The shell script below is my current effort,...
27
by: Aaron Hsu | last post by:
Hey all, After seeing the Secure version I/O functions thread, it occured to me that maybe not everyone agrees with the almost universal adage that I have heard. I have Always been told that...
1
by: rocking | last post by:
Hi Guys, I am working to achieve something that lokks really simple , but it actually sint. I have I text tab delimited file. in every line of that file at the same position in every row of the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...

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.