Another PHP newbie here, I trolled the boards here trying some of the different solutions but I keep getting the errors over an over. maybe my problem is specific. I keep getting the following when I load my test.php file into the browser. -
PHP Notice: Undefined index: variable in Path to page on line 24
-
The line in question is this -
$query1="insert into tablename ('var','var1','var2','var3','var4','var5','var6') values ('" . $_POST["var"] . "', '" . $_POST["var1"] . "', '" . $_POST["var2"] . "', '" . $_POST["var3"] . "', '" . $_POST["var4"] . "', '" . $_POST["var5"] . "','" . $_POST["var6"] . "')";
-
I'm sure it's something simple, but I can seem to shake it. I have of course changed the variable names, but you get the idea. I get one error for each variable. The page itself displays fine it just these errors at me. Any help would be great.
Thanks
Dean
5 6689 Markus 6,050
Recognized Expert Expert
for the values you don't need to do (' ".$vari." ')
just do ('$vari')
Other than that (which isnt an error) i don't know :(
aym 4
New Member
post the whole code please with your form???
I haven't written the form yet. Just a couple of tables and pictures on the page. Is that the problem? Here is the whole page. -
<html>
-
-
<head>
-
<title>Title</title>
-
<link rel="stylesheet" type="text/css" href="style.asp">
-
<?php include("javascript.js"); ?>
-
-
<?php
-
if ($_POST["function"] = "add")
-
{
-
$con = odbc_connect('databasename','root','');
-
-
$query1="insert into tablename ('var','var1','var2','var3','var4','var5','var6') values ('" . $_POST["var"] . "', '" . $_POST["var1"] . "', '" . $_POST["var2"] . "', '" . $_POST["var3"] . "', '" . $_POST["var4"] . "', '" . $_POST["var5"] . "','" . $_POST["var6"] . "')";
-
-
$cr1=odbc_exec($con,$query1);
-
-
odbc_close($con);
-
}
-
?>
-
<body>
-
<table>
-
<tr>
-
<td>
-
Test
-
</td>
-
<td>
-
<img src="whatever.jpg">
-
</td>
-
</tr>
-
</table>
-
</body>
-
</html>
-
Markus 6,050
Recognized Expert Expert -
<html>
-
-
<head>
-
<title>Title</title>
-
<link rel="stylesheet" type="text/css" href="style.asp">
-
[php]
<?php include("javasc ript.js"); ?>
<?php
if ($_POST["function"] = "add")
{
$con = odbc_connect('d atabasename','r oot','');
$query1="INSERT INTO `table_name`
(var, var1, var2, var3, var4, var5, var6)
VALUES
('$_POST["var"]',
'$_POST["var1"]',
'$_POST["var2"]',
'$_POST["var3"]',
'$_POST["var4"]',
'$_POST["var5"]',
'$_POST["var6"]')";
$cr1=odbc_exec( $con,$query1);
odbc_close($con );
}
?>
[/php] -
<body>
-
<table>
-
<tr>
-
<td>
-
Test
-
</td>
-
<td>
-
<img src="whatever.jpg">
-
</td>
-
</tr>
-
</table>
-
</body>
-
</html>
-
Cleaned it up a little bit there.
Hm..
The only thing i can think of is that it because you haven't opened a connection anywhere, where you state odbc_close it generates an error?
I'm really not sure.
Ok, here is what I have now and the new error. -
<?php
-
-
if ($_POST["function"] = "add")
-
{
-
var $var1 = $_POST['var1'];
-
var $var2 = $_POST['var2'];
-
var $var3 = $_POST['var3'];
-
var $var4 = $_POST['var4'];
-
var $var5 = $_POST['var5'];
-
var $var6 = $_POST['var6'];
-
var $var7 = $_POST['var7'];
-
-
$con = odbc_connect('databasename','','');
-
-
$query1="insert into tablename
-
(tablefield1, tablefield2, tablefield3, tablefield4, tablefield5, tablefield6, tablefield7)
-
VALUES
-
('$var1',
-
'$var2',
-
'$var3',
-
'$var4',
-
'$var5',
-
'$var6',
-
'$var7')";
-
-
$cr1=odbc_exec($con,$query1);
-
-
odbc_close($con);
-
}
-
-
?>
-
And the new error -
PHP Parse error: syntax error, unexpected T_VAR in C:\yada\yada\yada\test.php on line 12
-
Line 12 being... -
var $var1 = $_POST['var1'];
-
In addition I checked the version of PHP via phpinfo() and it's 5.2.1, so no problem there. I know I'm just getting something wrong in the syntax.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: jsgoodrich |
last post by:
I am looking for some help if anyone can lend a hand.
I have a simple php website that displays a table from my mysql
database.
To prep for my MCSE I moved my home server to Windows 2003 Standard, I
installed mysql and php 5 to run some of my databases and websites.
Under Linux the site worked fine, under windows I keep getting Notice
Undefined Index error on line 67
|
by: number1yan |
last post by:
Can anyone help me,
i am creating a website and am using a php script that recomends the website to other people. I keep getting the same error and can not work out why. The error is:
Notice: Undefined index: FriendName in D:\Yan\Over_8\SendEmail.php on line 4, Notice: Undefined index: FriendEmail in D:\Yan\Over_8\SendEmail.php on line 5, Notice: Undefined index: Name in D:\Yan\Over_8\SendEmail.php on line 6, Notice: Undefined index: Email...
|
by: Reggie |
last post by:
am trying to create a a upload file.am uploading files ok but i
recieve this message.
Notice: Undefined variable: uploaded_size in /home/fhlinux169/c/
clashoff.co.uk/user/htdocs/upload.php on line 7
Notice: Undefined variable: uploaded_type in /home/fhlinux169/c/
clashoff.co.uk/user/htdocs/upload.php on line 14
Notice: Undefined index: uploadedfile in /home/fhlinux169/c/
|
by: sickboy |
last post by:
$channels=$_GET; if (empty($channels)) { $channels='blank'; } changechannels($channels);
$theatre=$_GET; if (empty($theatre)) { $theatre='splash'; } changetheatre($theatre);
$info=$_GET; if (empty($info)) { $info='noinfo'; } changeinfo($info);
Hey everyone,
I keep getting an error regarding the above code. These are the errors:
Notice: Undefined index: channels in /home/forcefed/public_html/index.php on line 5
|
by: Pseudonyme |
last post by:
Dear All :
Ever had an httpd error_log bigger than the httpd access log ?
We are using Linux-Apache-Fedora-Httpd 2006 configuration.
The PHP lines code that lead too tons of errors are :
$http_ref= $HTTP_REFERER;
$prog = $_COOKIE;
| |
by: francsutherland |
last post by:
Notice: Undefined index: send in D:\Domains\workingdata.co.uk\wwwroot\contact_text.php on line 7
Hi,
I've started getting this error in the contact page form of my website. The web hosting company did an upgrade and it seems to coincide with that.
The Notice is at the top of the page, but the rest of the page displays normally and form still works. I don't get the Notice when I test the page on the local Apache server in the XAMPP...
|
by: FutureShock |
last post by:
I have since recently turned up my error reporting on a production site
to E_ALL to ensure I am using 'best practices' when writing out code.
So far it has helped me discipline myself with initializing my
variables. I am running into a problem with my $_POST array though.
I am self-referencing a form page for processing, so at the beginning I
am looking for the existence of certain $_POST variables for processing.
I am setting an...
|
by: stealthmode666 |
last post by:
New to .php so need script help.
I want to know how to stop this being displayed when I click submit.
Notice: Undefined index: homeowner in E:\domains\r\...\user\htdocs\...\form.php on line 166
I have an array which takes filled in fields and blank fields and sends them via email.
I DON'T need the user to fill in all the fields which is resulting in this notice on every field that is not filled in. I do need the fields to be sent tho'...
|
by: complearn |
last post by:
Do you know why I got these errors for status_bar.php in some webhost, but work perfectly on other webhost?
Whats wrong? here are the codes from line 18, our webhost is running php5.
$dmg = ($_GET == 0 || $_GET == '22') ? $_GET : $_GET+$_GET;
|
by: Smellydog |
last post by:
I'm having a strange issue with PHP version 5.2.8 running on Windows Vista with Lighttpd. I receive a Notice that says the following:
Notice</b>: Undefined index: name in <b>E:\LightTPD\htdocs\go\go\form.php</b> on line <b>160</b>
Here is the odd part. No matter what I do, no matter how many times I change the script, add lines, remove lines, the notice keeps referencing the same file and line number. Even when I comment out the line,...
|
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,...
| |
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...
|
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,...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |