Data not submitting to database

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 1020 Views - Last Post: 19 January 2013 - 03:44 AM Rate Topic: -----

#1 danbywinby  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 06-January 13

Data not submitting to database

Posted 18 January 2013 - 09:08 AM

Hi

When i go onto my website and try and submit some data into my database it is not submitting and i do not know why. However i am very confident that the problem is somewhere in the following code:

<div class='Map'>


				<img  src='http://n.vdsh.net/hosting/Dan/JWT/images/ets2_map.png'/>
				<?
				$host="localhost"; // Host name
				$username="root"; // Mysql username
				$password="********"; // Mysql password
				$db_name="DansDB"; // Database name
				$tbl_name="DansMap"; // Table name

				mysql_connect("$host", "$username", "$password")or die("cannot connect");
				mysql_select_db("$db_name")or die("cannot select DB");
	
				$sql= "SELECT * FROM $tbl_name";
				$Result = mysql_query($sql);
		
				function getUser($ID)
				{
				$tbl_name2="jwtmembers"; // Table name
				$User = "SELECT Name FROM $tbl_name2 WHERE id = $ID";
				$UserQ = mysql_query($User);
				$UserN = mysql_fetch_array($UserQ);
				return $UserN[0];
				}
	
				while($row = mysql_fetch_array($Result))
				{
				echo "<div class='Marker' onmouseout='hideCommet(".$row['id'].")'  onmouseover='ShowCommet(".$row['id'].")' style='left:".$row['x']."px;top:".$row['y']."px'></div>";
				echo "<div id='".$row['id']."'onmouseout='hideCommet(".$row['id'].")'  onmouseover='ShowCommet(".$row['id'].")' style='left:".$row['x'] ."px;top:".$row['y']  ."px' class='CommentD'><div class='ComUser'>".getUser($row['User'])."</div><div class='ComboxCom'>".$row['Comment']."</div></div>";
				}
				?>
			
			</div>
			
			<div class='Modal'>
	
				Division: <input type="text" id="division"><br>
				Truck: <input type="text" id="truck"><br>
				Cargo: <input type="text" id="cargo"><br>
				Departing from: <input type="text" id="departure"><br>
				Destination: <input type="text" id="destination"><br>
				<button  onclick='Add2db()'>Submit</button>
				<button  onclick='closeMod()'>Close</button>
				<div class='c'></div>
				
			</div>
			
			<!-- Toby Stuff End -->
	
	<!-- Toby Stuff -->
	
		<script>
<?
	if($In == "1")
	{
		echo ""?>
		var relativeX 
    var relativeY
	$(".Map ").click(function(e){
     relativeX = e.pageX - this.offsetLeft;
     relativeY = e.pageY - this.offsetTop;
	$(".Map").append("<div class='NMarker'></div>");
	$(".NMarker").css("left",relativeX);
	$(".NMarker").css("top",relativeY);
	
	$(".Modal").show();
	$(".Modal").css("left",relativeX +200);
	$(".Modal").css("top",relativeY +10);
	});


function Add2db()
{

var division = $("#division").val()
var truck = $("#truck").val()
var cargo = $("#cargo").val()
var departure = $("#departure").val()
var destination = $("#destination").val()
var Mod = $(".Modal").clone()
var Stuff
$(".Modal").html("<img src='http://n.vdsh.net/hosting/Resources/loaders/Loader1.gif' alt='loader'/>")
	$.ajax
	({ 
			url: 'AddMarkerMap.php',
			data: 
			{
			division: division,
			truck: truck,
			cargo: cargo,
			departure: departure,
			destination: destination,
			x:relativeX,
			y:relativeY
			},
			type: 'post',
			success: function(output) 
			{
			Stuff = output;
				if(output == "1")
				{
					$(".Modal").html(Mod)
					$(".Modal").hide();
				}
				else if(output == "3")
				{
					alert("Username Blank")
				}
				else if(output == "4")
				{
					alert("No Username")
				}
				else
				{
					alert(output)
					$(".Modal").hide();
				}
			}
	})
}
		
	
	<?"";
	}?>
	function closeMod()
{
	$(".Modal").hide();
}
function ShowCommet(id)
{
	$("#"+id).show()
}
function hideCommet(id)
{
	$("#"+id).hide()
}
	</script>
	
	<!-- Toby Stuff End -->
	
