Solved

help with error please php

Posted on 2011-03-15
5
270 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
  • 3
5 Comments
 
LVL 38

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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.

773 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