Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

help with error please php

Posted on 2011-03-15
5
Medium Priority
?
276 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

618 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