</body>
</html>



If i have posted this in the wrong place then i apologise but i used my best judgement and decided to post it here, also if you need to see some more of my code then please feel free to ask and i shall provide more of it.

Thank You

Is This A Good Question/Topic? 0
  • +

Replies To: Data not submitting to database

#2 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3480
  • View blog
  • Posts: 10,032
  • Joined: 08-June 10

Re: Data not submitting to database

Posted 18 January 2013 - 09:15 AM

you are right that this code does not submit data into your database. simply because there is no such database query. the only queries I see are SELECT queries that fetch data.

you should check the AddMarkerMap.php instead (thatís the file that gets the data submitted).

PS. there are a lot of things to be said about the given code

PPS. use error handling to find out whatís wrong.
Was This Post Helpful? 0
  • +
  • -

#3 danbywinby  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 06-January 13

Re: Data not submitting to database

Posted 18 January 2013 - 09:24 AM

But the code was all working fine before i took out a 'comment' text area and added in the 'division', 'truck', 'cargo', 'departure' and 'destination' text inputs.

Also the code that i posted before is only a part of the code for the webpage.
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3480
  • View blog
  • Posts: 10,032
  • Joined: 08-June 10

Re: Data not submitting to database

Posted 18 January 2013 - 09:32 AM

View Postdanbywinby, on 18 January 2013 - 05:24 PM, said:

But the code was all working fine before i took out a 'comment' text area and added in the 'division', 'truck', 'cargo', 'departure' and 'destination' text inputs.

even the more reason to check the file I pointed out. if you change the input structure and leave the processing code be, it is bound to fail (tbh, who builds a data check into his code? *)



* - irony!
Was This Post Helpful? 0
  • +
  • -

#5 danbywinby  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 06-January 13

Re: Data not submitting to database

Posted 18 January 2013 - 09:36 AM

Ok well here is the file you asked for:

<?
	session_start(); 
	$host="localhost"; // Host name
	$username="******"; // Mysql username
	$password="*************"; // Mysql password
	$db_name="DansDB"; // Database name
	$tbl_name="DansMap"; // Table name
	
	mysql_connect("$host", "$username", "$password")or die("cannot connect");
	mysql_select_db("$db_name")or die("cannot select DB");
	
	if(isset ($_SESSION["UserM"]))
	{
		$un = $_SESSION["UserM"];
	}
	else
	{
	$un =="";
		echo "4";
	}
	
	if($un == "")
	{
		echo "3";
	}
	else
	{
		$division = htmlspecialchars(stripslashes(mysql_real_escape_string($_POST['division'])));
		$truck = htmlspecialchars(stripslashes(mysql_real_escape_string($_POST['truck'])));
		$cargo = htmlspecialchars(stripslashes(mysql_real_escape_string($_POST['cargo'])));
		$departure = htmlspecialchars(stripslashes(mysql_real_escape_string($_POST['departure'])));
		$destination = htmlspecialchars(stripslashes(mysql_real_escape_string($_POST['destination'])));
		$date = gmdate("Y-m-d H:i:s");
		$x = htmlspecialchars(stripslashes(mysql_real_escape_string($_POST['x'])));
		$y = htmlspecialchars(stripslashes(mysql_real_escape_string($_POST['y'])));
		$Comment = "";
		
		$Select = "SELECT * FROM $tbl_name WHERE User = '$un'";
		$SelectR = mysql_query($Select);
		$CountS = mysql_num_rows($SelectR);
	
		if($CountS == 0)
		{
			$sql= "INSERT INTO $tbl_name (User,Division,Truck,Cargo,Departing from,Destination,Date,x,y,Comment) VALUES('$un','$division','$truck','$cargo','$departure','$destination','$date','$x','$y','$Comment')";
		}
		else if($CountS == 1)
		{
			$sql= "UPDATE $tbl_name SET Comment ='$Comment' ,Date = '$date' ,x='$x' ,y = '$y' WHERE User = '$un'";
		}
		else
		{
			$remove = "DELETE FROM $tbl_name WHERE User = '$un'";
			$RemoveQ = mysql_query($remove);
			$sql= "INSERT INTO $tbl_name (User,Division,Truck,Cargo,Departing from,Destination,Date,x,y,Comment) VALUES('$un','$division','$truck','$cargo','$departure','$destination','$date','$x','$y','$Comment')";
		}
		
		$Result = mysql_query($sql);
		
		if($Result)
		{
			echo "1";
		}
		else
		{
			mysql_error();
		}
	}
