?
Solved

help with error please php

Posted on 2011-03-15
5
Medium Priority
?
275 Views
Last Modified: 2012-08-14
hi experts, im trying to insert some data into the database but keep getting errors ive attached the code im trying to execute and it returns "ERROR" you can see why when it echo's it on fail.

any help is appricated in debugging it thanks again.

code is attached
<?php
session_start();
ob_start();
?>
<?php 
error_reporting(E_ALL);

$last_spoke_to = $_POST['last_spoke_to'];
$notes = $_POST['notes'];
$val= $_REQUEST['val'];
var_dump($val); 
var_dump($notes); 


include 'myphp.php';


//update the database with the set variables recoverd from the form from the other page. 

$query = "INSERT INTO `notes` (customer_name, notes) VALUES (".$val.",".$notes.");

$result=mysql_query($query);

 if($result){
	header("location:mobilenum.php?val=".$val);
}
else{
	echo "ERROR";
}
mysql_close();

?>


data is sent from this form below 
-----------------------------------

<form name="register" method="post" action="edituploadednotes.php">
<input type="hidden" value="<?php echo $_GET['val']; ?>" name="val" >
<td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
  <tr>
    <td colspan="14" bgcolor="#ffffff"><strong>Edit Notes</strong></td>
  </tr>
  <tr>
    <td width="249" bgcolor="#ffffff">Last spoke to</td>
    <td width="7" bgcolor="#ffffff">:</td>
   <td width="393" bgcolor="#ffffff"><textarea name="last_spoke_to" cols="40" rows="10">
Enter your last spoke to here....
</textarea>
      <br /></td>
  </tr>
  <tr>
    <td width="249" bgcolor="#ffffff">Notes</td>
    <td width="7" bgcolor="#ffffff">:</td>
    <td width="393" bgcolor="#ffffff"><textarea name="notes" cols="40" rows="10">
Enter your notes here....
</textarea>
      <br /></td>
  </tr>
  <td wdith="1298" bgcolor="#ffffff">
  <input type="submit" name="Submit" value="Update" /></td>
  </tr>
</table></td>
</form>

Open in new window

0
Comment
Question by:NeoAshura
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 39

Expert Comment

by:Aaron Tomosky
ID: 35139163
VALUES (".$val.",".$notes.");
Should be
VALUES ("'".$val."','".$notes."'");
And really should wrap Val and notes in mysqlrealescapestrig
0
 
LVL 6

Author Comment

by:NeoAshura
ID: 35139274
Hi there sadly

VALUES ("'".$val."','".$notes."'");

is incorrect and is not correct syntax i tried to change the " and the ' but nothing worked.
0
 
LVL 14

Accepted Solution

by:
Scott Madeira earned 1000 total points
ID: 35139756
You have an extra " in there. Try this....

VALUES ('".$val."','".$notes."')";
0
 
LVL 6

Author Comment

by:NeoAshura
ID: 35139871
ok the insert works but when i try to query the database to get the output i get errors.

here is my query to try and get output stored in two tables.

can you help me please? im trying to extract all data from both tables. based on the variable passed.

$sql = "SELECT * FROM customer, notes WHERE customer_name = '" . $val . "'";

it says my query is ambiguous. any ideas?

0
 
LVL 6

Author Closing Comment

by:NeoAshura
ID: 35146619
Answered the bug error i was having.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question