Hi
I am currently setting up a script so that it inserts information into one table and then follows onto the next few lines and checks to see if the user already has a row in a different table if not the script should insert into the database, if the user already has a row it will update the information by adding the numbers to the ones currently stored in the database.
At present I am testing the second SQL insert which does not work? I'm not worried about the update just (I think I know how I will sort this out).
Can anyone see what I am doing wrong please?
[PHP]
// Includes the connection details to the database
virtual('/cbagsv2/connections/dbasecon.php');
mysql_select_db ($dbase, $connection);
//SQL Insert for the scorecard database table, inserting all details
$sql="INSERT INTO scorecard (user,course,da te,score,course par,adjustscore ,
stablefordpoint s,holein1,eagle ,birdie,par,bog ey,
other,dblbogey, hole1,hole2,hol e3,hole4,hole5,
hole6,hole7,hol e8,hole9,hole10 ,hole11,hole12,
hole13,hole14,h ole15,hole16,ho le17,hole18) VALUES ('$name','$cour se','$date','$t otalscore','$to talpar',
'$addjustscore' ,'$stableford', '$hole1','$eagl e','$birdie',
'$par','$bogey' ,'$dblbogey', '$other','$hole _1_score',
'$hole_2_score' ,'$hole_3_score ','$hole_4_scor e',
'$hole_5_score' ,'$hole_6_score ','$hole_7_scor e',
'$hole_8_score' ,'$hole_9_score ', '$hole_10_score ',
'$hole_11_score ','$hole_12_sco re','$hole_13_s core',
'$hole_14_score ' ,'$hole_15_scor e','$hole_16_sc ore',
'$hole_17_score ','$hole_18_sco re')";
if (!mysql_query($ sql,$connection ))
{
die('Error: ' . mysql_error());
}
else
{
echo "<p>Statist ics successfully added to the scorecard database.</p>";
}
//Checks the totalstats db table to see if the user already exists in the table and also checks if the year is the same
$sqlselect = "SELECT * FROM totalstats WHERE name = '$name' AND year = '$year'";
if($result = mysql_db_query( $sqlselect, $connection))
{
if(mysql_num_ro ws($result))
{
}
else
{
$queryInsert = "INSERT INTO totalstats (name,holein1,e agle,birdie,par ,bogey,dblbogey ,other,sablefor dpoints,year) VALUES ('$name','$hole 1','$eagle','$b irdie','$par',' $bogey','$dblbo gey','$other',' $stableford','$ year')";
if (!mysql_db_quer y($queryInsert, $connection))
{
die('Error: ' . mysql_error());
}
else
{
echo "<p>Statist ics successfully added to the Statistics database.</p>";
}
}
}
[/PHP]
Here is the contents of the connection file: its only on a testing server locally to my machine so don't have a go at me for using the username and password as root. lol
[PHP]
//Constants saves repeating data, usernames etc throught the pages.
$dbuser = "root";
$pw = "root";
$dbase = "cbags";
$db = "localhost" ;
//connection string
$connection = mysql_connect($ db, $dbuser, $pw);
[/PHP]
Thank you in advance fr your help.
Tom
9 1991
Problem Solved I had a typo in my code that no matter how many times I looked I could not see it.
And the error was not shown on screen as the verion of MAMP I have for the mac does not have errors set to display in the php.ini
Good yoiu found it yourself. See you next time.
Ronald
Markus 6,050
Recognized Expert Expert
What line was this typo on?
I'm intruiged :D
The error was on line 40 and it was the reference was "sablefordpoint s" which should have been "stablefordpoin ts" but no matter how long I looked at the code I could not work it out.
But the very second I clicked submit to post the question and re read my post I noticed it.
If you are wondering what the script is for its to track golf statistics for your round of golf so I can track if I myself and friends are improving etc with also a built in handicap calculator.
Once I get everything sorted I may also open it up to the rest of the world!
Tom
Markus 6,050
Recognized Expert Expert
Ah!
It happens to the best of us!
Ever need any help, post back here.
Regards, markus.
I thought it was here--
othe r,sablefordpoin ts,...
Markus 6,050
Recognized Expert Expert
I thought it was here--
othe r,sablefordpoin ts,...
If you mean the space in 'other' then no, thats just the way the code has been formatted.
I think I had better be more succinct...
The code at line 40 will not execute correctly. The field name 'other' has a space in it between 'othe' and 'r'. This will break on execution.
It appears not to be simply a newline inserted by the code tags to me. Am I missing something? Search on 'othe ' (that is, 'othe<space>' to find it.
Also, their are nomenclature discrepancies that are suspect too. Is it 'sableford' or 'stableford'?
Try executing the SQL directly into the database and see if it works then paste it into your code.
Markus 6,050
Recognized Expert Expert
I think I had better be more succinct...
The code at line 40 will not execute correctly. The field name 'other' has a space in it between 'othe' and 'r'. This will break on execution.
It appears not to be simply a newline inserted by the code tags to me. Am I missing something? Search on 'othe ' (that is, 'othe<space>' to find it.
Also, their are nomenclature discrepancies that are suspect too. Is it 'sableford' or 'stableford'?
Try executing the SQL directly into the database and see if it works then paste it into your code.
As has already been said, the error was with 'sableford'.
The spacing that you see throughout the code is done by how it has been copied and pasted into here. I.e, it won't be apparent in his code.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Simon |
last post by:
Hi,
I am having a little problem with my PHP - MySQl code, I have two tables
(shown below) and I am trying populate a template page with data from both.
<disclaimer>Now I would like to say my skills, especially with MySQL are
rudimentary</disclaimer> However my code (link below) fails, the nested
database call does not return any data and this has me stumped. Any help
will be much appreciated.
Many thanks in advance
|
by: Lenz Grimmer |
last post by:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
MySQL 4.0.14, a new version of the popular Open Source/Free Software
Database, has been released. It is now available in source and binary form
for a number of platforms from our download pages at
http://www.mysql.com/downloads/ and mirror sites.
|
by: Mike Chirico |
last post by:
Interesting Things to Know about MySQL
Mike Chirico (mchirico@users.sourceforge.net)
Copyright (GPU Free Documentation License) 2004
Last Updated: Mon Jun 7 10:37:28 EDT 2004
The latest version of this document can be found at:
http://prdownloads.sourceforge.net/souptonuts/README_mysql.txt?download
|
by: Saqib Ali |
last post by:
I have created 2 tables in my MySQL database. A_TAB and B_TAB.
They have auto-incrementing integer primary keys respectively named
A_ID & B_ID.
When I created B_TAB, I declared a field named A_ID which references
A_TAB.AID.
I insert valid data into both tables. However, the foreign key
constraint is NOT being enforced. The database allows be to enter any
integer into B_TAB.AID regardless of weather that value exists
anywhere in the...
|
by: Karam Chand |
last post by:
Hello
I have been working with Access and MySQL for pretty
long time. Very simple and able to perform their jobs.
I dont need to start a flame anymore :)
I have to work with PGSQL for my companies current
project.
I have been able to setup postgresql in my rh box and
| |
by: jlee |
last post by:
I'm pretty much a newbie on mysql, and I need some help.
I am running mysql Ver 12.22 Distrib 4.0.24, for portbld-freebsd5.4
(i386) on a server hosting an active website.
The site's developer uses his own php shopping cart to receive customer
orders.
The configuration was done via cPanel with no external modifications -
which produced no protests when built, ran and connected with no
|
by: josie23 |
last post by:
Egad,
I'm not a coder/programmer by nature or occupation but understand things like html and css and a small amount of perl. So, basically, I'm a perl/mysql imbecile.
But, I've been trying to find syntax to insert values into a mysql database table. I'm able to use the below syntax to insert hard-coded values like 'josie' and 'smith' but can't find working syntax to insert $scalar data from another file (which is really what perl-mysql is...
|
by: Atli |
last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users.
Anyone should be able to get through this without much trouble. Programming knowledge is not required.
Index
What is SQL?
Why MySQL?
Installing MySQL.
Using the MySQL command line interface
|
by: ssnaik84 |
last post by:
Hi Guys,
Last year I got a chance to work with R&D team, which was working on DB scripts conversion..
Though there is migration tool available, it converts only tables and constraints..
Rest of things (stored procedures, functions).. we have to manually edit.
That time, we face some interesting challenges.. I failed to document all of them, but whatever I can share with u.. I will try.. :)
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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...
| |
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: 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...
|
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...
| |