?>


Was This Post Helpful? 0
  • +
  • -

#6 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3480
  • View blog
  • Posts: 10,032
  • Joined: 08-June 10

Re: Data not submitting to database

Posted 18 January 2013 - 09:54 AM

you need to do some debugging:
- are the input/output data what you expect?
- do you have error checking everywhere?

PS. instead of the separate insert/update queries you can use
INSERT Ö ON DUPLICATE KEY UPDATE Ö
(though that requires that you have a KEY defined)
Was This Post Helpful? 1
  • +
  • -

#7 danbywinby  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 06-January 13

Re: Data not submitting to database

Posted 18 January 2013 - 10:32 AM

I'm not getting any output data at all.

I input the data in then i get the ajax spinny red thing then i get a blank popup. If you need to access it to do some debugging or whatever then you can access it on this page http://dan.vdsh.net/...ivertracker.php however you will need to login through facebook in order to try and input some data into the database.

In order to use the page once you have loggeed in with facebook just click on the map and then a box will popup with text boxes for you to input data into and then you just click submit. This is where it is failing at the moment because when you click submit it doesnt submit the data i just get a blank alert box.

B.T.W I am not the original creator of the drivertracker bit it was created by a mate and i have just get tried to integrate into my website it was working fine with their just being one box which you use to input data with but for my uses i need several text boxes to put in several bits of data.
Was This Post Helpful? 0
  • +
  • -

#8 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3480
  • View blog
  • Posts: 10,032
  • Joined: 08-June 10

Re: Data not submitting to database

Posted 18 January 2013 - 11:03 AM

View Postdanbywinby, on 18 January 2013 - 06:32 PM, said:

however you will need to login through facebook in order to try and input some data into the database.

I donít have Facebook.
Was This Post Helpful? 2
  • +
  • -

#9 danbywinby  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 06-January 13

Re: Data not submitting to database

Posted 18 January 2013 - 11:07 AM

Sorry about that didnt realise you didnt have facebook erm can you still help me if i just give you the full text of the two files in question?? Please
Was This Post Helpful? 0
  • +
  • -

#10 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3480
  • View blog
  • Posts: 10,032
  • Joined: 08-June 10

Re: Data not submitting to database

Posted 18 January 2013 - 11:13 AM

no problem, itís not obvious I donít have Facebook.

the files alone donít help. I would also have to install the DB (which I doubt Iíll do). what you have to do is dump all sensible data and check the resulting Response (all sensible debuggers allow you to look at the data of an AJAX request directly).

note: as of PHP 5.4 the old and outdated mysql extension is deprecated.
Was This Post Helpful? 0
  • +
  • -

#11 danbywinby  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 06-January 13

Re: Data not submitting to database

Posted 18 January 2013 - 11:18 AM

drivertracker.php
<?php
session_start(); 

if(isset($_SESSION["FBUserM"])&& isset($_SESSION["FBNameM"])&&isset($_SESSION["UserM"]))
{
	$In = "1";

}
else
{
	$In = "0";
	
}


?>
<!DOCTYPE html>

<html lang="en">

