Solved

help with error please php

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Encode a password 2 38
How can I do this in Pyhton? 12 72
WooCommerce Sort by Date 4 10
Adding Extra Information box 4 25
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now