473,326 Members | 2,111 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,326 software developers and data experts.

Undefined variable: y in C:\wamp\www\gun.php on line 8

I am getting an error that "y is undefined variable".
I know this will gonna be so simple and basic problem but I am new to php so that's why I am facing this problem.
please me its urgent for me.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $Amtoffirstrelease=$_POST['Amtoffirstrelease'];
  3. $Amtofsecondrelease=$_POST['Amtofsecondrelease'];
  4. $head=$_POST['head'];
  5. $subhead=$_POST['subhead'];
  6. $Availableamt=$Amtoffirstrelease+$Amtofsecondrelease;
  7. $sanctionedamt=$_POST['sanctionedamt'];
  8. $progressivebal=$y+$sanctionedamt;
  9. $dbhost = "localhost";
  10. $dbuser = "root";
  11. $dbpass = "";
  12. $dbname = "purchase";
  13. mysql_connect($dbhost, $dbuser, $dbpass);
  14. mysql_select_db($dbname) or die(mysql_error());
  15.  
  16. $x="SELECT MAX(progressivebal) FROM 'naipone'";
  17. $y= mysql_query("SELECT progressivebal FROM 'naipone' WHERE progressivebal=x") or die('error');
  18. $query="insert into naipone(Amtoffirstrelease, Amtofsecondrelease, head, subhead, 
  19.  
  20. Availableamt,sanctionedamt,progressivebal) values 
  21.  
  22. ('$Amtoffirstrelease','$Amtofsecondrelease','$head','$subhead','$Availableamt','$sanctionedamt','$progressiveba
  23.  
  24. l')";
  25. mysql_query($query)or die('error');
  26. echo"database update with:" .$Amtoffirstrelease."" .$Amtofsecondrelease. "".$Availableamt."" .$head."".
  27.  
  28. $subhead."";
  29. ?>
Feb 21 '13 #1
5 1572
Rabbit
12,516 Expert Mod 8TB
Line 8, you use a variable y without first assigning it a value.
Feb 21 '13 #2
Now its solved but its show error1 which at 18 line.
Feb 21 '13 #3
gvuksa
7
You should use mysql_error to know exactly what the error is.
You should maybe lose empty lines or try something like this
Expand|Select|Wrap|Line Numbers
  1. $query="insert into naipone(Amtoffirstrelease, Amtofsecondrelease, head, subhead," .
  2.  
  3. "Availableamt,sanctionedamt,progressivebal) values" .
  4.  
  5. "('$Amtoffirstrelease','$Amtofsecondrelease','$head','$subhead','$Availableamt','$sanctionedamt','$progressiveba" .
  6.  
  7. "l')";
  8.  
Feb 21 '13 #4
Thanks!
It works.I solved that problem. But now the main problem is progressivebal values does not update as I want (like line 9 and 18).
Thank you
Feb 21 '13 #5
Rabbit
12,516 Expert Mod 8TB
We only allow one question per thread on this forum. Please create a new thread for your question.
Feb 21 '13 #6

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

Similar topics

3
by: Dan Finn | last post by:
OpenBSD 3.2 Apache 1.3.26 PHP 4.3.4 PHP-Nuke 6.9 getting these in the apache error log: Sun Nov 16 20:20:16 2003] PHP Notice: Undefined variable: HTTP_USER_AGENT in...
4
by: Chris Beall | last post by:
If you want your code to be bulletproof, do you have to explicitly check for the existence of any possibly-undefined variable? Example: window.outerHeight is defined by some browsers, but not...
1
by: prabhunew2005 | last post by:
hi I am doing web portal design using php. I gave part of one of my screen coding. <html> <head> <script language = "javascript"> function list_all_click()
2
by: Bob Bruyn | last post by:
I've recently installed Apache 2 and php 5.2 on my WIndows XP machine. Everything is up and running. I'm passing some vars via the URL. It works fine online:...
5
by: siyaverma | last post by:
Hi, I am new to php, i was doing some small chnages in a project developed by my collegue who left the job and i got the responsibility for that, After doing some changes when i run it on my...
3
Markus
by: Markus | last post by:
I was just playing around with javascript today and i wanted to change the style of a table element with javascript. The code i am using: ChangeIt(id){ var target = document.getElementById(id)...
1
by: bob johnson | last post by:
Notice: Undefined variable: db_host in C:\wamp\www\cbmall\index.php on line 7 Notice: Undefined variable: db_user in C:\wamp\www\cbmall\index.php on line 7 Notice: Undefined variable: db_pass...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.