<head>

	<!-- Toby Stuff -->
	<link  href='http://n.vdsh.net/hosting/resources/generic.css' rel='stylesheet'/>
	<script src="http://code.jquery.com/jquery-latest.js"></script>
	<link  href='http://n.vdsh.net/hosting/dan/jwt/driver_log/style.css' rel='stylesheet'/>
	<!-- -->
	
	<meta http-equiv="content-type" content="text/html; charset=utf-8"/>                              <!-- Meta Stuff Required -->
	<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
	<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
	<META HTTP-EQUIV="Expires" CONTENT="-1">
	<link rel="stylesheet" type="text/css" href="styles.css" />                                       <!-- CSS -->
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>               <!-- JQuery -->
	<script src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.latest.js"></script> <!-- Jquery Cycle -->


	<script> <!-- Image/Text rotator requires JQuery Cycle above ^^/>^^ -->
	$('.home-page-slideshow').cycle({
		fx: 'fade',
        timeout: 3000
	});
	</script>
	
	<script>
	var currentTime = new Date()
	var month = currentTime.getMonth() + 1
	var day = currentTime.getDate()
	var year = currentTime.getFullYear()
	</script>
	
	<!-- Appears in the title bar in web browser -->
	<title>
		JWT Haulage Group
	</title>
	
</head>

