Is it possible to assign php array in MySQL IN() function? for example,
$numbers = array('8001254656','8886953265','88864357445','80021536245');
$sql = mysql_query("SELECT * FROM `number_table` WHERE `number` IN ($numbers)");
Any Ideas?
Thanks,
Hi everyone,
Will there be any measurable performance difference when passing data as values instead of as reference in PHP?
It seems like few people are aware of that variables can be passed as values instead of references. Is this common sense or not?
Hi all,
I have a html form that sends the data from 2 fields (memer no. , pw) via axaj (getElementById)to php file to check them with database info. . I did every thing well but I want to reset both fields if one of them is incorrect . How can I send reset order back to html form ?
notice - I didn't use submit button just normal button to keep in same page.
Thanks all
I am building a PHP and MySQL search as so
SELECT * FROM Properties WHERE Locaion = 'Liverpool'
I want to count how many of each property type there are and display them at the side of the page to use as filters (like Rightmove.co.uk).
This is what I am have come up with but can't get it to work
SELECT *,
count(PropertyType = 'house') AS HouesTotal,
count(PropertyType = 'Apartment') AS ApartmentTotal
FROM Properties WHERE Location = 'Liverpool'
Can anyone help?
Hi everyone,
I am in the middle of building a cache layer for the Redis DB to my application and I have come to the point where's it's about to take care of arrays.
I wonder if there's any good (high performance!) way of controlling an string to be serialized or not with PHP?
Thanks a lot!
I have searched but could not get solution on this issue.
I am working on an application which will generate unknown number of items and have users select the quantity from a drop down against each item. Eg.
Item(s) | price | Select qty
Rice 23 3
Beans 22 4
Eggs 52 5
...
...
...
unknown
Please, how can I capture the above in an array and also calculate the total value for all selected items and corresponding fees?
I have the following HTML code:
<form id='form1' name='form1' method='post' action='item_calc.php'>
<?php
.....
while($t_row = mysql_fetch_assoc($get_items)) {
echo "<p><label>$t_row['$item_name']
<input type='text' READONLY name='item_price[]' value='$t_row['$item_price']' /></label>
<input type='text' READONLY name='item_fees[]' value='$t_row['$item_fee']' />
<select name="item_qty">
<option value="1">
<option value="2">
<option value="3">
<option value="4">
<option value="5">
</select>
</p><p>";
}
echo "<label><input type='submit' name='submit' value='Submit' /></label></p>
</form>";
Please, how can I get item_price[] + item_fees[] * item_qty for all selected items?
This is what I have tried:
for ($i = 0; $i < count($_POST['item_price']); $i++) {
// Do something here with $_POST['checkbx'][$i]
foreach ($_POST['item_fees'] as $tkey => $tvalue) {
//echo "Key: $tkey; Value: $tvalue<br>";
}
foreach ($_POST['item_price'] as $pkey => $pvalue) {
//echo "Key: $pkey; Value: $pvalue<br>";
}
$total = $tvalue + $pvalue;
}
echo $total;
Hello, I'm a web services newbie and I've tried to learn it looking for tutorials in google... but I didn't found anything really helpfull...
Do you know any tutorial / web page / documentation for web services using PHP 5 native SOAP client? I need to implement a SOAP client for fetch/send data from a IIS server (for hotels reservations).
Is there some server that I can make tests with?
Thank you!
I cant seem to send an email using PHP's mail(). I have also tried PHPMailer and Swiftmail with no success. However, the following command on the server delivers mail successfully.
cat test.txt | mail -s "test mail" [email protected]
Is there a way to trace where the problem is coming from? mail() just seems to return true or false.
I was wondering how can I validate a single checkbox using PHP and MySQL.
Here is the HTML.
<input type="checkbox" name="privacy_policy" id="privacy_policy" value="yes" />
I am very inexperienced with PHP and I've having trouble calling a mootools function.
Here's my code:
echo '<script language="JavaScript">';
echo "Sexy.error('Test!');";
echo '</script>';
When I try it with a simple alert('test') it works just fine.. I'm confused?!?
Hi All
Currently developing a PHP framework and have ran into my first problem. I need to be able to drop the framework into any folder on a server, no matter how many folders deep, and need to find that directory to use as a base URL.
For example, it currently works if I put the framework in the root of the server (http://cms.dev/), but if I were to put it in http://cms.dev/folder/ it does not work.
Please advise, any comments welcome.
BenTheDesigner
What PHP code can I use to stop showing text at a certain time?
For example:
"Come to this event at 3PM on Monday!"
I don't want that to show after 3:01PM on the site.
what is the best way to make my php code working on one domain
and sure i will encode the whole code by ioncube
i want function like
function domain(){
}
if($this_domain <> domain()){
exit('no');
}
or
$allowed_hosts = array('foo.example.com', 'bar.example.com');
if (!isset($_SERVER['HTTP_HOST']) || !in_array($_SERVER['HTTP_HOST'], $allowed_hosts)) {
header($_SERVER['SERVER_PROTOCOL'].' 400 Bad Request');
exit;
}
now i want know the best way to do that
may be will user strpos
I have a table defined like this:
create table users (
id int(10),
age int(3),
name varchar (50)
)
I want to use a query to update just age, which is an integer, that comes from an html form.
When it arrives to the method that updates it, it comes as a string, so I change it to integer with PHP and try to update the table, but it doesn't work
$age = intval($age);
$q2 = "UPDATE users SET age='$age' where username like '$username';";
mysql_query($q2,$con);
I wrote three methods in a class and one is calling another, but when I call the function outside through the object, it is showing an undefined function error for the second function.
Here's my code:
function resize_image(){
}
function image_resize(){
$a = resize_image();
}
When I run this, it shows resize_image() as undefined. Here's the error:
Fatal error: Call to undefined function resize_image() in
/home/vacayge/public_html/Major/Alpha1/classes/cUserImages.php on line
2090
Is there a way I can post photos to my facebook profile using my username and password only? The code may be in PHP or Java. I dont want to make a facebook app and allow it to post photos to my profile.
Any help is much appreciated. Thanks in advance.
Hai
I want to create a web site with pure php. I want to hide the url parameters. I.e. I want to make my web site with clean urls. Is there is any way to do this with out using any framework? Is it curl help full to do this? Does any one give me a solution.
Is there a way to PHP make asynchronous http calls? I don't care about the response, I just want to do something like file_get_contents(), but not wait on the request to finish before executing the rest of my code. This would be super useful for setting off "events" of a sort in my application, or triggering long processes.
Any ideas?
What is wrong with this code?
<?php
class users {
var $user_id,
$f_name,
$l_name,
$db_host,
$db_user,
$db_name,
$db_table;
function user_input() {
$this->$db_host = 'localhost';
$this->$db_user = 'root';
$this->$db_name = 'input_oop';
$this->$db_table = 'users';
}
function userInput($f_name, $l_name) {
$dbc = mysql_connect($this->db_host , $this->db_user, "") or die ("Cannot connect to database : " .mysql_error());
mysql_select_db($this->db_name) or die (mysql_error());
$query = "insert into $this->db_table values (NULL, \"$f_name\", \"$l_name\")";
$result = mysql_query($query);
if(!$result) die (mysql_error());
$this->userID = mysql_insert_id();
mysql_close($dbc);
$this->first_name = $f_name;
$this->last_name = $l_name;
}
function userUpdate($new_f_name, $new_l_name) {
$dbc = mysql_connect($this->db_host, $this->db_user, "") or die (mysql_error());
mysql_select_db($this->db_name) or die (mysql_error());
$query = "UPDATE $this->db_table set = \"$new_f_name\" , \"$new_l_name\" WHERE user_id = \"$this->user_id\"";
$result = mysql_query($query);
$this->f_name = $new_f_name;
$this->l_name = $new_l_name;
$this->user_id = $user_id;
mysql_close($dbc);
}
function userDelete() {
$dbc = mysql_connect($this->db_host, $this->db_user, "") or die (mysql_error());
mysql_select_db($this->db_name) or die (mysql_error());
$query = "DELETE FROM $this->db_table WHERE $user_id = \"$this->user_id\"";
mysql_close($dbc);
}
}
?>
The error is:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\jordan_pagaduan\class.php on line 21
Cannot connect to database : Access denied for user 'ODBC'@'localhost' (using password: NO)
The code cannot define this "$this->db_host" as "localhost".
how to get the value of input box while submitting the form in php
i need the url like this
www.example.com/te/?a=test&firstname=blabla
<form action="te/?a=test" method="post">
<input type="text" name="firstname" />
<input type="submit" name="button" />
</form>