Solved

help with error please php

Posted on 2011-03-15
5
272 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 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

739 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