<body>
	
	<!-- Toby Stuff -->
	
		<div id="fb-root"></div>
		<script src='fb_check.js'></script>
		<script src="//connect.facebook.net/en_US/all.js"></script>
	
		<div class='Header'>
	
			<div id='Header1'>
			
				<div class='floatL'>			
	
				</div>
			
				<div class='floatR'>
				<? if($In ==1)
				{
				echo "
					<div class='userlogedin'>
						<img class=' headerimg' src='https://graph.facebook.com/".$_SESSION["FBUserM"]."/picture?access_token=394088350673080|mC3BHmWdqw0LBil-x2JmW41u_LQ'/>
						<span>
						<div>".$_SESSION["FBNameM"]."</div>
						<p> <a href='logout.php'>Logout</a> </p>
						</span>
					</div>
					";
			
				}
				else {echo""?>
			

				<a class='toplinks' href="javascript:checkfb()">Login</a>
		
			
				<?"";}?>
				
				</div>
				
			</div>
			
		</div>
		
		<div class='c'>
		</div>
	
	<!-- Toby Stuff End -->
	
	<div class='tracker-header'>
	
		<img src="./images/JWT Logo.png" alt="JWT Haulage Group Ltd" width="388px" height="99px">
		
	</div>

	<div class='tracker-container'>
		
		<ul class='navigationbar'>
			
			<li><a href="index.php">Home</a></li>
			<li><a href="news.php">News</a></li>
			<li><a href="#">ETS2</a></li>
			<li><a href="#">UKTS/GTS</a></li>
			<li><a href="drivertracker.php">Driver Tracker</a></li>
			<li><a href="#">Contact</a></li>
				
		</ul>
			
		<div class='content'>
		
			
			
		</div>
		
		<div class='clear'>
		</div>
		
		<div class='tracker-footer'>
		
			<div class='footer-text1'>
			
				<h3>Links:</h3>
				
				<ul class='footer-links'>
				
					<a target="_blank" href="http://www.facebook.com/pages/JWT-Haulage-Group-Ltd-In-Partnership-With-Schumacher-Logisitics-Services/166705200103425?fref=ts" title="Like us on Facebook"><img src='http://n.vdsh.net/hosting/resources/gosocial/png/32/facebook.png' alt="Facebook Page"></img></a>
					<a target="_blank" href="http://plus.google.com/share?url=http://www.jwt-group.co.uk" title="Share me on Google+"><img src='http://n.vdsh.net/hosting/resources/gosocial/png/32/google.png' alt="Google+ Icon"></img></a>
					<a target="_blank" href="http://twitter.com/share?url=http://www.jwt-group.co.uk&amp;text=@JWTHaulageltd%20Been%20driving%20around%20europe%20for%20JWT%20Haulage.%20Come%20and%20join%20me%20at%20www.jwt-group.co.uk" title="Tweet about me"><img src='http://n.vdsh.net/hosting/resources/gosocial/png/32/twitter.png' alt="Twitter Icon"></img></a>
					<a target="_blank" href="http://management.jwthaulage.tk" title="JWT Haulage Management Blog"><img src='http://n.vdsh.net/hosting/resources/gosocial/png/32/blogger.png' alt="JWT Haulage Management Blog"></img></a>
					<a target="_blank" href="http://www.jwthaulageltd.freeforums.org" title="JWT Haulage Forum"><img src='http://n.vdsh.net/hosting/Dan/JWT/images/JWT Forums Logo.png' alt="JWT Haulage Forum"></img></a>
					<a target="_blank" href="http://www.jwthaulagegroupts2.freeforums.org" title="JWT Haulage ETS2 Forum"><img src='http://n.vdsh.net/hosting/Dan/JWT/images/JWT ETS2 Forums Logo.png' alt="JWT Haulage ETS2 Forum"></img></a>
					<a target="_blank" href="http://www.facebook.com/groups/JWTHaulageLtd/" title="Join our driver group on facebook"><img src='http://n.vdsh.net/hosting/Dan/JWT/images/facebook_group.png' alt="Facebook Driver Group"></img></a>
					
				</ul>
				
			</div>
			
			<div class='footer-text2'>
		
				<h5>Copyright &copy; <script>document.write(year)</script> JWT Haulage Group VTC. All rights reserved.</h5>
				
				<script>
					document.write("Date: " + month + "/" + day + "/" + year)
				</script>
				
			</div>
			
			<div class='clear'>
			</div>
			
		</div>
		
	</div>
	
	<!-- Toby Stuff -->
			
			<div class='Map'>


				<img  src='http://n.vdsh.net/hosting/Dan/JWT/images/ets2_map.png'/>
				<?
				$host="localhost"; // Host name
				$username="root"; // Mysql username
				$password="ed9e4afe98!"; // Mysql password
				$db_name="DansDB"; // Database name
				$tbl_name="DansMap"; // Table name

				mysql_connect("$host", "$username", "$password")or die("cannot connect");
				mysql_select_db("$db_name")or die("cannot select DB");
	
				$sql= "SELECT * FROM $tbl_name";
				$Result = mysql_query($sql);
		
				function getUser($ID)
				{
				$tbl_name2="jwtmembers"; // Table name
				$User = "SELECT Name FROM $tbl_name2 WHERE id = $ID";
				$UserQ = mysql_query($User);
				$UserN = mysql_fetch_array($UserQ);
				return $UserN[0];
				}
	
				while($row = mysql_fetch_array($Result))
				{
				echo "<div class='Marker' onmouseout='hideCommet(".$row['id'].")'  onmouseover='ShowCommet(".$row['id'].")' style='left:".$row['x']."px;top:".$row['y']."px'></div>";
				echo "<div id='".$row['id']."'onmouseout='hideCommet(".$row['id'].")'  onmouseover='ShowCommet(".$row['id'].")' style='left:".$row['x'] ."px;top:".$row['y']  ."px' class='CommentD'><div class='ComUser'>".getUser($row['User'])."</div><div class='ComboxCom'>".$row['Comment']."</div></div>";
				}
				?>
			
			</div>
			
			<div class='Modal'>
	
				Division: <input type="text" id="division"><br>
				Truck: <input type="text" id="truck"><br>
				Cargo: <input type="text" id="cargo"><br>
				Departing from: <input type="text" id="departure"><br>
				Destination: <input type="text" id="destination"><br>
				<button  onclick='Add2db()'>Submit</button>
				<button  onclick='closeMod()'>Close</button>
				<div class='c'></div>
				
			</div>
			
			<!-- Toby Stuff End -->
	
	<!-- Toby Stuff -->
	
		<script>
