I feel like I should know how to do this but I am stumped and perhaps it's because I'm sick but anyway...
I have a form that will be used to search a database. The form has a total of 12 fields which can be filled out to perform the search.
My question is: Is there an easy way to include or exclude the fields in SQL query when accessing the database? That is, I only want to include the fields where something has been entered in the query string and am not sure how I would go about doing that.
Any help is greatly appreciated. Thank you in advance!
I am using a php script to process information on a form.(the form POSTS to x.php)
At the end of the script I output a simple thank you page.
Should I be redirecting to a different page, or is it ok (normal) to simply create the web output (thank you) as part of the php page? (the address of whichwould be www.whatever.com/x.php)
I'm uploading some images using the following code as a part of the catch and validate system
$image_details = getimagesize($_FILES['userfile']['tmp_name']);
// Reject upload if the file isn't an image.
if (!file_exists($_FILES['userfile']['tmp_name']))
{
$text = "the file vanished!";
}
elseif (!$image_details)
{
$text = "that file wasn't an image";
}
Testing the system with some jpeg images, one of them goes through fine while the other one reports that it's vanished. They're both under the upload limits of the html and php.ini and it's the smaller one that vanishes. I've even tried resizing and saving the images, but it doesn't change things.
This is the script I used to use to create a file.
//name of file I want to create $filename = "openfile.php"; //open file $openfile=fopen($filename,"w"); //this is some content $filecontent = "ephi is terribly lousy in remembering things."; //I put the content there fputs($openfile, $filecontent); //and close the file fclose($openfile); ?>
Default folder file permission is 755. Any new file in the folder is set to be 644.
Now the script doesn't work anymore, except if I changed the folder permission to 757 or 777. But, I didn't wish to do that.
If you are doing work for a client remotely, and they are in a different state than you, how does a contract work? Do you just fax it to the client, have them sign, and fax back? Are there any particularly tricky legalities to the contract since it is in two different states?
Hi guys, I'm trying to make an email verification script. 1. User enters values to the contact form (done) 2. Contact form sends verification email to the entered user email (done) 3. User clicks on the link and verification process is complete (I'm stuck here)
// 1. open connection to MySQL (okay, done!) $koneksi = mysql_connect($db_host, $db_user, $db_password) or die(mysql_error()); $db_select = mysql_select_db($db_name) or die(mysql_error());
// 2. query the database to see if the verification string match the ones in the database (this is okay, too!) $query = "SELECT email_id FROM email_ver WHERE verify_string=$verify"; $result = mysql_query($query); while ( $data = mysql_fetch_array($result) ) { $drid = $data['email_id']; } if ($drid!=$id) { $t="There are no such ID or request."; } else { // 3. query the database to update that email has been verified (this is where I'm stuck!) $query = "UPDATE email_ver SET email_verify='y', verify_string='0' WHERE email_id=$id"; // specifically these next two lines! $result = mysql_query($query) or die(mysql_error()); $num_rows = mysql_affected_rows($result); // if the query work if ($num_rows > 0) { echo "Yay! Your email is valid!"; } }
I got this following error: Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource
Why is that happen? When the actual query is successfully done in the database (I've checked and re-checked). [Edit: It's because I'm feeding it with the wrong kind of resource. *LOL*]
am Pretty new to using PEAR, facing some pbms here lately , I ve installed pear with the following setup : windows /apache 2/mysql /php5 now while execute the following code :
"Warning: require_once(DB.php) [function.require-once]: failed to open stream: No such file or directory in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\pear.php on line 3
Fatal error: require_once() [function.require]: Failed opening required 'DB.php' (include_path='C:\PHP\pear') in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\pear.php on line 3"
please let me know how to fix this.thx alot. Praveen.
Hi. I'm not really completely sure as to why this is happening. Here's my error message:
Fatal error: Call to a member function Execute() on a non-object in /opt/lampp/htdocs/medievalbattles/current/v8/httpdocs/include/functions.php on line 16
Here's the functions.php line (the whole function, really). Line 16 is $result = $__db->Execute($sql); ---------- // Does this email exist already? function checkemail($email) { global $dbname; $sql = "SELECT * FROM $dbname.accounts WHERE email = '$email'"; $result = $__db->Execute($sql); if ($result->RecordCount >= 1) { $uid = $result->fields["id"]; return $uid; } else return false; } ----------
At the top of functions.php, I am including my config file (include("config.php");)
The contents of config.php are as follows: ---------- ##################### ## Database variables ##################### $dbhost = "localhost"; $dbuser = "root"; $dbpass = ""; $dbname = "mb_game";
I'm trying to write a small gallery script which gives the possibility to upload a number of 1-10 files at once - first thing the user does is pick the number of files to upload, then he is directed to the upload form(s).
Now my problem is that I don't know how to process the multiple files at once - there are 4 fields for each photo, the file itself, a title, a description and the gallery id. All of that is inserted into a DB after the images have been resized and uploaded - how do I do both of those things for multiple files at once? It must be something with for or foreach, but I have no idea how to use it with multiple files AND multiple fields to be posted at once. The affected part is the add action. Any help would be very appreciated - I'm pretty much a noob (still). :)
Digging into an extreme wtf code base and 90% of the site tree refers to a couple included files of type '.lib'. Ignoring the naming convention, the real issue is this:
Inside these .lib files are lines and blocks of comments that start with # instead of `//' or `/* ... */`.
Just going by the assumption that the site is actually running, but is '#' really a valid/good/sane escape character for comments?
Anyone familiar with either dreamhost, code igniter, or .htaccess? I'm having a problem getting it all setup, and I suspect that my problem is in the .htaccess file.
My .htaccess: RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php/$1 [L]
The website in question: http://www.zastica.com/ (you can see that the index page works, but anything else like zastica.com/blog/ dies with "No Input File Specified"
I keep getting undefined notices. I was going to see if you guys could show me the pro way of writing this code so it won't give me all those notices. I can get the undefined index thing to go away by doing this:
if (!isset($_REQUEST['DateOfBirth']) or $_REQUEST['DateOfBirth']) $_REQUEST['DateOfBirth'] = null;
I want to know how this should be handled. thanks.
Notices:
Notice: Undefined index: DateOfBirth in /var/www/budget.fidelityreserves.com/html/clientbudget.php on line 156
Notice: Undefined offset: 2 in /var/www/budget.fidelityreserves.com/html/clientbudget.php on line 158
Notice: Undefined offset: 1 in /var/www/budget.fidelityreserves.com/html/clientbudget.php on line 165
Notice: Undefined offset: 2 in /var/www/budget.fidelityreserves.com/html/clientbudget.php on line 165
Code:
//Remove characters from DateOfBirth and split into array of three numbers $date_arr = preg_split('/[\-\/ ]/', $_REQUEST['DateOfBirth']); //If last number in array is a date field if ( $date_arr[2] > 1900 ) { //reorder array with last number first $date = $date_arr[0].$date_arr[1].$date_arr[2]; $_REQUEST['DateOfBirth'] = $date; } else { //else order array with first number first $date = $date_arr[1].$date_arr[2].$date_arr[0]; $_REQUEST['DateOfBirth'] = $date; }
So I wanted an opinion on some books. I consider myself very well... dumb, in PHP. I can write simple backends to manage website content, upload files, screw with databases... but while loops, for statements, classes... they scare me.
In an effort to expand my knowledge of PHP I recently purchased two books:
Web Database Applications with PHP and MySQL (2nd Edition) by O'Reilly Object-Oriented PHP: Concepts, Techniques, and Code by Peter Lavin
And the only purpose of this post is to see if any of you have opinions on these books, or suggestions for what I could do to begin obtaining a more robust handle on PHP programming. Because honestly... I'd rather code PHP than design another club flyer.
I am drawing a blank here about this. I am clumsily putting this code in:
echo "'>";
This works, but I know this is not how this should be handled. I need to include the contents of the variable $total in the field's value. What is the elegant normal way of doing this?
Been scanning through php.net's site for a couple of hours looking to see if there was a function that could convert a nested associative array into an xml object or into xml string. I see plenty of functions to take xml strings and convert them into a DOMDocument.
I guess I could create something that loops through the elements and places tags based on key/value pairs but I would think with PHP's massive library of functions, such a simple function would exist? Just missing it I guess. Anyone know?
I created a script a while ago that allowed users to upload files to a folder and then update the html page to show the new file and the description given via a form. The users now want to be able to delete items that they uploaded. Naturally this is months after I worked on the script and they want it done today (dammit). I found a rather nice tool in w2box: http://labs.beffa.org/w2box/ except I can not get it to work on my server for some reason. Has anyone worked with it? The creators have not responded to my ask for help yet. Is there another script out on the interwebs that allows for file upload, deletion and downloading that is easy to deal with on a Linux/Apache server?