|
lukeer wrote: Is there a bash way to achieve this?
echo foobar > /dev/ttyS0
Use the best guess
|
|
|
|
|
Hello,
I am pretty new to php and i am trying my hands on something little but i"m getting a persistent error.
I am trying to insert a record into the database but i keep getting the error saying the record wasn't inserted.
i checked the databse and there's really nothing there.
Below is the php code. Please let me know the error and guide me through the changes.
<?php
$host = 'localhost';
$user = 'admin';
$password = '12345';
$database = 'staff_db';
$conn = mysql_connect($host,$user,$password) or die('Error: Could not connect to database - '.mysql_error());
mysql_select_db($database,$conn) or die('Error in selecting the database: '.mysql_error());
$title = mysql_real_escape_string(filter_var(trim($_POST['Title']), FILTER_SANITIZE_STRING));
$fname = mysql_real_escape_string(filter_var(trim($_POST['FirstName']), FILTER_SANITIZE_STRING));
$mdname = mysql_real_escape_string(filter_var(trim($_POST['MiddleName']), FILTER_SANITIZE_STRING));
$lname = mysql_real_escape_string(filter_var(trim($_POST['LastName']), FILTER_SANITIZE_STRING));
$res_add = mysql_real_escape_string(filter_var(trim($_POST['Resid_Add']), FILTER_SANITIZE_STRING));
if(! $res_tel = mysql_real_escape_string(filter_var(trim($_POST['Resid_Tel']), FILTER_SANITIZE_NUMBER_INT)))
{
echo 'Please enter a valid telephone number.';
};
if(! $mobile = mysql_real_escape_string(filter_var(trim($_POST['Mobile']), FILTER_SANITIZE_NUMBER_INT)))
{
echo 'Please enter a valid mobile number.';
die();
};
if(! $email = filter_var(trim($_POST['Email']), FILTER_VALIDATE_EMAIL))
{
echo 'Please enter a valid email.';
die();
}
$sql = 'INSERT INTO `$database`.`Emp_Details` (
`Title` ,
`First_Name` ,
`Middle_Name`,
`Last_Name` ,
`Res_Add` ,
`Res_Tel` ,
`Mobile` ,
`Email`
)
VALUES (".$title." , ".$fname." , ".$mdname.", ".$lname.", ".$res_add.", ".$res_tel.", ".$mobile.", ".$email.")';
if(mysql_query($sql))
{
echo 'User information saved successfully.';
}else
{
echo 'Error: We encountered an error while inserting the new record.';
}
mysql_close($conn);
?>
Thanks.
|
|
|
|
|
You should use mysql_error() to see the reason why the query failed, but my guess is that it will say something like "table $database.Emp_Details does not exist".
You have used single quotes to surround your query, but PHP does not replace variables inside a single-quoted string - use double-quotes, or concatenate strings using the "." operator.
|
|
|
|
|
Thank you for your response.
I have tried what you said but its still not working.
|
|
|
|
|
What does the error message you got from mysql_error() say?
If you converted the outer quotes to double-quotes, did you then single-quote the values in the query?
|
|
|
|
|
thanks soo much for your help graham..... i got it now. Thanks
|
|
|
|
|
Transactions ID and Quantity is working! But tax, shipping and Revenue not working!
This is my php code:
<?php
$gaorder="<script type='text/javascript'> ";
$gaorder=$gaorder."var _gaq = _gaq || []; ";
$gaorder=$gaorder."_gaq.push(['_setAccount', 'UA-32542684-1']); ";
$gaorder=$gaorder."_gaq.push(['_trackPageview']); ";
$tax=($totalCost/100)*5;
$gaorder=$gaorder."_gaq.push(['_addTran','".$code_order."','haxata.com','".$totalCost."','".$tax."','0','ThanhPho','Tinh','VietNam']); ";
global $db;
$db->getConnect();
while($row = mysql_fetch_array($result))
{
$gaorder=$gaorder."_gaq.push(['_addItem','".$code_order."','".$row[Product]."','".$row[Name]."','".$row[Name]."','".$row[Cost]."','".$row[Number]."']); ";
}
$db->closeConnect();
$gaorder=$gaorder."_gaq.push(['_trackTrans']); ";
$gaorder=$gaorder."(function() {";
$gaorder=$gaorder."var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ";
$gaorder=$gaorder."ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';";
$gaorder=$gaorder."var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);";
$gaorder=$gaorder."})();";
$gaorder=$gaorder."</script>";
echo $gaorder;
?>
Please help me! thank you so much!
|
|
|
|
|
I would like to get the sum of all the fields in columns. where columns are dynamic even the rows are dynamic.
Hi here in my table the user can add column's dynamically, so i won't be knowing the columns name to raw code initially as $row['SUM(price)']. Hence I need a query which can pull by itself all the column values
|
|
|
|
|
Even if you don't know how many column and how many rows are there going to be even though you can establish certain rule. Try to establish the rule. and you can browse all row and column through javascript
I wish I could believe there is an after life.
|
|
|
|
|
how to implement like this:
$classname = "dsa";$ob = new $classname();
i just have a var of the class name and how to new the class?
|
|
|
|
|
You have the right syntax for doing that in your example.
There are some helpful functions for working with classes: Class functions[^].
The class_exists[^] function is useful for checking if you have a valid class name.
|
|
|
|
|
|
Hello masters of web developing. I have an average experience in C# and I like to know that how much does it take to be a great developer in PHP by considering that I put my time on this 24/7. Why I didn't choose ASP.NET is that I think it is much time consuming than learning PHP and I like to work with current famous CMSes like Wordpress and Drupal.
|
|
|
|
|
How long is a piece of string?
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Tie both ends together and ask again!
"I had the right to remain silent, but I didn't have the ability!"
Ron White, Comedian
|
|
|
|
|
In my php file called "account.php" I have
<html>
<body>
<link rel="icon" type="image/gif" href="favicon.gif" />
<div id="main-box">
<ul>
<li class="buttons">
="button"="account"="Get Your Account"="#"
</li>
</ul>
</div>
</body>
</html>
I want it so when the user clicks the button, a text box appears and displays ONE line from the text file and when they view it, it deletes it from the text file.
text.txt
Eddie
Apples
Hello
People
So after the user clicks the button it displays "Eddie" line to them and then deletes it after the user sees it so that the next line "Apples" would then become the first line.
If you don't understand my question then please let me know and I will try to explain further. Thank you. 
|
|
|
|
|
|
Hi,
I have a table fetched using ajax, according to the choice made from my dropdown menu. In the table I have some input fields. I need to save my inputs in the table while submitting it.
If I check the source code of the page I cannot find the table fields to post using $_post since ajax is used. I am really new to ajax. Can anybody please tell me how I can submit these table input values in PHP?
Thanks in advance
|
|
|
|
|
I want to make a messageboard with php.
but I cant't insert data to database.
I dont know what's wrong in my code???
Can someone help me please?
<!DOCTYPE HTML>
<html>
<head>
<title> 留言板 </title>
</head>
<body>
<form action="insert.php" method="get">
請輸入名稱: <input type="text" name="name" />
請輸入標題: <input type="text" name="title" />
請輸入留言: <input type="text" name="message" />
請輸入電子郵件: <input type="text" name="email" />
<input type="submit" value="送出留言" name="post" />
</form>
</body>
</html>
<?php
require_once("connectdb.php");
if(isset($_GET["name"])!=""){
$query_insert = "INSERT INTO '1100108128'.'MB'
('USER','TITLE','MESSAGE','TIME','EMAIL')
VALUES (";$query_insert .= "'".$_GET["name"]."',";
$query_insert .= "'".$_GET["title"]."',";
$query_insert .= "'".$_GET["message"]."',";
$query_insert .= "NOW(),";
$query_insert .= "'".$_GET["email"]."')";
mysql_query($query_insert);
header("Location:Messageboard.php");
}
?>
|
|
|
|
|
replace
mysql_query($query_insert);
with
mysql_query($query_insert) or die('Error occured: ' . mysql_error());
Than reply with the output.
|
|
|
|
|
navigate data from database in webpage without page refresh
|
|
|
|
|
I make a little login example...
In the index.php :
<html>
<head>
<!--
</head>
<body>
Username:<input id="input-username" type="text" maxlength="100" />
Password:<input id="input-password" type="password" maxlength="16" />
<input id="btn-ok" type="button" value="OK" />
</body>
<script type="text/javascript">
$('#btn-ok').click(function() {
var DataToSend = new Object();
DataToSend.username = $('#input-username').val();
DataToSend.password = $('#input-password').val();
$.post('validate.php',DataToSend,function(data) {
if(data == 'ok')
alert('Login OK!');
else
alert('Login ERROR!');
});
});
</script>
</html>
You just make a post to a php file "validate.php" and there you validate the login, and make querys to the DataBase and return a value, and you are doing that all without refresh the page!
Any question, add me on gtalk: miguel.poegel@pears.fr
Regards,
KZ
|
|
|
|
|
ques 1: Php how can Multiple selected List box items move from one list box to another list box?
ques 2:Instead of Submit button how can i use Button or Any thing which do process like insert / update / delete /select without refresh the page?
navigate the data without page refresh how can i achieve in easy way?
|
|
|
|
|
You can use javascript... without refresh the page...
|
|
|
|
|
hi all.
I want get data form url when use header('location:'.$url) then it rederect to another url.
how to get data when using header('location:'.$url) ???
thanks
nothing
|
|
|
|