<?
	if($In == "1")
	{
		echo ""?>
		var relativeX 
    var relativeY
	$(".Map ").click(function(e){
     relativeX = e.pageX - this.offsetLeft;
     relativeY = e.pageY - this.offsetTop;
	$(".Map").append("<div class='NMarker'></div>");
	$(".NMarker").css("left",relativeX);
	$(".NMarker").css("top",relativeY);
	
	$(".Modal").show();
	$(".Modal").css("left",relativeX +200);
	$(".Modal").css("top",relativeY +10);
	});


function Add2db()
{

var division = $("#division").val()
var truck = $("#truck").val()
var cargo = $("#cargo").val()
var departure = $("#departure").val()
var destination = $("#destination").val()
var Mod = $(".Modal").clone()
var Stuff
$(".Modal").html("<img src='http://n.vdsh.net/hosting/Resources/loaders/Loader1.gif' alt='loader'/>")
	$.ajax
	({ 
			url: 'AddMarkerMap.php',
			data: 
			{
			division: division,
			truck: truck,
			cargo: cargo,
			departure: departure,
			destination: destination,
			x:relativeX,
			y:relativeY
			},
			type: 'post',
			success: function(output) 
			{
			Stuff = output;
				if(output == "1")
				{
					$(".Modal").html(Mod)
					$(".Modal").hide();
				}
				else if(output == "3")
				{
					alert("Username Blank")
				}
				else if(output == "4")
				{
					alert("No Username")
				}
				else
				{
					alert(output)
					$(".Modal").hide();
				}
			}
	})
}
		
	
	<?"";
	}?>
	function closeMod()
{
	$(".Modal").hide();
}
function ShowCommet(id)
{
	$("#"+id).show()
}
function hideCommet(id)
{
	$("#"+id).hide()
}
	</script>
	
	<!-- Toby Stuff End -->
	
</body>
</html>



AddMarkerMap.php
<?
	session_start(); 
	$host="localhost"; // Host name
	$username="root"; // Mysql username
	$password="ed9e4afe98!"; // Mysql password
	$db_name="DansDB"; // Database name
	$tbl_name="DansMap"; // Table name
	
	mysql_connect("$host", "$username", "$password")or die("cannot connect");
	mysql_select_db("$db_name")or die("cannot select DB");
	
	if(isset ($_SESSION["UserM"]))
	{
		$un = $_SESSION["UserM"];
	}
	else
	{
	$un =="";
		echo "4";
	}
	
	if($un == "")
	{
		echo "3";
	}
	else
	{
		$division = htmlspecialchars(stripslashes(mysql_real_escape_string($_POST['division'])));
		$truck = htmlspecialchars(stripslashes(mysql_real_escape_string($_POST['truck'])));
		$cargo = htmlspecialchars(stripslashes(mysql_real_escape_string($_POST['cargo'])));
		$departure = htmlspecialchars(stripslashes(mysql_real_escape_string($_POST['departure'])));
		$destination = htmlspecialchars(stripslashes(mysql_real_escape_string($_POST['destination'])));
		$date = gmdate("Y-m-d H:i:s");
		$x = htmlspecialchars(stripslashes(mysql_real_escape_string($_POST['x'])));
		$y = htmlspecialchars(stripslashes(mysql_real_escape_string($_POST['y'])));
		$Comment = "";
		
		$Select = "SELECT * FROM $tbl_name WHERE User = '$un'";
		$SelectR = mysql_query($Select);
		$CountS = mysql_num_rows($SelectR);
	
		if($CountS == 0)
		{
			$sql= "INSERT INTO $tbl_name (User,Division,Truck,Cargo,Departing from,Destination,Date,x,y,Comment) VALUES('$un','$division','$truck','$cargo','$departure','$destination','$date','$x','$y','$Comment')";
		}
		else if($CountS == 1)
		{
			$sql= "UPDATE $tbl_name SET Comment ='$Comment' ,Date = '$date' ,x='$x' ,y = '$y' WHERE User = '$un'";
		}
		else
		{
			$remove = "DELETE FROM $tbl_name WHERE User = '$un'";
			$RemoveQ = mysql_query($remove);
			$sql= "INSERT INTO $tbl_name (User,Division,Truck,Cargo,Departing from,Destination,Date,x,y,Comment) VALUES('$un','$division','$truck','$cargo','$departure','$destination','$date','$x','$y','$Comment')";
		}
		
		$Result = mysql_query($sql);
		
		if($Result)
		{
			echo "1";
		}
		else
		{
			mysql_error();
		}
	}
?>



View PostDormilich, on 18 January 2013 - 11:13 AM, said:

no problem, itís not obvious I donít have Facebook.

the files alone donít help. I would also have to install the DB (which I doubt Iíll do). what you have to do is dump all sensible data and check the resulting Response (all sensible debuggers allow you to look at the data of an AJAX request directly).

note: as of PHP 5.4 the old and outdated mysql extension is deprecated.


Damn well i dont know what you mean by 'dump all sensible data etc' as i am only a noob at PHP and this drivertracker my mate created for me and im unable to contact him to help me sort this mess out for the next few days so that's why i decided to post on here to see if somebody on here could help but thanks for trying to help me i really appreciate it. I'll just wait for either somebody else to help or i'll just contact my mate when i next can.
Was This Post Helpful? 0
  • +
  • -

#12 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3480
  • View blog
  • Posts: 10,032
  • Joined: 08-June 10

Re: Data not submitting to database

Posted 18 January 2013 - 04:07 PM

View Postdanbywinby, on 18 January 2013 - 07:18 PM, said:

Damn well i dont know what you mean by 'dump all sensible data etc'

var_dump(). e.g. var_dump($_POST);

This post has been edited by Dormilich: 18 January 2013 - 04:08 PM

Was This Post Helpful? 0
  • +
  • -

#13 Slice  Icon User is offline

  • sudo pacman -S moneyz


Reputation: 241
  • View blog
  • Posts: 700
  • Joined: 24-November 08

Re: Data not submitting to database

Posted 18 January 2013 - 08:09 PM

Not sure if this would be an issue, but you use a space in one of your column names.

$sql= "INSERT INTO $tbl_name (User,Division,Truck,Cargo,Departing from,Destination,Date,x,y,Comment) VALUES('$un','$division','$truck','$cargo','$departure','$destination','$date','$x','$y','$Comment')";



Departing from, is that a column you've added yourself? Normally I'd wrap some back-tics around it (`) but I'm not sure if that's necessary when you reference the column inside the parenthesis.

For good practice it's usually best to keep column names one string such as Derparting_From, or DepartingFrom to avoid any query issues down the road.

Oh and you might want to remove your database info from your posted code.
Was This Post Helpful? 0
  • +
  • -

#14 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3480
  • View blog
  • Posts: 10,032
  • Joined: 08-June 10

Re: Data not submitting to database

Posted 19 January 2013 - 01:10 AM

View PostSlice, on 19 January 2013 - 04:09 AM, said:

Departing from, is that a column you've added yourself? Normally I'd wrap some back-tics around it (`) but I'm not sure if that's necessary when you reference the column inside the parenthesis.

it is always necessary to quote a column name that contains invalid characters (space) or reserved keywords (from).
Was This Post Helpful? 0
  • +
  • -

#15 danbywinby  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 06-January 13

Re: Data not submitting to database

Posted 19 January 2013 - 02:54 AM

View PostDormilich, on 18 January 2013 - 04:07 PM, said:

View Postdanbywinby, on 18 January 2013 - 07:18 PM, said:

Damn well i dont know what you mean by 'dump all sensible data etc'

var_dump(). e.g. var_dump($_POST);


Ok and how do i use the var_dump thing to help me solve the problem i am having??

View PostSlice, on 18 January 2013 - 08:09 PM, said:

Not sure if this would be an issue, but you use a space in one of your column names.

$sql= "INSERT INTO $tbl_name (User,Division,Truck,Cargo,Departing from,Destination,Date,x,y,Comment) VALUES('$un','$division','$truck','$cargo','$departure','$destination','$date','$x','$y','$Comment')";



Departing from, is that a column you've added yourself? Normally I'd wrap some back-tics around it (`) but I'm not sure if that's necessary when you reference the column inside the parenthesis.

For good practice it's usually best to keep column names one string such as Derparting_From, or DepartingFrom to avoid any query issues down the road.

Oh and you might want to remove your database info from your posted code.


Ive fixed that now aswell i have changed Departing from to Departure but that still hasnt helped.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2