PHP watermark
6/9/2011 external link
Ok so thanks to the help of a couple other members I was able to put together this code that adds a watermark to an image before it displays it. However, I cannot figure out how to make it do it for more than one image. Here is my code:CODE $directory = "clientPhotos/" . $_SESSION['Client'] . "/"; foreach (glob($directory . "*.jpg") as $filename) { echo '<img src="show_image.php?f=' . rawurlencode(basename($filename)) . '" />'; echo rawurlencode(basename($filename));This code is within show_image.php:CODE<?phpsession_start(); // open the file in a binary mode $name = "images/dog.jpg"; //$fp = fopen($name, 'rb'); // Load the stamp and the photo to apply the watermark to $watermark = imagecreatefromstring(file_get_contents($name)); $image = imagecreatefromjpeg("clientPhotos/" . $_SESSION['Client'] . "/Blue hills.jpg"); // Set the margins for the stamp and get the height/width of the stamp image $marge_right = 10; $marge_bottom = 10; $sx = imagesx($watermark); $sy = imagesy($watermark); // Copy the stamp image onto our photo using the margin offsets and the photo // width to calculate positioning of the stamp. imagecopy($image, $watermark, imagesx($image) - $sx - $marge_right, imagesy($image) - $sy - $marge_bottom, 0, 0, imagesx($watermark), imagesy($watermark)); // Output and free memory header('Content-type: image/jpeg'); imagejpeg($image); imagedestroy($image); exit;?>Right now, dog.php is the watermark for Blue hills.jpg both of which that are within the separate php file. the $directory from the top code is irrelevant as long as the image exists, it will just take the images from within show_image and replace it. Which is fine I guess, although weird. But since show_image is outputting the image info on the bottom, I can't figure out how to do this for more than one image. I can't have separate files for each image because the original purpose of using "for each" was so it didn't matter how many images were in the folder nor the names of them, they would just display, and I need them to do so with the watermark.
customized LINK!
6/9/2011 external link
hi all dear,how can i create a customized link for a form like "friend cloob" join form?!ex.when user clicks "i am male" the s.e.x combobox in the form changed to male or inverse...i want a link like this:www.testfriendcloobs.com/form.php?s.e.x=maleorwww.testfriendcloobs.com/form.php?s.e.x_id=2what was i do to create a link like this and customize the form?!
Help correcting a error
6/9/2011 external link
I am working on a widget for Social Engine 4 and Randomly get the following errorCODEParse error: syntax error, unexpected '}' in /home/standth1/public_html/csr/application/widgets/fightsubmit/Controller.php(8) : runtime-created function on line 1Fatal error: Function name must be a string in /home/standth1/public_html/csr/application/widgets/fightsubmit/Controller.php on line 10I was trying to change the variable "data" into something more descriptive when it started. So I did what I normally do... I put it all back to data. And I am still getting the same exact message.Controller.php:CODE<?phpclass Widget_FightSubmitController extends Engine_Content_Widget_Abstract{ public function indexAction() { $scode = $this->_getParam('data'); $func = create_function (null, $scode ); ob_start(); $func(); $this->view->data = ob_get_contents(); ob_end_clean(); }}?>Manifest.php:CODE<?phpreturn array( 'package' => array( 'type' => 'widget', 'name' => 'fightsubmit', 'version' => '1.0.0', 'path' => 'application/widgets/fightsubmit', 'repository' => '', 'meta' => array( 'title' => 'Fight Submit', 'description' => 'Submit fight data.', 'author' => 'garrett-innovations.com', ), 'directories' => array( 'application/widgets/fightsubmit', ), ), // Backwards compatibility 'type' => 'widget', 'name' => 'fightsubmit', 'version' => '1.0.0', 'title' => 'Fight Submit', 'description' => 'Submit fight data.', 'category' => 'Widgets', 'autoEdit' => true, 'adminForm' => array( 'elements' => array( array( 'Text', 'data', array( 'label' => 'Minimum CP Access Level:' ) ), ) ),) ?>index.tpl:CODE<?php $currentDisplayName = Engine_Api::_()->user()->getViewer()->displayname; echo 'Welcome, ' . $currentDisplayName; $currentAuthLevel = Engine_Api::_()->user()->getViewer()->level_id; echo '<br/>Authorization Level: ' . $currentAuthLevel . '<br/><br/>'; echo 'Minimum Auth Level: '. $this->data . '<br/><br/>';?>Any help on this is much appreciated.
CAPICOM
6/9/2011 external link
Hello allI need to some code line about to use CODE"Set EncryptedData = Server.CreateObject("CAPICOM.EncryptedData")"in ASP3To Encrypt my data like (fields "name", "family").thank you very much
Check File exist in hard drive
6/9/2011 external link
I wish to redirect my site if a particular page is a file exist in hard drive, using the following code, but it don't works, kindly help.<%Set fs=Server.CreateObject("Scripting.FileSystemObject")If fs.FileExists("C:\3dgarro.cur")=true Then Response.Write("exists.")Else Response.Write("not exist.")End Ifset fs=nothing%>
how do i select all rows from table where timeStamp is older than 7 days of current date
5/9/2011 external link
I have a field timeStamp within my table which is type timestamp with a format 2011-09-30 23:11:12.The attribute is on update current_timestamp.can i run an sql command to select all rows that are older than 7 days from date when command is executed.something like select * from tbl where timeStamp < current_timestamp - 30
Select blogs only of friends
5/9/2011 external link
First of al sorry for bad english,Hi,I'm trying to make a blog system and show you own blogs and friend blogs.this is my 'database'1. usersf> id (you) and friends (friends)2. blog> id(anyone but i want to select my own and friends)This is what I did: $query = mysql_query("SELECT friends FROM dabosn.usersf WHERE id='" . mysql_real_escape_string( $id ) . "'");while($row = mysql_fetch_assoc($query)){$friends = $row['friends'];}echo $friends;$query = mysql_query("SELECT b.bid,b.id,b.title,b.blog,b.picture,b.video,b.blogsize,u.easyname FROM blog as b,dabosn.users as u WHERE u.id=b.id and b.id='" . mysql_real_escape_string( $friends ) . "'");while($row2 = mysql_fetch_assoc($query)){echo $row2['easyname'];}Only that doesn't work because {} stops before the other query: $query = mysql_query("SELECT friends FROM dabosn.usersf WHERE id='" . mysql_real_escape_string( $id ) . "'");while($row = mysql_fetch_assoc($query)){$friends = $row['friends'];echo $friends;$query = mysql_query("SELECT b.bid,b.id,b.title,b.blog,b.picture,b.video,b.blogsize,u.easyname FROM blog as b,dabosn.users as u WHERE u.id=b.id and b.id='" . mysql_real_escape_string( $friends ) . "'");while($row2 = mysql_fetch_assoc($query)){echo $row2['easyname'];}}Normally this works but now it only show 1 friendso I tried 1 query $query = mysql_query("SELECT b.bid,b.id,b.title,b.blog,b.picture,b.video,b.blogsize,u.easyname FROM blog as b,dabosn.users as u,dabosn.usersf as f WHERE u.id=b.id and b.id=f.friends(WHERE f.id=mine $id )";while($row2 = mysql_fetch_assoc($query)){echo $row2['easyname'];}}Ofcourse this not going to work but how do i make something like this? that between the ()And this only shows friends how do i add my own message to? i was thinking add or b.id=$id is that going to work?Already thanks!
How to redirect every page of website to WWW. format
5/9/2011 external link
How can I redirect the user to example.com to www.example.com?And what if I only want to redirect the homepage?
MySql Restart
5/9/2011 external link
Hey Guys, I restarted my sql using # etc/init.d/mysql restart. It does its thing...Stopping MysqlStarting Mysql thenChecking for corrupt, or tables that need to be updated...Then I tried to run a login script who's contents are saved in the mysql database and it didnt work.After banging my head against the wall like that for a while I attempted to login to my phpmyadmin and sure enough I cant login to that either.I have located all the data on the harddrive so I know the data isnt lost Im not concerned with that but why cant I login to phpmyadmin after restarting mysql?More importantly how do I fix it. This is a time sensitive matter so any help would be great.-SB
Arithmetic in Isql help
5/9/2011 external link
Hello every one .. I am new here but this looks like the best place to get a little help with my SQL level 1 programming class ...My teacher on our assignment ask this question and I am a little lost ... We are using the SQL fundamentals book and the Oracle 11g book.. using powers in iSQL 6 raised to 3 Any help would be great guys ... Thanks in advancedEmile
Writing to a file
4/9/2011 external link
I've been playing with php and trying to write a simple AI program that will learn things you tell it and will store the stuff in text files. Anyway I am having an issue writing to the file I don't get a 500 it just doesn't write anything to the file. Also how do I make line breaks? Oh and how do I redirect to another page?Here's my code:CODE<?php//This array shows the possible greetings a user can type in.$greetings[0]="HI";$greetings[1]="HEY";$greetings[2]="HELLO";$usercommand=$_GET["command"];$command = strtoupper($usercommand);If ($command==$greetings[0] OR $command==$greetings[1] OR $command==$greetings[2]) $cresponse="[AI] Who is it?";Else $cresponse="[AI] I don't understand tell me what does " . $usercommand . " mean?"; $newfiledata = "[You] " . $usercommand . "" . $cresponse . "";echo $newfiledata;echo file_put_contents("conversation.txt", $newfiledata, "FILE_APPEND");?>
SQL Query not working
4/9/2011 external link
HI guys... why this code not working "SELECT * timesheet WHERE YEAR(date) = YEAR(CURDATE()) AND MONTH(date) = MONTH(CURDATE()) ";this SQL statment working fine on the database engine direct, but not working when run it via PHP page???Please any help Thank you in advance.
PHP video tutorials
4/9/2011 external link
Hi guys ,I really learned a lof from w3schools , as i suggest you this site that i have found when i was googling some php video tutorials , I want share with you .The video nice with clear explaination enjoy your time http://www.phpvideostutorials.com/Best Regards
PHP Calendar
3/9/2011 external link
I need to create a calendar for a website. Since I am using PHP pages for the website, so I guess best to use PHP calendar (no javascript). I am still new to PHP and haven't looked into SQL Server (I do know SQL language, that's it). I have heard about Google calendar, but wouldn't work well with the design. All it needs to be is "event calendar". Only admin will add/edit events, and then others can see events. At first, I thought of creating a full 12-months but thought it wouldn't be practical. The propose of event calendar is to see future events in few months ahead (which there isn't a whole lot, but something like 5 events in a year). I feel they will be using it more on other little and local events, so I want to keep that in mind. So, something like a week of vacation with daily activites thoughout the day. So far, the link below seems to be best design:http://www.phpjabbers.com/time-slots-booking-calendar/orhttp://www.phpjabbers.com/event-booking-calendar/orhttp://www.phpjabbers.com/php-event-calendar/I really can't "order" those calendar since the org doesn't have money for me to "try" things out. I need a startup version so I can work from there. I looked in many places and download codes, those aren't helping me.http://th2.php.net/manual/en/refs.calendar.phpI need a startup and then I could pick up from there. I live in Milwaukee, WI.Chuck
How does array_diff work
2/9/2011 external link
Can you explain to me why I get the following answers when I use array_diff?<?php$a1=array(2=>"Cat",1=>"Dog",2=>"Horse");$a2=array(0=>"Rat",2=>"Horse",2=>"Dog");$a3=array(0=>"Horse",1=>"Dog",2=>"Cat");print_r(array_diff_assoc($a1,$a3,$a2));?>How does the array_diff_assoc function work?Is it looking for values of the first array that are not found in any of the other arrays?Does the order in which the arrays are listed in the array_diff_assoc matter or determine which is compared first?For example, is $a1 compared to $a3 and then to $a2. The returned value is [2]="Horse". Why is this value returned and not [1]="Dog" and [2]="Horse"For a key-value pair not to be returned, the key and value pair have to be found in all arrays listed?
Finding (the) Closure
1/9/2011 external link
I built a class to imitate closures, while being able to be treated as a regular class, but the syntax needed was ugly, and hard to remember. So now ....I'm building a new class, to make closures more portable. The basic syntax for instantiating one of these objects would be this: CODE$enclosure = new \us_0gb\enClosure(function($var)use($par){echo $par,$var;}); or CODE$closure = function($var) use ($par) { echo $par,$var; };$enclosure = new \us_0gb\enClosure($closure); As you can see, it takes a closure as its argument. Now, I need to isolate the closure's original code.I think it might be impossible if the closure was created using eval(), but I should be able to do it if a hard copy of it exists in the file. Using PHP's built-in ReflectionFunction class, this is what I have so far, with the irrelevant methods removed:CODE<?php class enClosure { public function __construct(\Closure $Closure) { $this->Closure = $Closure; $ReflectionFunction = new \ReflectionFunction($this->Closure); $function = \array_slice(file($ReflectionFunction->getFileName()), ($ReflectionFunction->getStartLine() - 1), ($ReflectionFunction->getEndLine() - $ReflectionFunction->getStartLine() ) + 1); $this->enClosure = \implode("\n", $function); $begin = \strpos($this->enClosure, 'function'); $end = \strrpos($this->enClosure, '}') - $begin + 1; $this->enClosure = \substr($this->enClosure, $begin, $end); }}However, I'm having issues with nested curly braces:CODE<?php$par = 'test';$enClosure = new \us_0gb\enClosure(function($var)use($par){echo $par,$var;});echo $enClosure->enClosure,"\n\n";if(!isset($notset)){ $Closure = function($var)use($par){echo $par,$var;}; }$enClosure = new \us_0gb\enClosure($Closure);echo $enClosure->enClosure,"\n\n";results in:QUOTE function($var)use($par){echo $par,$var;}function($var)use($par){echo $par,$var;}; }Any help would be greatly appreciated.
dropdown for search suggestions with prompting
1/9/2011 external link
Is there an example on w3shools that demonstrates a drop down box that could fit under a input box like: http://www.w3schools.com/php/php_ajax_php.asp ?EDIT: Where the suggestions in the drop down can be based on the prompting from the input box?
Removing identifying information from the HTTP response headers.
1/9/2011 external link
My site is based on ASP3I get some notice about security of my site:--Information Leakage--discriptions:Your site, web server discloses version numbers and architecture information within the HTTP response headers.So The following HTTP Headers are attached to every HTTP response from the your site application. This information helps an attacker profile the application architecture of your site and may point towards existing vulnerabilities.Server: Microsoft-IIS/6.0X-Powered-By: ASP.NETand you must :Remove identifying information from the HTTP response headers.Is there any code in asp3 to manage number and type of my HTTP response headers?or this matter set only By IIS.I am using a shared server.Thank you very much for your help
httponly
1/9/2011 external link
My site is based on ASP3I get some notice about security of my site.--summery: your site's Cookie Missing "HttpOnly" Attribute--description:Sensitive cookies set by the application ("ASPSESSIONID") are not marked with HttpOnly. Without this, XSS attacks could be used to steal session identifiers and hijack user sessions.SO An XSS vulnerability would need to exist in the application. A high skill level would be needed to exploit this vulnerability as an attacker.--solution:Include HttpOnly on sensitive cookies as a defense-in-depth measure against the threat of session hijacking.please help me to clearing.I am using some cookie on my login page.and I am using some session.As I know that session saved on client side too, Is my session a type of cookie? and this danger type is for session too?please Show me some code.like thisCODEResponse.AddHeader "Set-Cookie", "mycookie=yo; HttpOnly"what must I do?for example my cookie name is CODE Response.Cookies("A")("f")= email1Thank you very much for your time
Mysql server at localhost?
1/9/2011 external link
How do I check that my mysql server is located at "localhost"?
Query Union All
1/9/2011 external link
Hi there, I need your help.I need union the queries for this output:CODEDSPq DSP asx nos ins sca inl ese tot_1XI T 72 0 0 72 39 498 2.638XM L 2 0 0 2 2 2.459 5.646XO C 52 0 0 70 5 3.204 7.894XS S 76 0 0 145 44 392 2.456Tot Tot 202 0 0 289 90 6.553 18.634Try this Query Union, but I have this output:CODEDSPq | DSP | tot | asxXI | T | 2.638 |XM | L | 5.646 |XO | C | 7.894 |XS | S | 2.456 |Tot | Tot | 18.634 | 72 2 70 145 289Can you help me?Thanks in advance.CODESELECT COALESCE(DSP,'Tot') `DSPq` , CASE DSP WHEN 'XS' THEN 'S' WHEN 'XO' THEN 'C' WHEN 'XM' THEN 'L' WHEN 'XI' THEN 'T' ELSE 'Tot' END `DSP` , `tot` , `asx`FROM(SELECT ZN 'DSP' , REPLACE(FORMAT(COUNT(*),0), ',', '.') 'tot' , NULL 'asx' FROM tbl_1 WHERE 1 AND ZN<>'' GROUP BY ZN WITH ROLLUP) xUNIONSELECT NULL , NULL , `tot` , `asx`FROM (SELECT ZN 'DSP' , NULL 'tot' , REPLACE(FORMAT(SUM(CASE WHEN ASX = 1 THEN 1 ELSE 0 END),0), ',', '.') 'asx'FROM tbl_1_sWHERE 1 AND ZN<>'' GROUP BY ZN WITH ROLLUP) x;
mysqldump syntax problem
1/9/2011 external link
I'm having a slight issue with the mysqldump feature. The database we have used to be on a server that ran a slightly older MySQL version, and when it was then placed into a new server with MySQL 5.0.51a, the mysqldump cronjob on Debian I had set up for the old database location is getting an error with the following:ERROR 1064 (00000) at line 23: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT CHARSET=latin1' at line 14The difference in MySQL versions probably means the syntaxes have changed, but I am not certain how to correct this. How can I go about doing this?
php ajax tutorial
1/9/2011 external link
I'm looking at php ajax tutorial. i'm on page http://w3schools.com/php/php_ajax_php.asp.i'm trying to figure out where's the documentation that says the innerHTML element is part of the document.getElementById method ?
Select name from database
1/9/2011 external link
Hi there,I have a mysql database which holds records about people. My aim was to search the database and display records found onto the screen, this was all working fine but i found that players who had apostrophe's in their name such as the name Adam O'Donnell brought up a mysql_numrows error on return.The name is typed into an input box and once you click the search button it will reload the page, send the name to php through a $_post command and then search the database. Here is the code i have tried so far:CODE #the search term from the html form once submit was pressed $searchterm = $_POST['SearchTerm']; $searchterm = trim(rawurldecode($searchterm)); #replace any black slash's $searchterm = str_replace("\\","",$searchterm); print $searchterm; #get the search category from the html form $searchcategory = $_POST['Category']; $characterremove = array("/"," "); #remove any forward slashes from search category $searchcategory = str_replace($characterremove,"",$searchcategory); $con = mysql_connect('h50mysql107.secureserver.net','sensiswos','Sens1sw0s'); @mysql_select_db("sensiswos",$con) or die(mysql_error()); mysql_query("SET NAMES utf8"); $query="SELECT * FROM FootballPlayers WHERE lower($searchcategory) LIKE lower('%$searchterm%') AND lower(PlayerManager) LIKE lower('$playermanagersearch') COLLATE utf8_bin ORDER BY Name asc"; print $query; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close();Ok so that is my code, when i run the query with a name without an apostrophe it works fine and returns a result, if i use a name with an apostrophe in i then get the following error generated once i print the query out:CODEAdam O'DonnellSELECT * FROM FootballPlayers WHERE lower(Name) LIKE lower('%Adam O'Donnell%') AND lower(PlayerManager) LIKE lower('%') COLLATE utf8_bin ORDER BY Name ascWarning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/content/S/h/a/Sharkadder/html/worldfootballleagues/sql_testing/search.php on line 195Ok so that is my code, i have tried using mysql_escape_string() when searching the database and that doesn't work and i have also tried doing a search without my removing the \\ as shown in the code above and that doesn't work.just to mention one final thing, the name is saved into the database without a \ before the apostrophe, so it is in the database as Adam O'Donnell and not Adam O\'Donnell. The other thing to mention is that i replace the \ after the page has reloaded because once i type the name in and submit it, on refresh the search term produces a \ before the apostrophe and so i replace it with blank.If you can help where i am going wrong then that would be great.Many thanks,Mark
Delete on a view
25/8/2011 external link
As I stated in my topic description im new to this stuff. Keeping things simple this is what I want to do.I have table1 and table2 and I have a view created showing me information on both tables. I want to be able to delete information on the view and once that has been deleted I want that information sent over to table3.I was reading an old SQL book and I found in bold letter "You cannot create a trigger on a view"So if it possible to delete information on the view how can I move that information to a table if I can't create a trigger?Anybody have any helpful ideas because I'm stumped?Thanks,Chris
Escaping Quotes
25/8/2011 external link
When I escape an apostrophe in a <textarea>, in a <form>, "Joe\'s coat." get's saved as "Joe's coat." in the table, but it displays correctly on my browser as "Joe's coat.". It seems the escaping is only important for the mysql UPDATE query. If so, how do I avoid, having to manually re-enter the escaping, each time I need to UPDATE a column with text that has apostrophes in a <form>?
project development
25/8/2011 external link
I apologies if this is the wrong place to post this.We are looking for someone to develope a simple project in JSP (basically a form with 3 to 4 text boxes). Would this be the right place to start looking for a professional developer.Thank you
Help with a query
25/8/2011 external link
I am editing a query that I have been using and not sure how to do thisI need to use both AND & OR Statements in the same query.I already have: (Please mind the format... this is being put into a php script)CODE'SELECT * FROM rank_fight_list WHERE fighterID1='.$this->fighterID.' OR fighterID2='.$this->fighterID;I need to add that the STATUS field must also be 'Official' or 'NSF'Not sure if I need to break the two or statements up with parentheses along with an AND in between or not.Any help would be appreciated. I would experiment but i hate butchering what already works fine.
php ini files
24/8/2011 external link
Do all apache servers allow you to create a custom php.ini file within your root directory for certain config options, or is this something that you have to set to allow elsewhere? If so, where?
Query not working?
24/8/2011 external link
Hi, the code$result = mysql_query("SELECT usr, xp, hp, level, faction FROM aad WHERE usr LIKE %$rcu%");$row = mysql_fetch_array($result);returnsWarning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/appattac/public_html/aadimensions/rsq.php on line 15Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/appattac/public_html/aadimensions/rsq.php on line 27Help!
Installing a PHP library
24/8/2011 external link
I'm using the SoapClient class, and when i move over my app to a test server, i get the following:Fatal error: Class 'SoapClient' not found in /public/info/ami/Aeropops.php on line 20When I do a phpinfo(), under Configuration Command I see this:--enable-soap=sharedAny idea what might be wrong?
MySQL LIKE failing?
24/8/2011 external link
I want a Simple user search for my game.So far I have:$result = mysql_query("SELECT usr, hp, xp FROM aad WHERE usr LIKE '%$rcu%'");then I use W3school's echo to table.So I have two users, both starting with "King"but it only returns one.And when i search the full user, neither do.Help!
Printing out portion of map
24/8/2011 external link
I am able to print an entire map with the map definition in a text file.Here is the output of the whole map: http://student18.gamfe.com.hk/map.phpThe codeCODE<table align="center" cellpadding="0" cellspacing="0" width="1170"> <tbody><tr><?php $file = file_get_contents("33.txt"); $entries = explode("\n", $file); for($i=0;$i < sizeof($entries);$i++){ $data = explode(",", $entries[$i]); for($j=0;$j < sizeof($data);$j++){ echo "<td align=\"center\" background=\"test/33_"; echo $data[$j]; echo ".gif\" width=\"65\" height=\"65\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"65\" height=\"65\"> <tbody><tr> <td> <center>".$data[$j]."</center> </td> </tr></tbody> </table> </td>"; } echo "</tr><tr>"; }?> </tr></tbody></table>I am trying to print out a 5x5 portion of the map based on the player coordinates. The player will always stay at the center of the 5x5 map. For example, if the player is at (5,4), how do I print out the 5x5 map with (5,4) being the center of the map?
Multiple action on form submit
24/8/2011 external link
I have a form collecting registration data, on submit, I have a confirmation page displaying data via php (session var), followed by a form with a "confirmed" checkbox. On submit, if confirmed, I want two actions: to post the data to MySQL and open a new window with PayPal interface to accept credit card payment. Elementary but logic eludes.Is the location function only way to redirect? How do I format a location redirect with multiple input data?I see redirect is tricky. What page structure and php method would be best to get this done?
Passing data between different sites
24/8/2011 external link
HiI have a forum in server1 with domain1 and a cms in server2 with domain2how check user login state in cms into server2 ?
CONTAINS Help
24/8/2011 external link
I ran into a new issue today. I was trying to search for all names containing "[GM]" within a table. Yes, the brackets are part of the name.This would be the first time I have had to use the CONTAINS function, so I was pretty much guessing. However, each attempt ended with an error stating that the information could not be pulled due to the table not being Full-Text Indexed.After a bit of bewilderment about this, I then tried to use LIKE instead. I used this as LIKE [GM]%However, this simply returned everything starting with the letter "G", I assumed it was because of the brackets.Based on this, I tried to get a little research on how to use the LIKE function when a special character is involved and came around to using ESCAPE in combination with the LIKE request. However, once more, this has confused me slightly as once I finally got it to work using the ESCAPE/LIKE combo, it did not return any results. Of course I know this is wrong, because MY name within this database contains the "[GM]".My apologies if anything I have wrote is a bit newbish or non-sensible, I am pretty much diving into SQL head first. Any ideas, suggestions, or examples would be greatly appreciated.-Frank
Single Query for Several Databases
24/8/2011 external link
I know you can use JOIN for retrieve data from two different tables. However, every case I have seen of this thus far has been when both tables reside within the same database. I have recently found myself with the need to pull data from two tables, each residing in a different DB.I have tried numerous times to figure this out on my own, but now I am hitting a mental roadblock.Example:I have one database named GameInfoI have another database named AccountInfoWithin GameInfo is a table named CharInfoAnd within the AccountInfo is a table named UserDetailI need to SELECT data from a column named CharName from GameInfo.dbo.CharInfoand SELECT data from a column named UserStatus from AccountInfo.dbo.UserDetailI need to do this in a single query. Basically I want to do this in a single query so I can search for all CharNames from GameInfo.dbo.CharInfo that have a UserStatus of "5" currently assigned to their account in AccountInfo.dbo.UserDetail.Any ideas?
Private files with Permissions?
23/8/2011 external link
Is there any way so only the server can view files.For example, a Library of functions only accessible if my server uses Require and loads it?Like if a user typed in http://www.whatever.com/lib.php it would deny access?
Can't connect to local MySQL server
23/8/2011 external link
I get the error message:Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2002): Can't connect to local MySQL server through socket '/tmp/mysql.sock'when I try to connect to a hosted database.Looking so far through the help I could find online, the suggestions refer to changes in server settings, a thing I cannot change. Is there anything else I could do? Other than php files and phpMyAdmin access there is not much I can else...Son
SimpleCode
23/8/2011 external link
I know nothing about JAVA.I have a website that the user enteres a request for information about a fixed number of categories and when it is submitted, the information is pulled from a database and displayed.I just got introduced to Google App Engine. My goal is to have someting that would work on smart phones. Are my goals possible to mix the two together? can I make a java code for the form that retreives information and it would conside with Google App Engine service?Am I on the right track, or am I just getting confused?Where do I start to learn move about making a simple form in JAVA. The form will only have about two to three fields and a submit button.
reading a post without going out on index.php
23/8/2011 external link
Hii have a simple index.php displaying a topic title and a brief summary of the content. And in the topic title has a link like this href="view_post.php?id=$id"which this url calls the view_post.php file.. it has anyway to make this still in the index.php instead of calling the view_post.php file..
Books.
23/8/2011 external link
Can anyone recommend a title of a good/excellent PHP 5+ book? I noticed that W3Schools only have them on HTML/CSS and JS/Ajax.
HTTP 500 error when using MySQL
23/8/2011 external link
I installed php, along with mysql and apache and got php and apache working properly together it seems. I have no problems when it comes to just using php code, to display a date for example, but when I try to use mysql, I get an HTTP 500 error. I've only gotten that error when there's a flaw with the code I've written. However, I copied and pasted the following example from the w3schools php mysql tutorial, to eliminate any of my stupid mistakes, yet I still get the error.<?php$con = mysql_connect("localhost","peter","abc123");if (!$con) { die('Could not connect: ' . mysql_error()); }if (mysql_query("CREATE DATABASE my_db",$con)) { echo "Database created"; }else { echo "Error creating database: " . mysql_error(); }mysql_close($con);?>I'm pretty new to web design.What could the problem be?I really appreciate any help, thanks.
how would i escape this?
23/8/2011 external link
hey guys, would someone be able to show me how i would escape this so the echo works. ThanksCODEecho "[ - <a href="/$dir/game_play.php">Play</a> - ]";
PHP date() Midnight?
22/8/2011 external link
Just wondering, what EXACTLY would the php function date() Return at midnight?Like would it say 12:00 PM, 12:00 AM? Or What?Like if I wanted to test if it was after between 9PM and 12PM (Midnight) What would I do? Thanks.Or should I just use 24 hr time?Thanks.P.S. what would 1AM and 12:01 PM be in PHP 24 hr time? the way w3schools formatted it was freaky.
if, else if, else
22/8/2011 external link
my code is not working and i believe it is due to "if, else if, else"if ($pass1 != ""){ if ($pass1 != $pass2) { $updatmsg = '<font color="#FF0000" size="+1"><u>ERROR:</u><br />Your Password fields below do not match.<br /></font>'; }if (strlen($pass1) > 20) { $updatmsg = '<font color="#FF0000" size="+1"><u>ERROR:</u><br />Your New Password is too long. 6 - 20 characters please.<br /></font>'; }else{if (strlen($pass1) < 6) { $updatmsg = '<font color="#FF0000" size="+1"><u>ERROR:</u><br />Your New Password is too short. 6 - 20 characters please.<br /></font>'; }else$sql = mysql_query("UPDATE project SET password='$pass1' WHERE id='$id'")or die (mysql_error());$updatmsg = '<font color="#006600" size="+1">Your password was updated successfully.</font>';could you please help with a working scriptthank you.
800a0bb9 Arguments are of the wrong type
22/8/2011 external link
Okay I am trying to write functions to reduce the amount of connections to the database and make my code simpler and shorter. So I have created a file that will be included that has some of the functions I have been testing out.This is the error I getQUOTE ADODB.Recordset800a0bb9Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another./DragonCraft/Includes/combat_functions.asp 15And here is the code:CODE<%'Functions for combat written by Glorfindel on August 21, 2011Function openconnection(database)set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open "" & database & ""End FunctionFunction MonsterHP(ID)openconnection("C:\Databases\DragonKwest.mdb")set rs = Server.CreateObject("ADODB.recordset")sql="SELECT Health From Monsters WHERE [ID]=" & ID & ""rs.open sql, conndo until rs.EOFfor each x in rs.FieldsMonsterHP = x.value nextrs.MoveNextlooprs.closeconn.closeEnd Functionresponse.write MonsterHP(1)%>
php date
22/8/2011 external link
hi all this is my 1st post i have this code to sand a date from 3 drop down menu's to my DB and its working for me $date = "$b_y-$b_m-$b_d";but how do i send my $date from my DB to display in my 3 drop down menu's?thank you in advance.
MySQL CURDATE() and how to tell how long time ago?
21/8/2011 external link
How do I put the full date into the database?(including seconds)How can I make the script tell how long time ago a date was?I'm creating a Norwegian web page, tough, so:Second(s) = sekund(er)Minutte(s) = minutt(er)Hour(s) = tim(er)Day(s) = dag(er)Week(s) = uke( r )Year(s) = år
adding if else to pdo connection to neaten up errors.
21/8/2011 external link
Hi guys, I have tried a few different way to add an if else to the below code, none of which were successfull. At the moment when the database is down it echo's connection failed. If the connection is successfull i would like it to echo 'database ok' would anyone know How to do this?Thanks.CODE<?php$hostname = 'localhost';$username = '';$password = '';$database = '';try {$dbh = new PDO("mysql:host=$hostname;dbname=$database", $username, $password);}catch(PDOException $e){echo 'Connection failed';}error_reporting(0);?>
I want to create a Multi Upload Image Center
21/8/2011 external link
Hi guys ;I had created before a new upload center to my site but i tried to make a multi-upload image Center but all my tries failed This is the code i have tried : CODE<?php if(isset($_POST['submit'])) { for($i=0;$i<count($_FILES['image']);$i++) { $file_name = $_FILES["image"]["name"];$filesize = $_FILES['image']['size'];$filetype = $_FILES['image']['type'];$filetypes = array ('image/jpg','image/jpg','image/GIF','image/JPEG','image/JPG','image/gif','image/jpeg'); $file_name1 = strchr($file_name,'.'); $new_file = time(00000,99999).$file_name1; $path_image = "script/upload/".$new_file; move_uploaded_file($_FILES["image"]["tmp_name"],$path_image);echo "<br /><hr /><img src='http://www.3arabarchive.net/$path_image'/><br><br>Code: <input type='text' size='50' value='[img]http://www.mysite.net/".$path_image."[/img]'>"; } } ?> <html> <body> <form method="post" action="upload_several.php" enctype="multipart/form-data"> <table> <tr><td> <input type="file" name="image[]"> </td></tr> <tr><td> <input type="file" name="image[]"> </td></tr> <tr><td> <input type="file" name="image[]"> </td></tr> <tr><td> <input type="file" name="image[]"> </td></tr> <tr><td> <input type="submit" value="upload"> </td></tr> </table> </form> </body> </html>Any Help !!!Thanks and good bye
paging not working
20/8/2011 external link
can anyone solve this. i am trying to add pages to the following code but i cant get my head around it what so ever. Can anyone helpCODE<?php include_once('inc_dbcon.php'); require_once('admin/config.php');require_once($languageFile);// Preview descrition length in characters$previewLength = 240;// check to see if in admin mode and validate keyglobal $keyOut;$keyOut = "";if (isset($_GET["k"])) if($_GET["k"] == $key){ // Key comes from admin/password.php file $keyOut = "&k=" . $key; } global $category;$category = "%";if (isset($_GET["category"])) $category = mysql_real_escape_string($_GET["category"]);$msg = "";if (isset($_GET["msg"])) $msg = mysql_real_escape_string($_GET["msg"]);// SEARCH CODE START$searchQuery = "";if (isset($_GET["q"])) $searchQuery = mysql_real_escape_string($_GET["q"]);if ($searchQuery != "") { $query_Recordset1 = "SELECT postId,category,title,description,isAvailable,description,price,confirmPassword,category,imgURL,imgURLThumb,DATE_FORMAT(timeStamp,'%b %d, %Y %l:%i %p') AS timeStamp1 FROM md_postings WHERE isConfirmed = '1' AND title like '%$searchQuery%' OR description like '%searchQuery%' ORDER BY `timeStamp` DESC";} else { // this following line was pulled from about ten lines below if you are updating an older version $query_Recordset1 = "SELECT postId,category,title,description,isAvailable,description,price,confirmPassword,category,imgURL,imgURLThumb,DATE_FORMAT(timeStamp,'%b %d, %Y %l:%i %p') AS timeStamp1 FROM md_postings WHERE isConfirmed = '1' AND category like '$category' ORDER BY `timeStamp` DESC";}// SEARCH CODE END - see also line 113 below$maxRows_Recordset1 = 100;$pageNum_Recordset1 = 0;if (isset($_GET['pageNum_Recordset1'])) { $pageNum_Recordset1 = mysql_real_escape_string($_GET['pageNum_Recordset1']);}$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);$Recordset1 = mysql_query($query_limit_Recordset1); if (!$Recordset1){ print("It appears we have a problem: " . mysql_error()); exit(); }$row_Recordset1 = mysql_fetch_assoc($Recordset1);if (isset($_GET['totalRows_Recordset1'])) { $totalRows_Recordset1 = mysql_real_escape_string($_GET['totalRows_Recordset1']);} else { $all_Recordset1 = mysql_query($query_Recordset1); $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);}$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;$queryString_Recordset1 = "";if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, "pageNum_Recordset1") == false && stristr($param, "totalRows_Recordset1") == false) { array_push($newParams, $param); } } if (count($newParams) != 0) { $queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams)); }}$queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1);?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><title></title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><link href="md_style.css" rel="stylesheet" type="text/css" /><script language="JavaScript">function doFilter(dis){ window.location.href = "index.php?category=<?php echo $category ?>&type=" + dis.value + "<?php echo $keyOut;?>"} </script></head><body><div id="md_container"><?php include_once("inc_header.php") ;?><?php include_once("inc_navigation.php") ;?><?php if ($msg == "deleted") print("<br clear='all' /> <div class='md_msg' style='margin-top:-10px;'>" . STR_DELETED ."</div>"); ?><br clear="all" /> <div id='md_listingBox'><?phpif($totalRows_Recordset1 < 1){ // SEARCH START new Code - added IF statement to support search if ($searchQuery != "") echo "<p><br /><br /><br />" . STR_NORESULTS . "<b>" . $searchQuery ."</b></p>"; else echo "<p><br /><br /><br />" . STR_NOITEMS . "</p>"; // SEARCH END NEW CODE} else { do { $img = "/images/gift_light.gif' title='This is a gift!'"; $type = $row_Recordset1['type']; $isAvailable = $row_Recordset1['isAvailable']; $isAvailableClass = ($isAvailable == 0) ? 'md_taken' : ''; $thumbnail = ' '; if (strlen($row_Recordset1['imgURLThumb']) > 3){ $thumbnail = "<a href='viewItem.php?id=" . $row_Recordset1['postId'] . "' class='md_recordLink " . $isAvailableClass . "'>"; $thumbnail .= "<img src='" . $row_Recordset1['imgURLThumb'] . "' class='md_thumbnail' border='0'></a>"; } else{ $thumbnail = "<b>No Image Available</b>"; }?><table width="100%" border="0" cellpadding="4" class="md_listingTable"> <tr> <td width="84" height="74" align="center"><?php echo $thumbnail; ?></td> <td valign="top"> <div class='md_date'><?php echo $row_Recordset1['timeStamp1'];?></div> <a href="viewItem.php?id=<?php echo $row_Recordset1['postId'] . $keyOut;?>" class='md_recordLink<?php echo $isAvailableClass; ?>'><?php echo stripslashes($row_Recordset1['title']); ?></a> — £<?php echo $row_Recordset1['price']; ?> <br /> <?php echo stripslashes(substr($row_Recordset1['description'],0,$previewLength)); ?>... </td> </tr></table><?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); } // end else clause?> </div><?php include_once("inc_footer.php");?></div></body></html><?php mysql_close($dbConn); ?>
New in programming Java, got problems Compiling
20/8/2011 external link
So i have begun to learn Java a little bit, but i can't get my programs to compile. I have set Both my Path and Path class to C:\Program Files (x86)\Java\jdk1.6.0_22\binBut I just get the message: "'javac' is not recognized as an internal or external command, operable program or batch file" when i type this: D:/stuff>javac HelloWorld.javaI also downloaded a ide, Eclipse after i had chnaged the path, but when i press "run" or "debug" nothing happens. What should i do? I'm so pissed of right know, sure i'd know Java maybe would be an challenge, but i can't even get the code to compile.BTW i don't have any javac.exe file on my computer either, even though i have installed JDK.
Only letters and numbers
20/8/2011 external link
Hi.Is there a way I can validate that a string only contains letters and numbers?
Converting decimal?
19/8/2011 external link
Hi, I'm trying to use this code I made and doesn't really work well.I want, so say a user has 9000 XP, it says "LEVEL 9" (Divided by 1000, obviously)But you get crazy results when you have say, 9812 XP, I want it to still say "LEVEL 9"So... is there any easy code I can use to remove decimals?
COMMENT FORM
19/8/2011 external link
I WROTE THIS CODE FOR COMMENT FORM WHEN I FILL OUT FORM AND I CLICK SEND ,THIS CODE DOESN'T WORK I DON'T KHNOW WHAT'S PROBLEM? CODE if(!empty($_POST['name'] )&&!empty($_POST['email']) && !empty($_POST['comment'])&& !empty($_POST['user_code']) ){ $n = $_POST['name'];$e=$_POST['email'];$me=$_POST['comment'];$id =intval( $_POST['message_id']);if($id>0){if( mysql_num_rows( mysql_query( "SELECT `cid` FROM `idea`WHERE `comment` = '" . $_POST['comment'] . "' and `email` = '" . $_POST['email'] . "' LIMIT 1" ) )< 1 ) {//vojood nadare pas felan kar kon $idea=mysql_query("INSERT INTO idea (name,email,comment,cid,checked) VALUES('$n','$e','$me','$id','0') "); mysql_set_charset("utf8",$con); printf('<div class=" bg-blue "><script language="javascript" type="text/javascript">alert("ADMIN AFTER CHECK COMMENT HE DISPLAY IT.");</script></div>');}else{ //else shart aval //echo"error"; }}else {//echo'<div class=" send"><center>SEND COMMENT</center></div>';} }
MySQL Blog Database Security
19/8/2011 external link
I am working on coding a blog by hand for a friend (partially because she doesn't like Wordpress, partially because I want to know that I am capable of hand coding an easily-customizable blog). I just finished her login page yesterday, importing her username and password directly into a database using phpMyAdmin. What should I do for security precautions to protect the database from being hacked? I have been trying to find tutorials on MySQL and PHP security, but I'm having trouble finding one that fits my needs as I have never worked with a database on a live website before.Thanks in advanceMark
TimeOut or Spam
19/8/2011 external link
I am trying to send mail (Using Zend mail API and a valid SMTP server) to send over 800 clients, but the process seems to be aborted after ~25 mailsAnyone have any idea why? The function simply go through the SQL database and send mails untill no more clients left to query.Thanks in advance.
Udpate Php Script with Prepared statements
19/8/2011 external link
So i have two update scripts using prepared statements. One works fine and updates the record, while the other give me a "Call to a member function bind_param() on a non-object". They are almost identical minus the variables in them. Ive been staring at this for a day now and still nothing. If anyone has any insight i would love to hear from you. This is the code that works...CODE<?phpsession_start();/*** connect to database ***/ /*** mysql hostname ***/ $mysql_hostname = '#######'; /*** mysql username ***/ $mysql_username = '#####'; /*** mysql password ***/ $mysql_password = '######'; /*** database name ***/ $mysql_dbname = 'propertyregistration'; $conn = mysqli_connect( $mysql_hostname, $mysql_username, $mysql_password, $mysql_dbname ); $last_name = trim($_POST['lastname']); $first_name = trim($_POST['firstname']); $address = trim($_POST['address']); $city = trim($_POST['city']); $state = trim($_POST['state']); $zip = trim($_POST['zip']); $phone = trim($_POST['phone']); $email = trim($_POST['email']); $student = $_GET['student_id']; $username = $_SESSION['username']; $_SESSION['username'] = $username; $dbh = new mysqli($mysql_hostname, $mysql_username, $mysql_password, $mysql_dbname);$stmt = $dbh->prepare("UPDATE personal_info SET last_name=?, first_name=?, address=?, city=?, state=?, zip=?, phone_number=?, email=? WHERE student_id =$student");$stmt->bind_param("ssssssss", $last_name, $first_name, $address, $city, $state, $zip, $phone, $email);$stmt->execute();header("Location: thankyou1.php");?>This code does notCODE<?phpsession_start();/*** connect to database ***/ /*** mysql hostname ***/ $mysql_hostname = '#####'; /*** mysql username ***/ $mysql_username = '#####'; /*** mysql password ***/ $mysql_password = '######'; /*** database name ***/ $mysql_dbname = 'propertyregistration'; $conn = mysqli_connect( $mysql_hostname, $mysql_username, $mysql_password, $mysql_dbname ); $item_id = trim($_POST['itemid']); $uid = trim($_POST['uid']); $manufacturer = trim($_POST['manufacturer']); $model = trim($_POST['model']); $color = trim($_POST['color']); $more = trim($_POST['more']); $username = $_SESSION['username'];$_SESSION['username'] = $username;$serial= $_GET['serial_number'];$dbh = new mysqli($mysql_hostname, $mysql_username, $mysql_password, $mysql_dbname);$stmt = $dbh->prepare("UPDATE item_info SET item_id=?, uid=?, manufacturer=?, model=?, color=?, more=? WHERE serial_number =$serial");$stmt->bind_param("ssssss", $item_id, $uid, $manufacturer, $model, $color, $more);$stmt->execute();header("Location: thankyou1.php");?>Thank you in advance
One query to retrieve data from either both or one table
18/8/2011 external link
Is it possible to query two tables at once but return only one results from one of the tables?For example, say I have a query like this:SELECT * FROM temptable INNER JOIN voteWHERE temptable.id = vote.temp_idWhat I would like to do is either retrieve all columns from both tables, BUT if I can't retrieve from table vote, then how can I only retrieve all from table temptable? I know the syntax isn't correct but here's a idea of what I'm trying to do below:SELECT * FROM temptable INNER JOIN voteWHERE temptable.id = vote.temp_idORSELECT * FROM temptableSo either retrieve all from both tables, if not for some reason, then retrieve only from temptable. Is this possible?
echo'ing http_referer
18/8/2011 external link
I have cobbled this together to echo my message only if the current_mp is on or lower than 499, and only if the user has come from a specific page.im getting the following error with the below code, can anyone see what I have done wrong?Parse error: syntax error, unexpected ':' in /var/www/html/testdir/cloud/walktest.php on line 292CODE<?phpif (($current_mp <= 499) && ($_SERVER['HTTP_REFERER'] == http://testsite.com/file.php)) { echo '<div class="header_pos">Not enough Magic Points<br /><br /></div>';}?>
pagination not working
18/8/2011 external link
I have used a free script to create a classified ads page. The script lists each row of data and have variables set for number of pages etc but i dont know how to intergrate the pages as links and modify the script to just show a certain amount of rows per page. There is a variable for number of rows per page and as far as i can work out the script only show the first page if i set the number of rows to 5. no page links though. Can anyone modify this.Any help would be grate.CODE<?php include_once('inc_dbcon.php'); require_once('admin/config.php');require_once($languageFile);// Preview descrition length in characters$previewLength = 240;// check to see if in admin mode and validate keyglobal $keyOut;$keyOut = "";if (isset($_GET["k"])) if($_GET["k"] == $key){ // Key comes from admin/password.php file $keyOut = "&k=" . $key; } global $category;$category = "%";if (isset($_GET["category"])) $category = mysql_real_escape_string($_GET["category"]);$msg = "";if (isset($_GET["msg"])) $msg = mysql_real_escape_string($_GET["msg"]);// SEARCH CODE START$searchQuery = "";if (isset($_GET["q"])) $searchQuery = mysql_real_escape_string($_GET["q"]);if ($searchQuery != "") { $query_Recordset1 = "SELECT postId,category,title,description,isAvailable,description,price,confirmPassword,category,imgURL,imgURLThumb,DATE_FORMAT(timeStamp,'%b %d, %Y %l:%i %p') AS timeStamp1 FROM md_postings WHERE isConfirmed = '1' AND title like '%$searchQuery%' OR description like '%searchQuery%' ORDER BY `timeStamp` DESC";} else { // this following line was pulled from about ten lines below if you are updating an older version $query_Recordset1 = "SELECT postId,category,title,description,isAvailable,description,price,confirmPassword,category,imgURL,imgURLThumb,DATE_FORMAT(timeStamp,'%b %d, %Y %l:%i %p') AS timeStamp1 FROM md_postings WHERE isConfirmed = '1' AND category like '$category' ORDER BY `timeStamp` DESC";}// SEARCH CODE END - see also line 113 below$maxRows_Recordset1 = 5;$pageNum_Recordset1 = 0;if (isset($_GET['pageNum_Recordset1'])) { $pageNum_Recordset1 = mysql_real_escape_string($_GET['pageNum_Recordset1']);}$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);$Recordset1 = mysql_query($query_limit_Recordset1); if (!$Recordset1){ print("It appears we have a problem: " . mysql_error()); exit(); }$row_Recordset1 = mysql_fetch_assoc($Recordset1);if (isset($_GET['totalRows_Recordset1'])) { $totalRows_Recordset1 = mysql_real_escape_string($_GET['totalRows_Recordset1']);} else { $all_Recordset1 = mysql_query($query_Recordset1); $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);}$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;$queryString_Recordset1 = "";if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, "pageNum_Recordset1") == false && stristr($param, "totalRows_Recordset1") == false) { array_push($newParams, $param); } } if (count($newParams) != 0) { $queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams)); }}$queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1);?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><title></title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><link href="md_style.css" rel="stylesheet" type="text/css" /><script language="JavaScript">function doFilter(dis){ window.location.href = "index.php?category=<?php echo $category ?>&type=" + dis.value + "<?php echo $keyOut;?>"} </script></head><body><div id="md_container"><?php include_once("inc_header.php") ;?><?php include_once("inc_navigation.php") ;?><?php if ($msg == "deleted") print("<br clear='all' /> <div class='md_msg' style='margin-top:-10px;'>" . STR_DELETED ."</div>"); ?><br clear="all" /> <div id='md_listingBox'><?phpif($totalRows_Recordset1 < 1){ // SEARCH START new Code - added IF statement to support search if ($searchQuery != "") echo "<p><br /><br /><br />" . STR_NORESULTS . "<b>" . $searchQuery ."</b></p>"; else echo "<p><br /><br /><br />" . STR_NOITEMS . "</p>"; // SEARCH END NEW CODE} else { do { $img = "/images/gift_light.gif' title='This is a gift!'"; $type = $row_Recordset1['type']; $isAvailable = $row_Recordset1['isAvailable']; $isAvailableClass = ($isAvailable == 0) ? 'md_taken' : ''; $thumbnail = ' '; if (strlen($row_Recordset1['imgURLThumb']) > 3){ $thumbnail = "<a href='viewItem.php?id=" . $row_Recordset1['postId'] . "' class='md_recordLink " . $isAvailableClass . "'>"; $thumbnail .= "<img src='" . $row_Recordset1['imgURLThumb'] . "' class='md_thumbnail' border='0'></a>"; } else{ $thumbnail = "<b>No Image Available</b>"; }?><table width="100%" border="0" cellpadding="4" class="md_listingTable"> <tr> <td width="84" height="74" align="center"><?php echo $thumbnail; ?></td> <td valign="top"> <div class='md_date'><?php echo $row_Recordset1['timeStamp1'];?></div> <a href="viewItem.php?id=<?php echo $row_Recordset1['postId'] . $keyOut;?>" class='md_recordLink<?php echo $isAvailableClass; ?>'><?php echo stripslashes($row_Recordset1['title']); ?></a> — £<?php echo $row_Recordset1['price']; ?> <br /> <?php echo stripslashes(substr($row_Recordset1['description'],0,$previewLength)); ?>... </td> </tr></table><?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); } // end else clause?> </div><?php include_once("inc_footer.php");?></div></body></html><?php mysql_close($dbConn); ?>
category and content
18/8/2011 external link
i looked for everywhere, i tried everything but i cannotfor example forums or hotscripts.comMain CategorySub Categoryif there is no category here then that subcategory's list comesfor examplePHPScripts and ProgramsAd Management and list of Ad management
Make links in text
18/8/2011 external link
hello this is my code:$query2 = mysql_query("SELECT blog FROM users WHERE id='" . mysql_real_escape_string( $ido ) . "'");while($row2 = mysql_fetch_array($query2)){$data[] = $row2;foreach ($data as $row2);$blog = $row2['blog'];echo htmlentities($blog);}I use htmlentities so people can't use <b >bold< / B> tags.But how I grab links and make them clickable.like:this is my holiday,first day we started here google.comNice picture's huh?but what i want:this is my holiday,first day whe started here google.comNice picture's huh?How can I make something like that?
PHP Email Form
18/8/2011 external link
Ok I have been reading around, trying other people's code but I can not get it. So I need help.Here is my HTML code:CODE<form name"contact" method="post" action="contactEmail.php"> <table> <tr> <td valign="top"> Full Name: </td> <td valign="top"> <input type="text" name="name" maxlength="50" size="30" /> </td> </tr> <tr> <td valign="top"> E-mail: </td> <td valign="top"> <input type="text" name="email" maxlength="100" size="30" /> </td> </tr> <tr> <td valign="top"> Subject: </td> <td valign="top"> <input type="text" name="subject" maxlength="50" size="30" /> </tr> <tr> <td valign="top"> Comments: </td> <td valign="top"> <textarea name="comments" maxlength="1000" cols="25" rows="6"></textarea> </td> </tr> <tr> <td colspan="2" style="text-align:right"> <input type="submit" value="Submit" /> </td> </tr> </table> </form>Here is the PHP I am trying to use:CODE<html><body><?php$name = $_POST['name'];$client_email = $_POST['email'];$subject = $_POST['subject'];$email_address = "krew-d@live.com";$message_text = $_POST["message_text"];echo "<br />";echo "<br />";$message_text = "This message was sent by:<br />" . $persons_name . "<br /> <br />" . "Who indicated their email address is:<br />" . $client_email . "<br /><br />" . "Their message reads:" . "<br />" . $message_text;mail($email_address,$subject,$message_text);header("Location: thankyou.php");?> </body></html>How wrong is that?Thanks,Krewe
elseif not working how it should
18/8/2011 external link
Hi, the code im using below doesnt seem to be working properly.To test it, i set exp to 99999 but for some reason it only echo's '2' instead of 4.Could anyone point out what I have done wrong? Thanks for any helpCODE<?phpif ($exp < 1000) { echo '1';} elseif ($exp > 3000) { echo '2';} elseif ($exp > 8000) { echo '3';} elseif ($exp > 16000) { echo '4';}?>
creating posts category
18/8/2011 external link
Hi there,anyone here can help me about the algorithm of the category.. im messing up how it will flow..
image url retrieval php code
18/8/2011 external link
Image upload Html form:CODE<html><body><form action="uplo.php" method="post"enctype="multipart/form-data"><label for="file">Filename:</label><input type="file" name="file" id="file" /><br /><input type="submit" name="submit" value="Submit" /></form></body></html>Image upload code:CODE<?php if ((($_FILES["file"]["type"] == "image/bmp")|| ($_FILES["file"]["type"] == "image/gif")|| ($_FILES["file"]["type"] == "image/jpg"))&& ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("c:/e/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "c:/e/" . $_FILES["file"]["name"]); echo "Stored in: " . "c:/e/" . $_FILES["file"]["name"]; } } }else { echo "Invalid file"; }?>Now i need a script which would retrieve the "Uploaded" image link from IMAGESHACK.UStrying a wordpress plugin using this..can someone help me out !thanks.
changing order of mysql results
17/8/2011 external link
Hi, I'm currently using the code below to display the results from my database, and I was wondering if theres a way I can flip the results because at the moment the newest message entered (its a chat box) is displayed at the bottom, i would prefer it at the top.CODE<?php$host = "";$user = "";$pass = "";$db = "";$connection = mysql_connect($host,$user,$pass);if (!$connection) { die('Could not connect: ' . mysql_error()); }mysql_select_db("$db", $connection);$result = mysql_query("SELECT * FROM chat");while($row = mysql_fetch_array($result)) { echo $row['name']; echo ':'; echo $row['message']; echo '<br />'; }mysql_close($connection);?>
Send Email on Max Execution Time Error
17/8/2011 external link
Hello guys,Quick question. Is it possible to "catch" the maximum execution time exception and send an email if that time limit is reached?
captcha
17/8/2011 external link
i use captcha for contact form ie show me this errorWarning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\my\index.php:1) in C:\wamp\www\my\index.php on line 3i wrote this code before html codesQUOTE <?php ob_start() ; session_start(); require('php-captcha.inc.php'); if (empty($_POST['user_code'])) { $valid="PLEASE ENTER CODE"; // echo 'Valid code entered'; } else if (PhpCaptcha::Validate($_POST['user_code'])) { $valid="VALID CODE"; // echo 'Valid code entered'; } else { $valid="INVALID CODE"; // echo 'Invalid code entered';}?>
PHP file function
17/8/2011 external link
CODE$directory = "/home/serverName/" . $_SESSION['Client'] . "/"; foreach (glob($directory . "*.jpg") as $filename) { echo '<img src="' . $filename . '" />'; }}I am trying to use this code to display all of the images located in a directory. The files I am working with are stored in the /home root of the site because I do not want them to be accessible by the clients that will be using the site. However, I do want to be able to display them. The above code is what I did to try to accomplish this. It tries to display the image but only shows the broken image symbol. Im not sure if this is because it is denying me access to the image because of its location though.Basically, the code is doing exactly what I am telling it to do. $directory equals what I am telling it to equal, and Im placing it into the image tag exactly how Im trying to, if I right click on the broken image symbold and view the properties, it is indeed trying to display the image from I am expecting it to. Only thing is is I think its not letting me display the image or maybe I have it wrong with how I am trying to display the image.
Exclude weekends from SQL query
17/8/2011 external link
Hi guys,I have the following query :select EMPLOYEE, COUNT(NUMBERCALLED) as TOTAL_CALLEDFROM SDDTA.PhoneReportWHERE (MANAGERNAME = 'X' ORMANAGERNAME = 'Y') ANDDATE = CURRENT_DATE - 1 DAY group by EMPLOYEEorder by count(numbercalled) descfetch first 5 rows only the query works fine and it gets me the data for the previous day. how can i exclude the weekends so I dont get "No data" when running on Mondays.thanks!
speeding up variable assignments
17/8/2011 external link
I'm using information from 4 tables. This info is used to assign data to many variables where each assignment is a line of code. What techniques, approaches, concepts are available that can significantly reduce the time it would take to make these variable assignments other than simply reducing the amount of data I'm using through elimination or combining variables?
Efficiently typecasting an array as a custom object?
17/8/2011 external link
I need to typecast an array as an object, so I can use methods the deal with the former array's data. However, direct typecasting results in an instance of the stdClass class, which is not even remotely helpful with custom methods. Currently, I'm using a foreach statement to handle the conversion process, as shown below, but from what I've read, this is a slow way to handle these kinds of data processing. Is there a more efficient way?CODE<?php foreach($array as $key => $value){ $object->$key = $value; }
problem with pear library
17/8/2011 external link
i read an article in ibm about parsing xml data as an html table and insert them into db;http://www.ibm.com/developerworks/opensour...excel/#ibm-pconbut i want to know if there is there is another method to assign an array to sql statement mysql_query to insert data into dbwithout using pear libraryjust i want a normal snippet instead of pear snippet to do the same jobcode:CODE<?phprequire_once( "db.php" );$data = array();$db =& DB::connect("mysql://root@localhost/names", array());if (PEAR::isError($db)) { die($db->getMessage()); }function add_person( $first, $middle, $last, $email ){ global $data, $db; $sth = $db->prepare( "INSERT INTO names VALUES( 0, ?, ?, ?, ? )" ); $db->execute( $sth, array( $first, $middle, $last, $email ) ); $data []= array( 'first' => $first, 'middle' => $middle, 'last' => $last, 'email' => $email );}if ( $_FILES['file']['tmp_name'] ){ $dom = DOMDocument::load( $_FILES['file']['tmp_name'] ); $rows = $dom->getElementsByTagName( 'Row' ); $first_row = true; foreach ($rows as $row) { if ( !$first_row ) { $first = ""; $middle = ""; $last = ""; $email = ""; $index = 1; $cells = $row->getElementsByTagName( 'Cell' ); foreach( $cells as $cell ) { $ind = $cell->getAttribute( 'Index' ); if ( $ind != null ) $index = $ind; if ( $index == 1 ) $first = $cell->nodeValue; if ( $index == 2 ) $middle = $cell->nodeValue; if ( $index == 3 ) $last = $cell->nodeValue; if ( $index == 4 ) $email = $cell->nodeValue; $index += 1; } add_person( $first, $middle, $last, $email ); } $first_row = false; }}?><html><body>These records have been added to the database:<table><tr><th>First</th><th>Middle</th><th>Last</th><th>Email</th></tr><?php foreach( $data as $row ) { ?><tr><td><?php echo( $row['first'] ); ?></td><<td><?php echo( $row['middle'] ); ?></td><<td><?php echo( $row['last'] ); ?></td><<td><?php echo( $row['email'] ); ?></td><</tr><?php } ?></table>Click <a href="list.php">here</a> for the entire table.</body></html>the snippet that i mean is:CODE $sth = $db->prepare( "INSERT INTO names VALUES( 0, ?, ?, ?, ? )" ); $db->execute( $sth, array( $first, $middle, $last, $email ) );thanks in advance
<htmlspecialchars> not working for me
16/8/2011 external link
hi all I am into using htmlspecialchars function I working with PHP manual example but not working for me I am using WAMP server latest version this is the example <?php$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);echo $new; // <a href='test'>Test</a>?>the output for me <a href='test'>Test</a>By the way, I want to ask anther question,, How can I retrieve this encoded html again as html ??? are there a function to do that???best wishes
imagecreatetruecolor does not work with transparency
16/8/2011 external link
I have a function that resizes images if the size is too wide as:CODE if ($w > $width) { $ratio = $width / $w; // ratio is max width divided by actual (<1) $img = imagecreatetruecolor($width, round($h * $ratio)); // height is actual height times ratio (less) imagecopyresampled($img, $orig, 0, 0, 0, 0, $width, round($h * $ratio), $w, $h); $orig = $img; $w = imagesx($orig); $h = imagesy($orig); }Works well and very useful unless you try to upload a transparent image. It shows as the manual states a black box which does not show when it is non-transparent image... Is there a way to work with similar function that also caters for transparent images?Son
switch in mysql statement?
16/8/2011 external link
I am wrecking my brain now for some time, but I cannot see the answer to my issue. I retrieve data from a db as:CODE$query = "SELECT img1, imgTitle, imgCat FROM hyr_images WHERE hyrID = $HID AND (imgCat = $pid OR imgCat = 7) ORDER BY imgCat ASC";I display the retrieved images on a several web pages and try to display the images for a specific page (assessed via imgCat). If no specific images are displayed the generic ones will be displayed (imgCat = 7). With my current setup page specific ones come first and then the generic ones, but I do only want to display the generic ones if there is not even one page specific one (and then in any case all generic ones should be displayed)..How can you achieve this? Is this possible?Son
Compare date to yesterday
16/8/2011 external link
Hi All,I have the follwoing query:select EMPLOYEE, COUNT(NUMBERCALLED) as TOTAL_CALLEDFROM SDDTA.PhoneReportWHERE (MANAGERNAME = 'X' ) ANDDATE = current_date group by EMPLOYEEorder by count(numbercalled) descfetch first 5 rows onlyI am trying to get the data for yesterday instead of current_date.any ideas?Thanks!
ASP Form Validation not working
16/8/2011 external link
Hi, I'm trying to add ASP validation to the form on this page here.Here's the code that I created:CODE<%If Request("POSTBACK") = "YES" Then oops = "" name = Trim(Request("name")) Set nmre = New RegExp nmre.Pattern = "^[a-zA-Z\'\-]$" If name = "Your Name" OR Not nmre.Test( Replace(name," ","") ) Then oops = oops & "<li>Please enter your name</li>" End If Set emre = New RegExp emre.Pattern = "^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-])\.([a-z](?:\.[a-z])?)$" emre.IgnoreCase = True If Not emre.Test( Request("email") ) Then oops = oops & "<li>Please enter a valid email address</li>" End If If oops = "" Then Server.Transfer "/ask-michael/#thankyou" End If Response.Write "Please correct the following errors and submit the form again:<ul>" & oops & "</ul>"End If%><form method="post" name="askmichael" onSubmit="return checkrefervalues();"><input name="POSTBACK" type="hidden" value="YES">When I hit submit on the form (with all valid fields), I get this error: "Please correct the following errors and submit the form again:," with nothing listed. Am I close to getting this validation to work?
didn't validate register form correctly
16/8/2011 external link
This code returns "Noen av feltene var ikke fyllt inn riktig."(Some of the fields were not filled in correctly.).it's supposed to redirect to login.php?s=1CODE<?phpif (CRYPT_BLOWFISH == 1){$username = mysql_real_escape_string($_POST["username"], $con);$password = mysql_real_escape_string(crypt($_POST["password"],$_POST["password"]), $con);$email = mysql_real_escape_string($_POST["email"], $con);$born = mysql_real_escape_string($_POST["born"], $con);}else{die("Kryptering er ikke støttet av serveren");}if (filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) if($_POST["password"]==$_POST["password2"])if($_POST["name"])if($_POST["password"])if($passet=="ok" && $nameset=="ok" && $passconfirmed=="ok" && $emailisvalid=="ok") { mysql_query("INSERT INTO users (username,password,email,regdate,rank)VALUES ('$username', '$password', '$email',CURDATE(),'2')"); header("location: ./login.php?s=1"); }else { $error="Noen av feltene var ikke fyllt inn riktig."; } ?>
How to Recreate Mysql Table Structure Using PHP
16/8/2011 external link
Hi, I want to re-structure my mysql table.CODEmysql_query("CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT, category_a VARCHAR(30))") or die(mysql_error());Now! i want to add another fields in this table structure.If admin want to create field category_b and category_c.Should i change table structure and add required fields.Or i should have to redesign database structure.So is it a good way?Like:table: testfields: user_id, categoriesfield values: category afield values: category bfield values: category cI want this type of result.userid: 1, category: auserid: 1, category: buserid: 1, category: cit'll possible in 3 rowsI was trying.userid: 1, category_a: a, category_b: b, category_c: c // It's possible in one rowPlease guide.
Encryption - which should I choose?
16/8/2011 external link
What kind of encryption should I use for encrytping passwords before I store them in the database?
mysql and mssql
16/8/2011 external link
Dear, in Mysql database with collation utf8, I inserted arabic data, after retreiving them using php with charset=utf-8I used mysql_query("set names utf8"); the problem is solvedis there an alternative for this query if we are reading from mssql..thank you
Encoding problem
16/8/2011 external link
Dear Friends,I created a database using MSSQL server with collation name:SQL_latin1_Genaral_CP1_CI_AS, and the tables with data types starting with n (ex: ntext, nvarchar...) because the data in the table is in Arabic. the arabic is appearing normally and readable in the tables.but when retreiving the Arabic using PHP with html header:<meta http-equiv="Content-Type" content="text/html; charset=utf-8">the arabic data it appears as questions mark ?????????????????.Please any suggestions,I need Help....Thanks a lot and Regards
CURL + RELATIVE LINKS?
16/8/2011 external link
When you CURL a website that uses Relative Links for all its: Images,Links,Forms,JavaScript Ect..and you make your curl code to insert your curl url + the websites base domain into those relative links so they become Absolute Linkslike:CODEsrc="/js/jquery.min.js"<-becomes->src="http://mysite.com/curl.php?http://othersite.com/js/jquery.min.js"Will those links retain or lose their functionality..?And what kinda function would I need to accomplish inserting "http://mysite.com/curl.php?http://othersite.com" into all of the Relative Links of the page I curl..?
+1 into database table
16/8/2011 external link
Does anyone know how I would go about making a form or button that when clicked will increase a number in my database by 1 at a time?
Execute plugin from another site before page loading
15/8/2011 external link
I don't know if I am wording the question right but I have not been able to find an answer to this problem that I am having. I have a plugin on my page that I have listed at the bottom. I have changed the domain to testsite so the link is not the actual link. This plugin works great after the page loads but does not show up in the view source option. The only thing that shows using the "view source" option from tools is what is displayed below. However the plugin shows perfectly on the already loaded page. I am trying to make the plugin content available on the view source option so that the googlebot can see the text and links included there. I don't know if I need some kind of jquery or php command or what. What command or code would I use to have this plugin load prior to the page loading so the content will be available for view via the view source option? I have tried several methods from posts that somewhat similar discussions but they did not work. I am not a programer so I know just about enough to make me dangerous but I have created several php sites now so I am getting better. Thanks in advance for any input. Bob.<script language="javascript">var bid= 4575;var site =2;document.write('<script language="javascript" src="http://testsite.com/?bid='+bid+'&sitenumber='+site+'&tid=event_results&'+ window.location.search.substring(1)+'"></' + 'script>');</script>I have tried to use <?php echo $_SERVER['QUERY_STRING']; ?>"> but that just gives me http:// testsite.com/?bid=4575&sitenumber=2&tid=event_results&event=example+name when I try to view the source document. Still does not execute the plugin prior to the page loading.
Just won't fetch data from database!
15/8/2011 external link
QUOTE Warning: mysql_query() [function.mysql-query]: Access denied for user 'kristfzz'@'localhost' (using password: NO) in /home/kristfzz/public_html/index.php on line 16Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/kristfzz/public_html/index.php on line 16Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/kristfzz/public_html/index.php on line 181. The username I've entered is kristfzz_1, and not just kristfzz2. I've entered a password!index.php:CODE<?phpinclude("include/common.php");include("include/header.php");?><div id="content"><?phpif($_GET["r_http"]=="404"){?><h1>Siden kunne ikke bli funnet.</h1><?php}else{ $result = mysql_query("SELECT * FROM sites WHERE name='index'"); while($row = mysql_fetch_array($result)) { echo $row["content"]; }}?></div><?phpinclude("include/footer.php");?>common.php isn't importantdatabase.phpCODE<?php// connect$con = mysql_connect("localhost","kristfzz_2","******");if (!$con) { die('Debugging: ' . mysql_error()); } mysql_select_db("kristfzz_1", $con); ?>
Working with PHP Arrays
15/8/2011 external link
I am working with the following code on codepad.org<?php$office = array('Mckenzie','Aberdeen');$office_wage = array(10,10);$warehouse = array('Martin','Alison','Cuptech','Kroger');$warehouse_wage = array(12,12,12,12);$oEmployees = array_combine($office,$office_wage);$oWarehouse = array_combine($warehouse,$warehouse_wage);$allEmployees = array_merge($oEmployees,$oWarehouse);//print_r($allEmployees);$U=array_values($allEmployees);$R=array_flip($allEmployees);print_r($R);?>The output I got was the following:Array( [10] => Aberdeen [12] => Kroger)It outputs the last values in each array when the values are the same. It treats it like the values are duplicates. How do I treat each array value as unique so that I get a print out of everything.I want to get the following results:Array( [10] => Mckenzie [10] => Aberdeen [12] => Martin [12] => Alison [12] => Cuptech [12] => Kroger)
Ajax/PHP/MySQL
15/8/2011 external link
Hi everyone! I'm trying to build a website for a searchable database, and I'm running into some issues for the way I want to search it. Basically I'm trying to do something like this, but I'm trying to do it with three dropdown menus that populate from the database, which I've found several examples of. What's confusing to me is how to put these two things together. Generally the examples of multiple dropdown menus don't have examples of how to output information from the database once you've selected your options, like with the link I mentioned previously. Can anyone help me figure out how to do this? Specific examples would be really helpful.
Pass PHP to JavaScript - Problematical!
15/8/2011 external link
I have been having trouble with this.I have a website that relies heavily on PHP and JavaScript side-by-side. The following code:-CODE<?php if (strlen($pieces[7]) < 2) { echo (' '); } else { echo ($pieces[7]); } $tempvar = '10';?> <script type="text/javascript"> jsvar = <?php echo $tempvar; ?>; alert(jsvar);</script>works fine. If I change the line setting $tempvar to assign something alphabetic it doesn't work - jsvar ends up empty. If I change that line to something like $tempvar = $pieces[7]; it doesn't work either.What am I missing?
PHP submit form & unknown error on IE8 & FF4
15/8/2011 external link
CODE( ! ) Notice: Undefined index: lang in C:\wamp\www\LanguageChooser.php on line 3 Call Stack # Time Memory Function Location 1 0.0001 368384 ( ) ..\LanguageChooser.php:0I tried the php codes below but I've got the above error message on both IE8 and Firefox 4.I followed a Youtube PHP tutorial:PHP tutorial on YoutubeHe didn't encounter such an error message but I did.How could I fix the error? I don't ever know what kind of php errors it is.CODE<?php$lang = $_POST['lang'];?><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body><form action="LanguageChooser.php" method="POST">Language:<select name="lang"><option value="English" <?php if($lang=="English"){echo "SELECTED";} ?> >English</option><option value="French" <?php if($lang=="French"){echo "SELECTED";} ?> >française</option></select><input type="submit" name="submit" value="Choose" /></form></body></html><?php switch ($lang){ case "English": include "lang/english.php"; break; case "French"; include "lang/french.php"; break; default: include "lang/english.php"; break; }echo $first."<br />";echo $second;?>
asp noob needs some help
15/8/2011 external link
i have this page that I am analyzing to help make a escalation tool to use at work.This is the source of a form used in another tool already developed that has the ability to pull information from our billing system with some javascript (atleast thats how I think it works).Anyway, I need to be able to formulate a simple function that will pull the customers Account Number, First Name, Last Name, and Phone Number from the billing system and input the data into a form.In order to do that I guess I need to understand asp and some more java.In fact I am such a noob at ASP i'm not even sure why the page starts like a normal HTML file.If someone could break it down for me how i can preform the above that would be awesome.Some things that need to be known, the process that actually pulls the data is the onclick of the Get ACSR Customer button which calls SCRAPE().Its only dependency that I can see is <script language="JavaScript" src="includes\SitAoi.js"></script>If needed I can post the source of that aswell.the page mentioned above:CODE<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ><HTML> <HEAD> <title>Customer</title> <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"> <meta content="C#" name="CODE_LANGUAGE"> <meta content="JavaScript" name="vs_defaultClientScript"> <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"> <META http-equiv="REFRESH" content="1140"> <script language="JavaScript" id="1" src="includes\er.js"></script> <script language="JavaScript" src="includes\SitAoi.js"></script> <script language="javascript"> var bValidate = false; //------------------------------------------>> function ValidateForm() //------------------------------------------>> { if (bValidate) { var aStrRequiredFields = Array("TxtBoxFirstName", "TxtBoxLastName", "DrpDwnRegion", "TxtBoxZip", "DrpDwnState", "DrpDwnCity", "TxtBoxAddressLine1", "TxtBoxStreetNumber", "TxtBoxStreetName", "TxtBoxCsgSubAcct", "TxtBoxAcctCorp", "TxtBoxHouse", "TxtBoxCust"); var aStrRequiredDescriptions = Array("First Name", "Last Name", "Region", "Zip Code", "State", "City", "Address", "Street Number", "Street Name", "Subscriber Account Number", "Account Corp", "Account House Number", "Account Customer Number"); var strMsg = "Please correct the following fields:\n\n"; var iMsgLentgth = strMsg.length; for (var i = 0; i < aStrRequiredFields.length; i++) { var oField = document.getElementById(aStrRequiredFields[i]); if (oField) { switch(oField.type) { case "select-one" : if (oField.selectedIndex == 0 || oField.selectedIndex == -1 || oField.options[oField.selectedIndex].text == "[SELECT]") strMsg += " - " + aStrRequiredDescriptions[i] + " is required\n"; break; case "select-multiple" : if (oField.selectedIndex == -1) strMsg += " - " + aStrRequiredDescriptions[i] + " is required\n"; break; case "textarea" : break; case "text" : switch (oField.name) { case "TxtBoxCsgSubAcct" : var oChkBoxNonSub = document.getElementById("ChkBoxNonSub"); if (!oChkBoxNonSub.checked && 0 == oField.value.length && document.getElementById("DrpDwnRegion").value != '4' && document.getElementById("DrpDwnRegion").value != '5' && document.getElementById("DrpDwnRegion").value != '6' && document.getElementById("DrpDwnRegion").value != '7' && document.getElementById("DrpDwnRegion").value != '8') strMsg += " - " + aStrRequiredDescriptions[i] + " is required (Unless NON SUB is checked) \n"; break; case "TxtBoxAcctCorp" : var oChkBoxNonSub = document.getElementById("ChkBoxNonSub"); if (!oChkBoxNonSub.checked && 0 == oField.value.length) strMsg += " - " + aStrRequiredDescriptions[i] + " is required (Unless NON SUB is checked) \n"; else if (oField.value.length > 0) { if(oField.value.length > 5 || oField.value.length < 4) strMsg += " - " + aStrRequiredDescriptions[i] + " Appears to be too long or too short for a valid account number 4 or 5 characters"; else if (!ValidField("ACCTNUM", oField.value)) strMsg += " - " + aStrRequiredDescriptions[i] + " must contain only numbers"; } break; case "TxtBoxHouse" : var oChkBoxNonSub = document.getElementById("ChkBoxNonSub"); if (!oChkBoxNonSub.checked && 0 == oField.value.length) strMsg += " - " + aStrRequiredDescriptions[i] + " is required (Unless NON SUB is checked) \n"; else if (oField.value.length > 0) { if(oField.value.length > 6 || oField.value.length < 1) strMsg += " - " + aStrRequiredDescriptions[i] + " Appears to be too long or too short for a valid account number 1 to 6 characters"; else if (!ValidField("ACCTNUM", oField.value)) strMsg += " - " + aStrRequiredDescriptions[i] + " must contain only numbers"; } break; case "TxtBoxCust" : var oChkBoxNonSub = document.getElementById("ChkBoxNonSub"); if (!oChkBoxNonSub.checked && 0 == oField.value.length) strMsg += " - " + aStrRequiredDescriptions[i] + " is required (Unless NON SUB is checked) \n"; else if (oField.value.length > 0) { if(oField.value.length > 4 || oField.value.length < 1) strMsg += " - " + aStrRequiredDescriptions[i] + " Appears to be too long or too short for a valid account number 4 or 5 characters"; else if (!ValidField("ACCTNUM", oField.value)) strMsg += " - " + aStrRequiredDescriptions[i] + " must contain only numbers"; } break; case "TxtBoxZip" : if (oField.value == "" || oField.value == null) strMsg += " - " + aStrRequiredDescriptions[i] + " is required\n"; else if (oField.value.length != 5 && oField.value.length != 10) strMsg += " - " + aStrRequiredDescriptions[i] + " must be 5 or 10 characters \n"; else if (!ValidField("ZIP", oField.value)) strMsg += " - " + aStrRequiredDescriptions[i] + " must contain only numbers and hyphens \n"; break; default : if (oField.value == "" || oField.value == null) strMsg += " - " + aStrRequiredDescriptions[i] + " is required\n"; break; } break; default: if (oField.value == "" || oField.value == null) strMsg += " - " + aStrRequiredDescriptions[i] + " is required\n"; } } } bValidate = false; if (strMsg.length == iMsgLentgth) return true; else { parent.document.getElementById("TblHeader").focus(); alert(strMsg); return false; } } else return true; } //------------------------------------------>> function EnableValidation() //------------------------------------------>> { bValidate = true; } //------------------------------------------>> function RequireConfirmation(iReason) //------------------------------------------>> { if (document.getElementById("dgCustomerMatches")) { document.getElementById("TrDataGrid1").style.display = 'block'; document.getElementById("TrDataGrid2").style.display = 'block'; if (document.getElementById("LblCustomerHistory")) { document.getElementById("TrCustomerHistory1").style.display = 'block'; document.getElementById("TrCustomerHistory2").style.display = 'block'; document.getElementById("TrCustomerHistory3").style.display = 'block'; } } var strPrompt = ""; if (0 == iReason) alert("Please select an existing customer or confirm that this is a new customer."); else { if (1 == iReason) strPrompt = "This Customer has an open ticket. Are you sure you want to create a new ticket? Please confirm that this is a new issue by typing I CONFIRM below."; else if (2 == iReason) strPrompt = "Are you sure this is not an existing customer? Please confirm that this is a different customer by typing I CONFIRM."; else if (3 == iReason) strPrompt = "Are you sure this is a new or existing customer? Please check the account number and confirm that this a new or existing customer by typing I CONFIRM."; var strConfirm = prompt(strPrompt, ""); if (null != strConfirm && "I CONFIRM" == strConfirm.toUpperCase()) document.location.href = "WizardPage.aspx?WizardType=Ticket"; else if (null != strConfirm) { alert("Please Confirm by typing I CONFIRM."); RequireConfirmation(iReason); } } } //------------------------------------------>> function GetTicket() //------------------------------------------>> { var lstBoxCustomerHistory = document.getElementById("LstBoxCustomerHistory"); var iSelected = lstBoxCustomerHistory.selectedIndex; document.location.href="Customer.aspx?CustomerHistoryRequest=" + lstBoxCustomerHistory.options[iSelected].value; } //------------------------------------------>> function HistoryError() //------------------------------------------>> { alert("Sorry, History for this ticket has been archived and is not available"); } //------------------------------------------>> function CustomerReturn(result) //------------------------------------------>> { if (result.indexOf('^ERROR') == 0) alert(result); else document.location.href = "Customer.aspx?" + result; } //------------------------------------------>> function ComtracsScrape() //------------------------------------------>> { //--->> Validate each entry field if (document.Form1.txtCorp.value == null || document.Form1.txtCorp.value == "" || document.Form1.txtCorp.value == " " || !ValidField("NUMERIC-", document.Form1.txtCorp.value) || document.Form1.txtCorp.value.length < 4 ) alert (document.Form1.txtCorp.value + " Not a valid CORP Please Re-Enter Corp and try again"); else if (document.Form1.txthouse.value == null || document.Form1.txthouse.value == "" || document.Form1.txthouse.value == " " || !ValidField("NUMERIC-", document.Form1.txthouse.value) || document.Form1.txthouse.value.length > 6 || document.Form1.txthouse.value.length < 1) alert (document.Form1.txthouse.value + " Not a valid House Number Please Re-Enter House Number and try again"); else if (document.Form1.txtcustNum.value == null || document.Form1.txtcustNum.value == "" || document.Form1.txtcustNum.value == " " || !ValidField("NUMERIC-", document.Form1.txtcustNum.value) || document.Form1.txtcustNum.value.length < 1 ) alert (document.Form1.txtcustNum.value + " Not a valid Customer Number Please Re-Enter Customer Number and try again"); else { document.location.href = "Customer.aspx?ScrapeAmdocs=1&Corp=" + document.Form1.txtCorp.value + "&House=" + document.Form1.txthouse.value + "&CustNum=" + document.Form1.txtcustNum.value; } } //------------------------------------------>> function Scrape() //------------------------------------------>> { var oCustomer = new SitCust(1); var bScrapeSuccess = oCustomer.ExecuteQuery(); if (!bScrapeSuccess) { oCustomer = new SitCust(2); bScrapeSuccess = oCustomer.ExecuteQuery(); if (!bScrapeSuccess) { if ("" != document.getElementById("TxtBoxCsgSubAcct").value) document.location.href = "Customer.aspx?ScrapeAccountNumber=" + document.getElementById("TxtBoxCsgSubAcct").value; else if ("" != document.getElementById("TxtBoxHomePhone").value) document.location.href = "Customer.aspx?ScrapePhoneNumber=" + document.getElementById("TxtBoxHomePhone").value; else alert("S.I.T. Communicator is not installed. Please contact the helpdesk for installation."); } } if (bScrapeSuccess) { //-->> CHECK ACSR SCRAPE FIRST if (oCustomer.ExecuteQuery()) { var strParam = "ScrapeACSR=1&FirstName="; strParam += escape(oCustomer.getFirstName()); strParam += "&LastName="; strParam += escape(oCustomer.getLastName()); strParam += "&Address1="; strParam += escape(oCustomer.getAddress1()); strParam += "&Address2="; strParam += escape(oCustomer.getAddress2()); strParam += "&City="; strParam += escape(oCustomer.getCity()); strParam += "&State="; strParam += escape(oCustomer.getState()); strParam += "&Zip="; strParam += escape(oCustomer.getZip()); strParam += "&HomePhone="; strParam += escape(oCustomer.getHomePhone()); strParam += "&WorkPhone="; strParam += escape(oCustomer.getWorkPhone()); strParam += "&AccountNumber="; strParam += escape(oCustomer.getAccountNumber()); strParam += "&HouseKey="; strParam += escape(oCustomer.getHouseKey()); strParam += "&Principal="; strParam += escape(oCustomer.getPrincipal()); strParam += "&MgmtArea="; strParam += escape(oCustomer.getMgmtArea()); if ("" == oCustomer.getLastName()) alert("Please ensure that you are on the Account Information screen in ACSR and try again. If problem persists contact the helpdesk."); else document.location.href = "Customer.aspx?" + strParam; } } &nb
When is it safe to implement new PHP features?
15/8/2011 external link
I was wondering: when is it safe to implement new PHP features? I can recompile PHP on my server anytime I want, to run new code locally, but when would it be safe to use new feature in code I'm distributing? About how long after a new version release of a free scripting language, such as PHP, can major web hosts be expected to update their compilers?
php/form updating database without submitting to a new page
15/8/2011 external link
Lets say I have my index.php page, at the moment I am using a form which submits to update.php to update records in my database. It then uses a redirect code to return to my index.php page.That all works fine, but I was wondering if there was a way to update the records directly from the index.php page?
WAMP installation & PHP running
15/8/2011 external link
My testingPlease take a look at the vid above and see which step I was missing in order to run PHP well on the server level (? not sure about this), very different from using JS.
php not playing nice with HTML
15/8/2011 external link
I'm trying to add a log in check that displays a link to log in or log out depending on whether the user is logged in or logged out.My PHP:<? phpif (session_is_registered('username'))then echo '<a href="saleslogout.php">Log Out</a>';else echo '<a href="saleslogin.php">Log In</a>';?>What I'm getting:Log Out'; else echo 'Log In'; ?>Where "Log In" is a legitimate link and "Log Out" is just plain text.I can't figure out what is going wrong. Any suggestions? I'd really appreciate it.
Multiple persistent sockets per hostname:port
14/8/2011 external link
BACKGROUND:I've recently been working on a project that's now almost finished, except I have this one known issue I hope to tackle...The project is a client for a certain kind of server. Naturally, there is authentication involved that I deal with at connection time, like:CODE$client1 = new Client(HOSTNAME, USERNAME1, PASSWORD, PORT);//$client1 is now connected to HOSTNAME:PORT and logged in as USERNAME1However, I wanted to also have the ability to have persistent connections (via another argument), and this is where things get interesting.I can have a persistent connection to a hostname:port combo without problems, but I can't have multiple hostname:port connections depending on the username. That is,CODE$client1 = new Client(HOSTNAME, USERNAME1, PASSWORD, PORT, true);//$client1 is now connected to HOSTNAME:PORT and logged in as USERNAME1works, but it only works for USERNAME1. Trying to pass another user for a second connection will silently be ignored in favor of the previous user, i.e.CODE$client1 = new Client(HOSTNAME, USERNAME1, PASSWORD, PORT, true);//$client1 is now connected to HOSTNAME:PORT and logged in as USERNAME1$client2 = new Client(HOSTNAME, USERNAME2, PASSWORD, PORT, true);//$client2 is now connected to HOSTNAME:PORT... but is logged in as USERNAME1This behavior is expected, since I use pfsockopen() to make the connection, and then I use ftell() to check if login is necessary. I thought about saving the username in some fashion (e.g. file), and then switching logins back and forth as each Client instance made requests. However, the problem is the protocol I'm implementing doesn't allow login switches - once you're connected, your first action is to login, and you can't login again on the same connection.QUESTION:Is there any way I can make multiple persistent socket connections for the same hostname:port combo? Some search led me to this thingy, but I was hoping for something that could be achieved with bundled PHP extensions (the socket extension that is...), even if it would require a lot more effort on my part than just that simple constructor.
INSERT statement for table with a foreign key
14/8/2011 external link
For the two tables shown here, what INSERT statement would add a new Order for person Hansen? Is it possible to add a new order with one sql statement or does it require two statements?The only way I have found to add a new order is to first SELECT the P_Id for Hansen from the Persons table. Then the new row containing Hansen's P_Id would be INSERTed into the Orders table. But this seems like a function that sql should be able to perform in one statement.For example, why won't an embedded select statement similar to the following work?INSERT INTO ORDERS (OrderNo, P_Id)values (12345,select P_Id from persons where LastName = 'Hansen')I want to do this in a sqlite database.thanks
Updating the column MySQL via php
14/8/2011 external link
I am trying to insert the values to mytable, however the column 'img' has to take the blob value from table images where id='matchid'. I tried running the $query then again updating using update table. However, I am unable to do so. Please I need some help...$query = "INSERT INTO mytable (link, nick, img) VALUES ('$name','$pf','$#####') ";$##### has to be 'SELECT (image) FROM images WHERE id='$matchid';
PHP+SQL Issue
14/8/2011 external link
What this Code does is that it helps you achieve Facebok/Twitter Style Pagination. Running Part 1 it loads First 3 ROWS of the MySQL database. Running Part 2 loads the next 3 ROWS of the database. Then you can run Part 2 as many times as you want & it would always load the next 3 ROWS of the database.The Normal Code for this is:-CODEPART1:<?php$query ="SELECT * FROM table ORDER BY id DESC LIMIT 3";$result = mysqli_query($dbc,$query);while($row=mysqli_fetch_array($result)){$row_id=$row['id'];<!-- SOME CODE TO BE EXECUTED -->}?>PART2:<?php$query ="SELECT * FROM table WHERE id>".$row_id." ORDER BY id DESC LIMIT 3";$result = mysqli_query($dbc,$query);while($row=mysqli_fetch_array($result)){$row_id=$row['id'];<!-- SOME CODE TO BE EXECUTED -->}?>Now in my version of the code. I want to order things according to CPC & CPC can be any integer from 10-1. Part 1 of the code is no issue, but how can i make a Part 2 so that every time the next 3 ROWS from the database are listed?Sample Table:ID -- Name -- Country -- CPC01 -- Jhony -- USA -- 1002 -- Tomy -- UAE -- 703 -- Bond -- UK -- 304 -- Ben10 -- USA -- 805 -- Juliana -- UAE -- 106 -- Medina -- UK -- 5CODEPART 1:<?php$query ="SELECT * FROM table ORDER BY cpc DESC LIMIT 3";$result = mysqli_query($dbc,$query);while($row=mysqli_fetch_array($result)){$row_id=$row['cpc'];<!-- SOME CODE TO BE EXECUTED -->}?>Please help as soon as possible :-) Thanks!
PHP Try It Your Self
13/8/2011 external link
www.phptry.com I Have create a website for biggners to learn php online and excute their scripts. Visithttp://www.phptry.com
simple form to update database
13/8/2011 external link
edit: I got it working now, ive updated the code just incase it helps anyone down the lineHi guys, I have been searching the internet for about 5 hours now trying to find a tutorial I can understand to update some information in my database.I have half gotten a few working, and I'm fairly comfortable with forms now. Its just the update.php page that I just cant seem to get right.Would anybody be able to show me the simplest code to just update the row 'age' from my database called 'people' where the id is '1'Im hoping If i can understand the basics I can build up to what i want it to finally do.Thanks for any helpThis is one of the codes I have tried to get working.CODE// Connect to server and select database.mysql_connect("$host", "$username", "$password")or die("cannot connect");mysql_select_db("$db_name")or die("cannot select DB");// Get values from form$current_hp = $_POST['current_hp'];$current_mp = $_POST['current_mp'];$current_ap = $_POST['current_ap'];// Insert data into mysql$sql = "update game_char set current_hp='".$_POST['current_hp']."' ,current_mp='".$current_mp."',current_ap='".$_POST['current_hp']."' where id='1'";$result=mysql_query($sql);// if successfully insert data into database, displays message "Successful".if($result){echo "Successful";echo "<BR>";echo "<a href='/testdir/cloud/?x=navigation&y=dbtest'>Back to main page</a>";}else {echo "ERROR";}// close connectionmysql_close();?>This echos the error when I submit my form and I cant see why, any ideas?
Pass Data on Header Refresh To Same Page?
13/8/2011 external link
Is there anyway to pass a variable or data or something on a Header Refresh to the same page?I need to refresh a page every 30 sec, and after the 1st refresh I need to display some different content that will also keep refreshing every 30sec, but cant change on subsequent refreshes...How could I accomplish this?
Tables Background
13/8/2011 external link
Hi,im encountering conflict about alternate table TR background in loop..here's my code made with a white background:CODEwhile($rows=mysql_fetch_array($result)){echo "<tr bgcolor='#fff'>";echo "<td>" . $rows['id'] . "</td>";echo "<td>";echo "<a href='view_topic.php?id="; echo $rows['id']; echo "'>" . $rows['topic'] ."</a>"; echo "<BR></td>";echo "<td align='center'>" . $rows['view'] . "</td>";echo "<td align='center'>" . $rows['reply'] . "</td>";echo "<td align='center'>" . $rows['datetime'] . "</td>";echo "</tr>";}now im planning to have an alternate background white - grey - white - grey and i put the code like this.CODEwhile($rows=mysql_fetch_array($result)){ echo "<tr bgcolor='#fff'>";echo "<td>" . $rows['id'] . "</td>";echo "<td>";echo "<a href='view_topic.php?id="; echo $rows['id']; echo "'>" . $rows['topic'] ."</a>"; echo "<BR></td>";echo "<td align='center'>" . $rows['view'] . "</td>";echo "<td align='center'>" . $rows['reply'] . "</td>";echo "<td align='center'>" . $rows['datetime'] . "</td>";echo "</tr>";echo "<tr bgcolor='#eee'>";echo "<td>" . $rows['id'] . "</td>";echo "<td>";echo "<a href='view_topic.php?id="; echo $rows['id']; echo "'>" . $rows['topic'] ."</a>"; echo "<BR></td>";echo "<td align='center'>" . $rows['view'] . "</td>";echo "<td align='center'>" . $rows['reply'] . "</td>";echo "<td align='center'>" . $rows['datetime'] . "</td>";echo "</tr>";}its displayed the alternate background but the content is the same the ID 1 will display in the white background im expecting the ID 2 will be displayed on grey background but it happen the the ID 1 will display also in the grey background it will duplicate the content..
information_schema permission
13/8/2011 external link
I am trying to import a routine into information_schema. In the permissions it says that root has ALL access to the table but when I try to import the routine I keep getting:#1044 - Access denied for user 'root'@'localhost' to database 'information_schema' I tried to do it directly from Webmin but it says I need to add a primary key to the table before I can edit it. When I try to add a new field as a primary key I get an error:failed : Access denied for user 'root'@'localhost' to database 'information_schema'anyone know how to add a routine?edit I just found where to add privileges to the information_schema table in phpMyAdmin.. i logged out, back in, and checked to see if the privileges were saved, they were.... but then I tried inserting into the routines table again and I got the same message about root@localhost does not have privileges to database information_schema
adding <strong> inside an echo
12/8/2011 external link
Hey, I was hoping someone could tell me how I can wrap <strong></strong> around .$total_time.' seconds without causing an error?echo 'Page generated in '.$total_time.' seconds.'."\n";Thanks.
Forms - calling PHP
12/8/2011 external link
What I am trying to accomplish is very simple. I just do not have enough knowledge to completely figure it out. Ive googled it and a couple things pushed me in right direction but I still have not gotten this to work.Originally I did:CODE<form name="form1" method="post" action="checkAdmin.php">So it would direct to that page and run the function on it:CODE$adminPass="123";// username and password sent from form$password=$_POST['password'];if($password==$adminPass) else { echo "Wrong Password";}It works fine. However I no longer want it to direct to another page to tell me that the password is incorrect. I would prefer it if it showed text "wrong password". So I tried changing the form line to:CODE<form name="form1" method="post" action="<?php checkAdmin() ?>">And putting the code that was in checkAdmin.php into a function called checkAdmin().Whats happening though is it is passing "Wrong Password" through the url as "Wrong%20Password", still trying to direct to another page. Is this maybe because I am posting? I know the other option is "get" but that doesnt seem right either.Just need a little help how to get the text to show on the same page that the password was wrong.
BB Codes (Pre-Database vs. Post-Database)
12/8/2011 external link
I'm building a forum, and I've got a BB code & emoticon parsing script to parse users' posts, but is it better to parse posts before they are written to the database, or after they are loaded from the database? Both options have benefits, but I don't know which is a better option. there seem to be four major differences between the two strategies.With pre-database parsing, we get:Less processing used, because it won't need to be parsed each time the topic is loadedMore database space used, because the XHTML is longer than its BB code / emoticon equivalentNo on the fly BB codes, such as (user)7(/user), which shows the current name of a user, helpful for referring to a user, who may change their nameI'd need to build a de-parser, for when users edit their postsWith post-database parsing, we get:More processing usedLess database space usedDynamic BB codes, such as (user)7(/user), which shows the current name of a user, helpful for referring to a user, who may change their name, or (post)561(/post), to quote another's post, without the quote taking up more room in the databaseNo need for a de-parserAny feedback or suggestions would be greatly appreciated.
Error messages in forms
12/8/2011 external link
How do you do then sending messages to the user then some input fields are missing then submiting.Js stoping them from sending.cookies, get, submit script on the same page?Looking for insperation.
Storing individual key values to database
11/8/2011 external link
I am currently testing facebook PHP API but unsure how to store the values to MySQL.I am able to output the array data of my facebook info as follows with the code using the facebook php SDK:CODEforeach ($user_profile AS $key =>$value){ echo "\$key = " . $key . "<br />"; echo "\$value = " . $value . "<br />";}QUOTE $key = id$value = 123456789$key = name$value = First Last$key = first_name$value = First$key = last_name$value = Last$key = username$value = abcd$key = hometown$value = Array$key = location$value = Array...How do I insert the data into mysql if let say my table name is user_info and have the following fields: facebook_id, first_name, last_name, username, hometownIs there a method to get the values from sub-arrays as well?
Filter Multiple Records
11/8/2011 external link
Hi AllI need help in the following code, I have a filter in a repeat recordset, the filter works fine for one record, "Image_all" is where the filter is, there are 2 records in that,1042260774, and -475803217.I need to display results for 1042260774 and -475803217. At the moment I am getting results for 1042260774 only but repeated by 2.Please have a look at my attempt to do this:<%While ((Repeat2__numRows <> 0) AND (NOT layout_loop.EOF)) Dim Image_allimage_all = (Layout_images_conn.Fields.Item("Image_all").Value)%><%png_images.Filter="PNGID='"&image_all&"'"%><p>image = <%=(png_images.Fields.Item("head_TX").Value)%><%png_images.Filter=""%> <% Repeat2__index=Repeat2__index+1 Repeat2__numRows=Repeat2__numRows-1 layout_loop.MoveNext()Wend%>I have to use repeat nesting to get this to work.
foreach loop on query
11/8/2011 external link
Hi there,I have a foreach loop which loops through items in an array in PHP. Each value in the array is then checked and a column in a database table is checked. If the item is in the database i wish to print out the results onto the screen.The problem i have is that it seems to check the first item from the array and then it doesn't check the rest. I have looked on the internet about searching items in a foreach loop and doing a mysql query for each item and it seems to be a common problem.My code is as follows:CODE$clubs = array(Liverpool[eng](1996-2004), Real Madrid(2004-2005), Newcastle United(2005-2009), Manchester United(2009-Present)); #loop through items in array $clubs foreach ($clubs as $club) { #split the club up by "(" to just leave the team name i.e. removing the years $clubname = explode("(", $club); #search through database where the teamname is equal to $clubname $query1 = "SELECT * FROM ClubID WHERE teamname = '$clubname[0]'"; $result1=mysql_query($query1) or exit(mysql_error()); $num1=mysql_numrows($result1); $i=0; while ($i < $num1) { #since the teamname might have been found more than once we do while loop here #print out the result and then increment inner loop print mysql_result($result1,$i,"teamname"); $i++; } }ok so that is my code, it prints out the first team name ok, i.e. Liverpool[eng] prints out fine but the rest do not, any ideas why it will not keep looping through the rest of the clubs inside the array $clubs? All of the teams do exist in the database and the spellings are all correct.Many thanks,Mark
Querystring in a rewrite rule
11/8/2011 external link
Hi!I have a rewrite rule that picks up a .htm page and puts the file name onto a querystring on a php page:RewriteRule ^([^/\.]+).htm$ page.php?for=$1 [L]Am I able to setup a new rule that looks for a set query string on the .htm file and rewrites to a different php file.So amazon.htm currently rewrites to page.php?for=amazonI want:amazon.htm?flag=true to write to newpage.php?for=amazon
Variables outside of classes
10/8/2011 external link
Hey guys, I have searched for the answer here but can't find anything. Ironically this probably a basic question, but I have never had the need to come across this.... Background: My script is broken down into: getdata.php check_data_class.php I am using includes so for simplicity, treat this as all on one script. The output.php is a simple script that receives post data from a form and processes it. I have it set up to first check the data and make sure the data is correct; example(is_numeric, strlen). I have wrote a class to handle this procedure. I want the class to check the data and return an array if errors are present. Then if my errors array is !empty, it will loop through and print the errors. Question: How should I go about declaring the $errors = array(); Should I declare it outside of the class, or inside the class a public? Here is the class, as of now I tried using 'return' to write to the array but its not working when I try and loop though it. I know my 'foreach' and the rest of the code is right, I think this is a scope problem. Anyone know, thank you in advance.CODE<?phpinclude_once 'output.php'; class check_data { public function check_input ($target,$id) { $errors = array(); if(!is_numeric(($target)) { $errors[] = 'The' . $id . 'field may only be digits'; } if(strlen($target) > 2) { $errors[] = 'The' . $id . 'field must be only 2 digits in length'; } return $errors; }}?>
Current Date
10/8/2011 external link
Hi all,I have the follwoing query.I am trying to get the report for the current date and it seems to me I have the date formula wrong!!select EMPLOYEE, COUNT(NUMBERCALLED)as Total_CALLSFROM SDDTA.PhoneReportWHERE MANAGERNAME = 'Alec Harf' anddate = date( NOW())group by EMPLOYEEAny help??
Date
10/8/2011 external link
I have a form that allows the user to enter a date. This date is saved in an Mysql Table with the field type set to "date".It keeps saving the information in YYYY-MM-DD. Format.I need the user to enter the information in a simple format (ie MM-DD-YY. example 11-06-11)and when submitted, I need it to be stored as Tue Nov 6Please help.Starting point. Should I have dorp down boxes with all the weeks days, then another for the months, and another for the day? If so, will the information be stored in a manner that the php script can later compare dates?? and what if the user enters Tuesday Nov 6th, but november 6th is actually a wednesday?? I need it to be right.Thank you in advance.
PHP Include
10/8/2011 external link
Hi i have a problem when im adding (include) function. WHen im adding it its adds a break space (empty line), How can i fix it or is there any other solution?
MySQL Complicated Query
10/8/2011 external link
Hi Friend.I want a query to find some ids from field. But it's so difficult for me.table field name: product_idsproduct_ids (value): 1, 2, 3, 4, 5 (These all values are in one field with comma, It's a set of id's in one record field).Now i want to search 3 & 4 from this field.If user find 3 & 4, so i'll have to search 3 & 4 from product_idsI've tried "like" & "in"... But! still getting issue.Please help me out.I Tried E.g:1) select * from table_name where product_ids in (3, 4) // Not Working...2) select * from table_name where product_ids like '%3%' or product_ids like '%4%' // Not Working...Please help me out friends.Specially waiting for (justsomeguy, thescientist, boen_robot) replies, please help friends.
MySQL Complicated Query
10/8/2011 external link
Hi Friend.I want a query to find some ids from field. But it's so difficult for me.table field name: product_idsproduct_ids (value): 1, 2, 3, 4, 5 (These all values are in one field with comma, It's a set of id's in one record field).Now i want to search 3 & 4 from this field.If user find 3 & 4, so i'll have to search 3 & 4 from product_idsI've tried "like" & "in"... But! still getting issue.Please help me out.I Tried E.g:1) select * from table_name where product_ids in (3, 4) // Not Working...2) select * from table_name where product_ids like '%3%' or product_ids like '%4%' // Not Working...Please help me out friends.Moved: http://w3schools.invisionzone.com/index.php?showtopic=39249
dynamic page titles
9/8/2011 external link
HiHow can I use use the h1 tags as the title of the page.What do I need to do.Cheers
adding a zero to a decimal
9/8/2011 external link
if $a - $b = 16.2Is there a function that will display the result as 16.20? If so, which one?I'd like to avoid an if statement.
Make CURL Return Basic Text Version of Webpage?
9/8/2011 external link
http://www.google.com/gwt/x?u=http://cqcou...php&noimg=1How can I curl a website and have the response data be striped down like the link above.?is there anyway to make curl return just the basic most parts of a webpage like just its text and links and that's it..?
Difficulty with first database table query
9/8/2011 external link
I cannot get past this error code;Parse error: syntax error, unexpected T_LNUMBER, expecting ',' or ';' in C:\Inetpub\vhosts\weekdayweddings.net\httpdocs\asptestquerypage\Index.php on line 34The code I've used isCODE<?php$user_name = "";$password = "";$database = "";$server = "localhost:3306";$con = mysql_connect($server, $user_name, $password);if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("testcall", $con);$result = mysql_query("SELECT * FROM Stock No");$result = mysql_query("SELECT * FROM Price");while($row = mysql_fetch_array($result)) echo "<table border='1'><tr><th colspan="2" align="center"><img src="images/A0001.jpg"></th><th colspan="2" align="center"><img src="images/A0002.jpg"></th></tr>";while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td align="left">" . $row['Price WHERE Listed="1" '] . "</td>"; echo "<td align="right">" . $row['Stock No WHERE Listed="1" '] . "</td>"; echo "<td align="left">" . $row['Price WHERE Listed="2" '] . "</td>"; echo "<td align="right">" . $row['Stock No WHERE Listed="2" '] . "</td>"; echo "</tr>"; }echo "</table>"; mysql_close($con);?>Line 34 is the first line that begins................ echo and is all on one line in the codeI have checked and rechecked the quote marks but they all seem to follow the proper 'pairing' rules.I assume that I am making the right connection to the database?The page can be found at www weekdayweddings net website in the root folder asptestquerypage (Sorry if I should not post this, I couldn't find the rules on u r l s.grateful for any help,edwind
Create array from db results
9/8/2011 external link
Hi guys ,, I want a help to create an array like this array('XXX'=>array(name=>' yyyy''VVV'=>array(name=>'uuuu'))I want this to implement nested check boxes so the values (XXX,VVV) just header not check box, so I make a field in the db table call selected as the following:IDname parent_idselectedbest wishes
Lowercase all file/folder names
9/8/2011 external link
To combat the issues arrising from users entering folder and/or file names with uppercase letters (I only use lowercase) I included a file at top of web pages as:CODE$trailed = $_SERVER['REQUEST_URI']; if (preg_match('/[A-Z]/', $trailed)) { $trailed = strtolower($trailed); header('HTTP/1.1 301 Moved Permanently'); header('Location: http://'. $_SERVER["SERVER_NAME"] . $trailed); exit; }However, it shows 404 error when I uppercase a letter for testing for example. I also tried:if (preg_match('/[[:upper:]]/', $trailed)) but also does not work. I am open to any solution. Tried few via .htaccess, but also no luck (and no access to config file)...Any ideas?Son
CURL + MULTI-THREADING..?
9/8/2011 external link
I need to CURL 3 URL's Simultaneously and also Simultaneously Perform a get_string_between() function on the return results for each of those 3 CURL'ed URL's..!!!If its possible, whats the best way to do this?, any code examples?
gethint.asp example not working
9/8/2011 external link
Hello,I have copied and pasted the gethint example, on my home computer, from this webpage:http://www.w3schools.com/asp/asp_ajax_asp.aspThis is my HTML page with the java script:=======================================<html><head><title>Test Page :: ASP Arrays</title><link rel="stylesheet" type="text/css" href="css/aspStyle.css"/><script type="text/javascript">function showHint(str){var xmlhttp;if (str.length==0) { document.getElementById("txtHint").innerHTML=""; return; }if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); }else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } }xmlhttp.open("GET","gethint.asp?q="+str,true);xmlhttp.send();}</script></head><body><h3>Start typing a name in the input field below:</h3><form> First name: <input type="text" id="txt1" onkeyup="showHint(this.value)" size="30" /></form><p>Suggestions: <span id="txtHint"></span></p> <br/><br/><div style="text-align:center;"><a href="index.aspx">home</a></div></body></html>And here is the gethint.asp server page:==================================================<%dim a(30)response.expires=-1'Fill up array with namesa(1)="Anna"a(2)="Brittany"a(3)="Cinderella"a(4)="Diana"a(5)="Eva"a(6)="Fiona"a(7)="Gunda"a(8)="Hege"a(9)="Inga"a(10)="Johanna"a(11)="Kitty"a(12)="Linda"a(13)="Nina"a(14)="Ophelia"a(15)="Petunia"a(16)="Amanda"a(17)="Raquel"a(18)="Cindy"a(19)="Doris"a(20)="Eve"a(21)="Evita"a(22)="Sunniva"a(23)="Tove"a(24)="Unni"a(25)="Violet"a(26)="Liza"a(27)="Elizabeth"a(28)="Ellen"a(29)="Wenche"a(30)="Vicky"'get the q parameter from URLq=ucase(request.querystring("q"))'lookup all hints from array if length of q>0if len(q)>0 then hint="" for i=1 to 30 if q=ucase(mid(a(i),1,len(q))) then if hint="" then hint=a(i) else hint=hint & " , " & a(i) end if end if nextend if'Output "no suggestion" if no hint were found'or output the correct valuesif hint="" then response.write("no suggestion")else response.write(hint)end if%>=========================It won't work. No "hints" appear when typing letters a through z.Thanks for your help.
Insert into table error
9/8/2011 external link
I keep getting this error:Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VALUES ('1234567890000','adsf','asdf','sdaf','asdfasdf','sdfsa','safsd','sfsa','' at line 2My form is here:<form action="insert.php" method="post">Acct#: <input type="text" name="acctnum" />Rep ID: <input type="text" name="repid" />Rep Name: <input type="text" name="repname" />Previous Service: <input type="text" name="prevserv" />Offer Code: <input type="text" name="offercode" />Customer Name: <input type="text" name="custname" />Customer Address: <input type="text" name="custaddr" />Customer Phone Number: <input type="text" name="custphone" />Customer Zip Code: <input type="text" name="custzip" />Credit Card Type: <input type="text" name="credittype" />Last 4 Digits of Credit Card: <input type="text" name="creditlast4" />How was the sale received?: <input type="text" name="salercvd" />Order Date: <input type="text" name="orderdate" />Install Date: <input type="text" name="installdate" /><input type="submit" /></form>PHP snippet here:mysql_select_db("tvbscustomer", $con);$sql="INSERT INTO Sales (Acct#, Rep ID, Rep Name, Prev Serv, Offer Code, Cust Name, Cust Addr, Cust Phone, Cust Zip, Credit Type, Credit Last 4, Sale Rcv'd, Order Date, Install Date)VALUES('$_POST[acctnum]','$_POST[repid]','$_POST[repname]','$_POST[prevserv]','$_POST[offercode]','$_POST[custname]','$_POST[custaddr]','$_POST[custphone]','$_POST[custzip]','$_POST[credittype]','$_POST[creditlast4]','$_POST[salercvd]','$_POST[orderdate]','$_POST[installdate]')";Any ideas? I'm new to databasing so pardon if the code is sloppy or makes no sense.
FastCGI Used as an Apache Module
8/8/2011 external link
BACKGROUND: Hooray, hooray! Although I have not yet done it, I have decided to dump MAMP-Pro permanently. This said, I do not want to actually do it until I have something to replace it. Recently I read a portion of a discussion on CGI Binary and CGI as an Apache module. In that discussion there was mention of something called FastCGI. So, I explored a bit and discovered that the Apache server application has a FastCGI module.QUESTION ONE: Would someone like to address the pros and cons of using FastCGI as an Apache module as opposed to an extension of the CGI Binary?QUESTION TWO: Does Apache's FastCGI module work well with MAMP (not MAMP-Pro, mind you)?Roddy
regex to get id and date from string
8/8/2011 external link
Hey.So I am working on a mobile mail web app, and I need to implement a different sort of fetching of messages from an IMAP server due to performance issues. Unfortunately I have very little regex experience and need some help accomplishing the retrieval of data from the response.Sample ResponseCODE* 1 FETCH (FLAGS (\Seen) INTERNALDATE " 2-Jul-2009 20:12:11 -0400" RFC822.SIZE 1462)* 2 FETCH (FLAGS () INTERNALDATE " 2-Jul-2009 20:21:25 -0400" RFC822.SIZE 1462)* 3 FETCH (FLAGS () INTERNALDATE " 2-Jul-2009 20:33:53 -0400" RFC822.SIZE 1461)..* 25 FETCH (FLAGS () INTERNALDATE "11-Jul-2009 06:31:59 -0400" RFC822.SIZE 1491)The first number is the messageId and in between the quotes is a timestamp of the message as it was received. I need to be able to get the number _and_ the date out. I have the date using it's own preg_replace_all, and I'm sure I can do the ID just as easily, and then loop though both match arrays and make a cumulative multidimensional array such as each index would be a corresponding ID and timestamp.However, I am a wondering if a regex could somehow do them both at the same time (and what might that look like), or should I try and extract each piece of info out separately and then "merge" the two arrays into a custom structure that I can use in my app?Thanks in advance for any advice and consideration.edit: if anyone has any advice on how to just get the ID, that would be helpful too... edit edit: I guess I could just explode on the * and get the text before the first space.
Securing Input fields and use of BBcOde
7/8/2011 external link
Hi there,anyone here can help me filter my input field to avoid php hack..
Tracking emails
7/8/2011 external link
Hey all,So I am currently writing a nice little application that allows users to create email flyers then blast them out to fellow email list subscribers. Initially I was planning on tracking by placing an iFrame in the email body that was 0x0 which inside holds my tracking scripts. Though quickly I found out this is impossible as most email clients like Gmail and the such don't allow them to load... So after some quick research I believe most people accomplish this by placing a small invisible image in the email then they track how many times that image was rendered...I guess my question is, does anyone have any good ideas about how to track emails that are opened? Does the image thing work and if so could someone show me a how to or point me to one on the internet... I tried googling but to my dismay I didn't find anything detailed enough... Maybe I am not searching the right terms.btw my sites running on an apache server in a shared host environment...and the end goal is to get that number in an mysql column, updating as people open...pstoo bad iframes don't work because all I needed was a simple SET readEmail = (readEmail + 1) in the frame to get my desired data.
How To Find Edges of a Group of Points?
7/8/2011 external link
You don't need any java programming knowledge for this but it's written in java so I'll post it here.I have a 2 dimensional array of point objects. Each contains a row and column variable and a list of properties for that point. Points share property lists and can be grouped by their "PointPropertyList" id. So seen above is a group of points (green points surrounded by grey) surrounded by a second group (blue points). I want to draw a polygon around these points so I need to find the edges. I can easily find the edges by just checking to see if it has a neighboring point of the same group on each side. If it doesn't then it must be an edge.The issue I have is that after finding the edges and adding it to an array of other edge points- it is unordered. So I need to order the points so I can use Graphics2D to draw a polygon around them.tl;dr:Given an array of edge pointsHow can I determine the correct order of points from an unordered array of points?How can I determine if the shape is concave or convex?CODE0,0,0,0,0,0,0,0,0,00,1,1,0,0,0,0,0,0,00,0,1,1,0,0,0,0,0,00,0,1,1,0,0,0,0,0,00,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,0
transport variable from JS to PHP
6/8/2011 external link
Hi all,I have a variable in JS, which I need in PHP, but can't get it done....Googlesearch gave me: NOT POSSIBLE, unless page is reloaded, cause JS is client side and PHP is Server side...But I can't reload the page, so how can I manage it?
[solved] problem assigning GET into a variable
5/8/2011 external link
hello there,I have a problem of assigning GET array into a variable, but, without an assignment and I use the array instead, it worked. Below is the example:The example i tried below is working:CODE<?php$fopen = fopen('comment.xml','r+');while(!feof($fopen)) { $comment = $comment.fgets($fopen); }$thecomment = str_replace('</commentdata>','',$comment);$newcomment = $thecomment.'<comment><user>'.$_GET['user'].'</user><content>'.$_GET['comment'].'</content><date>'.$_GET['date'].'</date></comment></commentdata>';fwrite(fopen('comment.xml','w'),$newcomment);fclose($fopen);?>But when I assign it into a variable first, my xml became scattered with the value of the array around it. Below is the example, when I assign:CODE<?php$user = $_GET['user'];$comment = $_GET['comment'];$date = $_GET['date'];$fopen = fopen('comment.xml','r+');while(!feof($fopen)) { $comment = $comment.fgets($fopen); }$thecomment = str_replace('</commentdata>','',$comment);$newcomment = $thecomment.'<comment><user>'.$user.'</user><content>'.$comment.'</content><date>'.$date.'</date></comment></commentdata>';fwrite(fopen('comment.xml','w'),$newcomment);fclose($fopen);?>Any explanation, why this things happen? Thanks a lot guys!
What is this called Im trying to achieve?
5/8/2011 external link
I am not familiar with php enough to know what this is called that I am trying to achieve. What I want to do is collect some info (username) in a form. Then in another form query that info and be able to update that table with other values. Best way I can describe it is with exactly my needs. For example I want have a signup form that will allow you to sign up for a series of events. So first all a user can do is sign up for the "series". Then after the first event you have a form that displays the users that signed up for the series. But with a field for each user to be updated with a numerical value "1-12" then save/update. And after the next event you view the form and it will show the same numerical field and you enter a number again for each user until you have completed it for each event. 1. signup for an event. only field is a user name.2. have a page where I can display those usernames, and add other values. In this case it would be numbers 1-12 for usernames then save it. Does that explain what I'm building my forms for?That would accomplish my first feat in trying to setup with this application. I do not know what this type of functionality is called with taking data collected from a form, displaying it in another, and updating it. I have googled and searched w3schools and I havent come across the proper terminology that I know of that tells me what that is I am trying to do. It all stops with data collected either emailed, or simply just printing the data out in all the basic php form tutorials I have read. All I am requesting is some help in the right direction, with the name of this type of function so I can read up on this and learn how to achieve the end result. I feel pretty confident in reading documentation and practicing. But its a pain when I dont know the language enough to search for help adequately. Any help would greatly be appreciated, Thank you!
SelectedRow - GridView
5/8/2011 external link
HelloI have some data in a Gridview, selection is enabled, i need to be able to select a row and get the content of the first cell from that row. Here is the code:CODE Public Sub codeGridView_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles GridView1.RowCommand Dim row As GridViewRow = GridView1.SelectedRow Response.Write(row.Cells(1).Text) End SubI have this property set in the GridView control:CODEonselectedindexchanged="codeGridView_SelectedIndexChanged"There is no errors in the IDE but when i try to select a row the browser quits and i get this error in the IDE:CODENullReferenceException was unhandled by user code.Object reference not set to an instance of an object.Whats wrong ?Any help is greatly appreciated.Kind regards Mads Nielsen
I want to insert into table of my DB but it doesn't work
5/8/2011 external link
:rolleyes:people HiI need to insert a row into a table of my database, then here is a brief code as an example, anyone that would help me to resolve PLEASE <?php require_once('../Connections/elena.php'); ?><?phpfunction GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue;}$editFormAction = $_SERVER['PHP_SELF'];if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);}if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO boys(married, name) VALUES (%s, %s)", GetSQLValueString($_POST['married'], "int"), GetSQLValueString($_POST['name'], "text")); mysql_select_db($database_elena, $elena); $Result1=mysql_query($insertSQL,$elena) or die(mysql_error()."- Query -".$insertSQL); $insertGoTo = "index.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo));}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Process Example</title><style type="text/css"><!--body,td,th { color: #FFFFFF;}body { background-color: #0099CC;}.Estilo1 {font-family: Arial, Helvetica, sans-serif}.Estilo5 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; }.Estilo6 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; }--></style></head><body><form method="post" name="form1" action="<?php echo $editFormAction; ?>"> <input type="hidden" name="MM_insert" value="form1"></form><form action ="<?php echo $editFormAction; ?>"method="POST" enctype="multipart/form-data" name= "form1" > <h1><span class="Estilo1">Title</span></h1> <fieldset id="married"> <input name="married" type="radio" value="Yes" id="married_yes" <?php $OK = isset($_POST["married"]) ? true : false; if ($OK && isset($missing) && $_POST["married"] == "Yes") { ?> checked = "checked" <?php } ?>/> <label for = "married_yes">Si</label> <input name = "married" type="radio" value="No" id="married_no" <?php if ($OK && isset($missing) && $_POST["married"] == "No") { ?> checked="checked" <?php } ?> /> <label for ="married_no">No</label> </p> </fieldset> <p class="Estilo5">Name</p></form><p> <label> <textarea name="name" cols="95" rows="1" id="name"></textarea> </label></p> <label>Save <input name="submit" type="Submit" value="Save" /> </label></body></html>Thank You I'm expecting a help, when I know to program in PHP I will help too, I know VisualFox 9 but I need to learn PHPmy email is nueva123@hotmail.com
pagination
5/8/2011 external link
Hi againfirst im sorry for asking plenty questions im new at php and im willing to earn knowledge on this part..anyone here can help me to make a pagination..and i have a question about how can i make secure input fields? using a real escape string it will this disable special characters right.. but i heard someone telling there's a counter part about that? anybody here can suggest me how to secure the input fields..and about the BB Code how can i work with that also..
[NEVERMIND] custom MemberShipProvider and UserProfile
5/8/2011 external link
I've already made my custom MemberShipProvider but now i would like to associate it with UserProfile using my specific fields. The problem is i can't find any good tutorial or article on how to do this...can anyone guide me in the right direction?by the way i'm a newbie to ASP.NET MVC3 and am using C#Edit: ok nevermind, i found what i was looking for.
[Solved]Won't add data to database
5/8/2011 external link
The topic title says is all...Here's my code:CODE<html><head><title>Registrer film</title></head><body><center><p><a href="./">Hjem</a></p><?phpif($_POST["movie"]){$con = mysql_connect("localhost","******","*********");if (!$con) { die('Så sier databasen: ' . mysql_error()); }mysql_select_db("*****", $con);$movie=mysql_real_escape_string($_POST["movie"], $con);$rel=mysql_real_escape_string($_POST["release"], $con);$age=mysql_real_escape_string($_POST["agelimit"], $con);mysql_query("INSERT INTO movies (name ,agelimit ,release ,added)VALUES ('".$movie."', '".$age."', '".$rel."', CURDATE())");mysql_close($con);echo "<font color='green'>Filmen er registrert</font>";}else if($_POST&&$_POST["movie"]==""){echo "<font color='red'>Du må skrive inn navnet på filmen.</font>";}?><form method="post" action="add.php"><p>Navn<font color="red">*</font>:<br><input type="text" name="movie" value="<?php echo $_POST["movie"]; ?>"></p><p>Utgivelsesår:<br><input type="text" value="<?php echo $_POST["release"]; ?>" name="release"></p><p>Aldersgrense:<br><input type="text" value="<?php echo $_POST["agelimit"]; ?>" name="agelimit"></p><button type="submit">Lagre</button></form></center></body></html>
POST data according to a button
5/8/2011 external link
Hello!I have a form with a textbox. All I want to do is to post the data to a page according to which button was clicked.Suppose that I ask for the user to input an ID. Then there are two buttons: Edit and Delete. The edit button must send the ID to the edit.php and the delete button to the delete.php.CODE<form method = "post" action ="?"><input type = "text" id = "ID" /><input type = "submit" value = "Edit" onClick="window.location=''edit.php"/><input type = "submit" value = "Edit" onClick="window.location=''delete.php"/>Well, I know it doesn't work but I want one form because if I am going to use two forms I will mess the layout (I will add more buttons.)Any idea please?
ADT Plugin for eclipse
5/8/2011 external link
ADT plugin for eclipseI've downloaded the latest plug-in Of ADT 12.0.0(android development tool)and i want to build Android applications.Developing in Eclipse with ADT is highly recommended and is the fastest way to get started. So I want to add it to my eclipse IDE so that i could carry on with my project. Please suggest me a way solve the problem.!!
Header Location/Refresh - Open New Window..?
5/8/2011 external link
I need to find a way without using JavaScript to make my php page open a URL into a new tab/window..!!so if the person visits "http://mysite.com/index.php?REF=AAA&URL=http://google.com"http://google.com opens in a new tab/window and the index.php still loads its contents in the 1st tab/window.anything like that possible with php, or am i gunna need JS for this..?
Query on each separate web page for same data?
4/8/2011 external link
I have few web pages sitting in separate folder that have an extra style and top text that can be changed by end user, but stays consistent across all pages in the mentioned folder. I retrieve page data as content and feature photo for all pages individually, but wondered what way is best to do this for the extra style info and top text? If I run query on each page I might unnecessarily burden the web server, but then each page could be accessed directly and I need to make sure I check for the relevant data in database... did anyone do this before and has any recommendations?Son
Filling database?
4/8/2011 external link
I have searched the web, but can't find the answer to this. I know how to add and extract info from db with php. But I have to fill a database with lot of things (couple thousand records) how can I do that best? Is it possible to fill it in like on the table like you do in access and sort of in excell? So can you fill it fiscally in the table, or has it to be done with code? (php code or sql lines)
I need to insert into my table "diagini1" I'M ELENA
4/8/2011 external link
Hi, Please Help Me!!! I have a form where a lot of answers with radiogroup are selected but when I press button Enviar (or Submit) it doesn't function, I checked my table on my database and doesn't have any information, then my insert doesn't function, this is the code:<?php require_once('../Connections/elena.php'); ?><?php include('xalumno.php'); ?><?phpfunction GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue;}$editFormAction = $_SERVER['PHP_SELF'];if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);}if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO diagini1(cct,ze,nombre,edad,grado,grupo,comprende1,comprende2, comprende3,comprende4,comprende5,comprende6,comprende7,comprende8, comprende9,comprende10,com1,com2,com3,com4,com5, com6,com7,logmat1,logmat2,logmat3,logmat4,logmat5, convive1,convive2,convive3,convive4, learn1, learn2, learn3, probmot, cualprobmot, probdesotro, observa, total, nom_maestro, nom) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s, %s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)", GetSQLValueString($_POST['cct'], "text"), GetSQLValueString($_POST['ze'], "text"), GetSQLValueString($_POST['nombre'], "text"), GetSQLValueString($_POST['edad'], "int"), GetSQLValueString($_POST['grado'], "int"), GetSQLValueString($_POST['grupo'], "text"), GetSQLValueString($_POST['rb_comprende1'], "int"), GetSQLValueString($_POST['rb_comprende2'], "int"), GetSQLValueString($_POST['rb_comprende3'], "int"), GetSQLValueString($_POST['rb_comprende4'], "int"), GetSQLValueString($_POST['rb_comprende5'], "int"), GetSQLValueString($_POST['rb_comprende6'], "int"), GetSQLValueString($_POST['rb_comprende7'], "int"), GetSQLValueString($_POST['rb_comprende8'], "int"), GetSQLValueString($_POST['rb_comprende9'], "int"), GetSQLValueString($_POST['rb_comprende10'], "int"), GetSQLValueString($_POST['rb_com1'], "int"), GetSQLValueString($_POST['rb_com2'], "int"), GetSQLValueString($_POST['rb_com3'], "int"), GetSQLValueString($_POST['rb_com4'], "int"), GetSQLValueString($_POST['rb_com5'], "int"), GetSQLValueString($_POST['rb_com6'], "int"), GetSQLValueString($_POST['rb_com7'], "int"), GetSQLValueString($_POST['rb_logmat1'], "int"), GetSQLValueString($_POST['rb_logmat2'], "int"), GetSQLValueString($_POST['rb_logmat3'], "int"), GetSQLValueString($_POST['rb_logmat4'], "int"), GetSQLValueString($_POST['rb_logmat5'], "int"), GetSQLValueString($_POST['rb_convive1'], "int"), GetSQLValueString($_POST['rb_convive2'], "int"), GetSQLValueString($_POST['rb_convive3'], "int"), GetSQLValueString($_POST['rb_convive4'], "int"), GetSQLValueString($_POST['rb_learn1'], "int"), GetSQLValueString($_POST['rb_learn2'], "int"), GetSQLValueString($_POST['rb_learn3'], "int"), GetSQLValueString($_POST['rb_cualesprobmot'], "int"), GetSQLValueString($_POST['probdesotro'], "text"), GetSQLValueString($_POST['observa'], "text"), GetSQLValueString($_POST['total'], "int"), GetSQLValueString($_POST['nom_maestro'], "text"), GetSQLValueString($_POST['nomescuela'], "text")); mysql_select_db($database_elena, $elena); $Result1=mysql_query($insertSQL,$elena) or die(mysql_error()."- Query -".$insertSQL); $insertGoTo = "menuone.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo));}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>DIAGNOSTICO INICIAL "C i c l o I</title><style type="text/css"><!--body,td,th { color: #FFFFFF;}body { background-color: #0099CC;}.Estilo1 {font-family: Arial, Helvetica, sans-serif}.Estilo5 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; }.Estilo6 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; }--></style></head><body><form method="post" name="form1" action="<?php echo $editFormAction; ?>"> <input type="hidden" name="MM_insert" value="form1"></form><form action ="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name= "form1" > <h1><span class="Estilo1">Diagnóstico Inicial</span></h1> <h2><span class="Estilo1">Comprensión del medio natural, social y cultural</span></h2> <fieldset id="rb_comprende1"> <h5>1. Comp. 1-Ind.1.Nombra y ubica partes externas de su cuerpo y cara</h5> <input name="rb_comprende1" type="radio" value="Si" id="rb_comprende1_yes" <?php $OK = isset($_POST["rb_comprende1"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_comprende1"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_comprende1_yes">Si</label> <input name = "rb_comprende1" type="radio" value="No" id="rb_comprende1_no" <?php if ($OK && isset($missing) && $_POST["rb_comprende1"] == "No") { ?> checked="checked" <?php } ?> /> <label for ="rb_comprende1_no">No</label> </p> </fieldset> <fieldset id="rb_comprende2"> <h5>2. Comp. 1-Ind.2.Reconoce que es importante bañarse diariamente y lavarse las manos y los dientes y practica estas medidas de higiene</h5> <p> <input name="rb_comprende2" type="radio" value="Si" id="rb_comprende2_yes" <?php $OK = isset($_POST["rb_comprende2"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_comprende2"] == "Si") { ?> checked = "checked" <?php }?>/> <label for = "rb_comprende2_yes">Si</label> <input name = "rb_comprende2" type="radio" value="No" id="rb_comprende2_no" <?php if ($OK && isset($missing) && $_POST["rb_comprende2"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_comprende2_no">No</label> </p> </fieldset> <fieldset id="rb_comprende3"><h5> "3. Comp. 2-Ind.4.Participa en Juegos y rondas en espacios abiertos y con diversos materiales por ejemplo: pelotas, botes, llantas y tablas"</h5><p> <input name="rb_comprende3" type="radio" value="Si" id="rb_comprende3_yes" <?php $OK = isset($_POST["rb_comprende3"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_comprende3"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_comprende3_yes">Si</label> <input name = "rb_comprende3" type="radio" value="No" id="rb_comprende3_no" <?php if ($OK && isset($missing) && $_POST["rb_comprende3"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_comprende3_no">No</label> </p> </fieldset><fieldset id="rb_comprende4"><h5>4. Comp.4-Ind.2. Puede decir a las personas adultas donde le duele</h5><p> <input name="rb_comprende4" type="radio" value="Si" id="rb_comprende4_yes" <?php $OK = isset($_POST["rb_comprende4"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_comprende4"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_comprende4_yes">Si</label> <input name = "rb_comprende4" type="radio" value="No" id="rb_comprende4_no" <?php if ($OK && isset($missing) && $_POST["rb_comprende4"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_comprende4_no">No</label> </fieldset><fieldset id="rb_comprende5"><h5>5. Comp. 5-Ind.3. Lava las frutas antes de comerlas</h5><p> <input name="rb_comprende5" type="radio" value="Si" id="rb_comprende5_yes" <?php $OK = isset($_POST["rb_comprende5"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_comprende5"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_comprende5_yes">Si</label> <input name = "rb_comprende5" type="radio" value="No" id="rb_comprende5_no" <?php if ($OK && isset($missing) && $_POST["rb_comprende5"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_comprende5_no">No</label> </fieldset><fieldset id="rb_comprende6"><h5>6. Comp.6-Ind.3. Reconoce que las plantas y animales necesitan alimentarse para vivir</h5><p> <input name="rb_comprende6" type="radio" value="Si" id="rb_comprende6_yes" <?php $OK = isset($_POST["rb_comprende6"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_comprende6"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_comprende6_yes">Si</label> <input name = "rb_comprende6" type="radio" value="No" id="rb_comprende6_no" <?php if ($OK && isset($missing) && $_POST["rb_comprende6"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_comprende6_no">No</label></p> </fieldset><fieldset id="rb_comprende7"> <h5>7. Comp.8-Ind.1.Cuida que el agua para beber(potable) esté limpia y no se desperdicie</h5><p> <input name="rb_comprende7" type="radio" value="Si" id="rb_comprende7_yes" <?php $OK = isset($_POST["rb_comprende7"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_comprende7"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_comprende7_yes">Si</label> <input name = "rb_comprende7" type="radio" value="No" id="rb_comprende7_no" <?php if ($OK && isset($missing) && $_POST["rb_comprende7"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_comprende7_no">No</label></p> </fieldset> <fieldset id="rb_comprende8"> <h5>8.Comp.9-Ind.2.Relaciona el día con el sol y la noche con la luna y las estrellas</h5><p> <input name="rb_comprende8" type="radio" value="Si" id="rb_comprende8_yes" <?php $OK = isset($_POST["rb_comprende8"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_comprende8"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_comprende8_yes">Si</label> <input name = "rb_comprende8" type="radio" value="No" id="rb_comprende8_no" <?php if ($OK && isset($missing) && $_POST["rb_comprende8"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_comprende8_no">No</label></p> </fieldset><fieldset id="rb_comprende9"> <h5>9.Comp.13-Ind.2.Reconoce cuáles objetos pueden ser elaborados en su comunidad y </h5><p> <input name="rb_comprende9" type="radio" value="Si" id="rb_comprende9_yes" <?php $OK = isset($_POST["rb_comprende9"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_comprende9"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_comprende9_yes">Si</label> <input name = "rb_comprende9" type="radio" value="No" id="rb_comprende9_no" <?php if ($OK && isset($missing) && $_POST["rb_comprende9"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_comprende9_no">No</label></p> </fieldset><fieldset id="rb_comprende10"> <h5>10.Comp.19-Ind.2.Identifica a los miembros de su familia</h5><p> <input name="rb_comprende10" type="radio" value="Si" id="rb_comprende10_yes" <?php $OK = isset($_POST["rb_comprende10"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_comprende10"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_comprende10_yes">Si</label> <input name = "rb_comprende10" type="radio" value="No" id="rb_comprende10_no" <?php if ($OK && isset($missing) && $_POST["rb_comprende10"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_comprende10_no">No</label></p> </fieldset><h2 class="Estilo1">Comunicación</h2> <fieldset id="rb_com1"> <h5>1.Comp.1-Ind.3. Da y sigue instrucciones sencillas</h5> <p> <input name="rb_com1" type="radio" value="Si" id="rb_com1_yes" <?php $OK = isset($_POST["rb_com1"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_com1"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_com1">Si</label> <input name = "rb_com1" type="radio" value="No" id="rb_com1_no" <?php if ($OK && isset($missing) && $_POST["rb_com1"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_com1">No</label></p> </fieldset> <fieldset id="rb_com2"> <h5>2.Comp.2.-Ind.1.Saluda. Se presenta o se despide en españ</h5><p> <input name="rb_com2" type="radio" value="Si" id="rb_com2_yes" <?php $OK = isset($_POST["rb_com2"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_com2"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_com2_yes">Si</label> <input name = "rb_com2" type="radio" value="No" id="rb_com2_no" <?php if ($OK && isset($missing) && $_POST["rb_com2"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_com2_no">No</label> </p> </fieldset> <fieldset id="rb_com3"> <h5>3.Comp.3-Ind.1Platica en orden lo que realizó durante el dia</h5> <input name="rb_com3" type="radio" value="Si" id="rb_com3_yes" <?php $OK = isset($_POST["rb_com3"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_com3"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_com3_yes">Si</label> <input name = "rb_com3" type="radio" value="No" id="rb_com3_no" <?php if ($OK && isset($missing) && $_POST["rb_com3"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_com3">No</label></p> </fieldset><fieldset id="rb_com4"> <h5>4.Comp.4-Ind.2 Escucha con atención cuando hablan los adultos</h5> <p> <input name="rb_com4" type="radio" value="Si" id="rb_com4_yes" <?php $OK = isset($_POST["rb_com4"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_com4"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_com4_yes">Si</label> <input name = "rb_com4" type="radio" value="No" id="rb_com4_no" <?php if ($OK && isset($missing) && $_POST["rb_com4"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_com4">No</label></p> </fieldset><fieldset id="rb_com5"><h5>5.Comp.5-Ind.2. Dice de que se trata un cuento, a partir de sus imagenes</h5><p> <input name="rb_com5" type="radio" value="Si" id="rb_com5_yes" <?php $OK = isset($_POST["rb_com5"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_com5"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_com5">Si</label> <input name = "rb_com5" type="radio" value="No" id="rb_com5_no" <?php if ($OK && isset($missing) && $_POST["rb_com5"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_com5_no">No</label></p> </fieldset><fieldset id="rb_com6"><h5>6.Comp.7-Ind.4. Sabe escribir su nombre</h5><p> <input name="rb_com6" type="radio" value="Si" id="rb_com6_yes" <?php $OK = isset($_POST["rb_com6"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_com6"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_com6_yes">Si</label> <input name = "rb_com6" type="radio" value="No" id="rb_com6_no" <?php if ($OK && isset($missing) && $_POST["rb_com6"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_com6_no">No</label></p> </fieldset><fieldset id="rb_com7"> <h5>7.Comp.11-Ind.2.Escoge los libros que le gustan</h5> <p> <input name="rb_com7" type="radio" value="Si" id="rb_com7_yes" <?php $OK = isset($_POST["rb_com7"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_com7"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_com7_yes">Si</label> <input name = "rb_com7" type="radio" value="No" id="rb_com7_no" <?php if ($OK && isset($missing) && $_POST["rb_com7"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_com7_no">No</label></p> </fieldset> <h2 class="Estilo1">Lógica Matemática</h2><fieldset id="rb_logmat1"> <h5>1. Comp.1-Ind.2.Compara colecciones y señala cuál tiene más elementos, cuál tiene menos o si son iguales</h5> <p> <input name="rb_logmat1" type="radio" value="Si" id="rb_logmat1_yes" <?php $OK = isset($_POST["rb_logmat1"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_logmat1"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_logmat1_yes">Si</label> <input name = "rb_logmat1" type="radio" value="No" id="rb_logmat1_no" <?php if ($OK && isset($missing) && $_POST["rb_logmat1"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_logmat1_no">No</label></p> </fieldset> <fieldset id="rb_logmat2"><h5>2.Comp.1-Ind.3.Cuenta en orden los números del 1 al 10</h5> <input name="rb_logmat2" type="radio" value="Si" id="rb_logmat2_yes" <?php $OK = isset($_POST["rb_logmat2"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_logmat2"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_logmat2_yes">Si</label> <input name = "rb_logmat2" type="radio" value="No" id="rb_logmat2_no" <?php if ($OK && isset($missing) && $_POST["rb_logmat2"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_logmat2_no">No</label></p> </fieldset><fieldset id="rb_logmat3"><h5>3.Comp.3-Ind.1.Iguala dos colecciones de objetos agregando o quitando elementos</h5><p> <input name="rb_logmat3" type="radio" value="Si" id="rb_logmat3_yes" <?php $OK = isset($_POST["rb_logmat3"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_logmat3"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_logmat3_yes">Si</label> <input name = "rb_logmat3" type="radio" value="No" id="rb_logmat3_no" <?php if ($OK && isset($missing) && $_POST["rb_logmat3"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_logmat3_no">No</label></p> </fieldset><fieldset id="rb_logmat4"> <h5>4.Comp.5-Ind.1.Compara objetos y señala cuál es el más largo </h5> <p> <input name="rb_logmat4" type="radio" value="Si" id="rb_logmat4_yes" <?php $OK = isset($_POST["rb_logmat4"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_logmat4"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_logmat4_yes">Si</label> <input name = "rb_logmat4" type="radio" value="No" id="rb_logmat4_no" <?php if ($OK && isset($missing) && $_POST["rb_logmat4"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_logmat4_no">No</label></p> </fieldset><fieldset id="rb_logmat5"> <h5>5.Comp.6-Ind.1.Ubica objetos y personas con relación a sí mismo(cerca, lejos,enfrente o a un lado</h5> <p> <input name="rb_logmat5" type="radio" value="Si" id="rb_logmat5_yes" <?php $OK = isset($_POST["rb_logmat5"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_logmat5"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_logmat5_yes">Si</label> <input name = "rb_logmat5" type="radio" value="No" id="rb_logmat5_no" <?php if ($OK && isset($missing) && $_POST["rb_logmat5"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_logmat5_no">No</label></p> </fieldset>/> <h2 class="Estilo1">Actitudes y valores para la convivencia</h2> <fieldset id="rb_convive1" ><h5>1.Comp.2-Ind.1.2.Expresa con palabras su afecto por familiares, amigas y amigos</h5><p> <input name="rb_convive1" type="radio" value="Si" id="rb_convive1_yes" <?php $OK = isset($_POST["rb_convive1"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_convive1"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_convive1_yes">Si</label> <input name = "rb_convive1" type="radio" value="No" id="rb_convive1_no" <?php if ($OK && isset($missing) && $_POST["rb_convive1"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_convive1_no">No</label></p> </fieldset><fieldset id="rb_convive2"><h5>2.Comp.3-Ind.2.Respeta su turno para hablar y escucha a los demás</h5><p> <input name="rb_convive2" type="radio" value="Si" id="rb_convive2_yes" <?php $OK = isset($_POST["rb_convive2"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_convive2"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_convive2_yes">Si</label> <input name = "rb_convive2" type="radio" value="No" id="rb_convive2_no" <?php if ($OK && isset($missing) && $_POST["rb_convive2"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_convive2_no">No</label></p> </fieldset> <fieldset id="rb_convive3"><h5>3.Comp.4-Ind.2.Solicita y brinda ayuda a us compañeras y compañeros</h5> <input name="rb_convive13" type="radio" value="Si" id="rb_convive3_yes" <?php $OK = isset($_POST["rb_convive3"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_convive3"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_convive3_yes">Si</label> <input name = "rb_convive3" type="radio" value="No" id="rb_convive3_no" <?php if ($OK && isset($missing) && $_POST["rb_convive3"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_convive3_no">No</label></p> </fieldset> <fieldset id="rb_convive4"> <h5>4.Comp.5-Ind.1.Sabe que su país es México</h5> <p> <input name="rb_convive4" type="radio" value="Si" id="rb_convive4_yes" <?php $OK = isset($_POST["rb_convive4"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_convive4"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_convive4_yes">Si</label> <input name = "rb_convive4" type="radio" value="No" id="rb_convive4_no" <?php if ($OK && isset($missing) && $_POST["rb_convive4"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_convive4_no">No</label></p> </fieldset>/> <h2 class="Estilo1">Aprender a aprender</h2> <fieldset id="rb_learn1"> <h5>1.Comp.1-Ind.1. Atiende las instrucciones para realizar una tarea y pregunta cuando tiene dudas</h5> <p> <input name="rb_learn1" type="radio" value="Si" id="rb_learn1_yes" <?php $OK = isset($_POST["rb_learn1"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_learn1"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_learn1_yes">Si</label> <input name = "rb_learn1" type="radio" value="No" id="rb_learn1_no" <?php if ($OK && isset($missing) && $_POST["rb_learn1"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_learn1_no">No</label></p> </fieldset> <fieldset id="rb_learn2"> <h5>2.Comp.3-Ind.1 Sabe que personas y libros pueden proporcionale información</h5> <p> <input name="rb_learn2" type="radio" value="Si" id="rb_learn2_yes" <?php $OK = isset($_POST["rb_learn2"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_learn2"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_learn2_yes">Si</label> <input name = "rb_learn2" type="radio" value="No" id="rb_learn2_no" <?php if ($OK && isset($missing) && $_POST["rb_learn2"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_learn2_no">No</label></p> </fieldset><fieldset id="rb_learn3"> <h5>3.Comp.5-Ind.1 Realiza algunos dibujos secuenciados para expresar sus ideas</h5> <p> <input name="rb_learn3" type="radio" value="Si" id="rb_learn3_yes" <?php $OK = isset($_POST["rb_learn3"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_learn3"] == "Si") { ?> checked = "checked" <?php } ?>/> <label for = "rb_learn3_yes">Si</label> <input name = "rb_learn3" type="radio" value="No" id="rb_learn3_no" <?php if ($OK && isset($missing) && $_POST["rb_learn3"] == "No") { ?> checked="checked" <?php } ?> /> <label for "rb_learn3_no">No</label></p> </fieldset> <fieldset id="rb_actividadprobl"> <p class="Estilo6">Tiene algún problema para controlar sus movimientos al caminar, sentarse, escribir, recortar o realizar</p> <p class="Estilo5"><strong>alguna actividad manual <label> </label> </strong> <label></label> <label> <input name="rb_actividadprobl" type="radio" value="Si" id="rb_actividadprobl_yes" /> <?php $OK=isset($_POST["rb_actividadprobl"]) ? true : false; if ($OK && isset($missing) && $_POST["rb_actividadprobl"] == "Si") { ?> checked = "checked" <?php }?>/> <label for = "rb_actividadprobl">Si</label><input name="rb_actividadprobl" type="radio" value="No" id="rb_actividadprobl_No"<?phpif ($OK && isset($missing) && $_POST["rb_actividadprobl"]=="No") { ?> checked="checked" <?php } ?> /> <label for "rb_actividadprobl">No</label> </p> </fieldset> <p class="Estilo5"><strong>Cuáles?</strong> <label> <textarea name="cualesproblmot" cols="87" rows="5" id="cualesproblmot"></textarea> </label></p> <p class="Estilo6">Especifica si la niña o el niño tiene algún otro problema que pueda afectar su desempeño escolar:</p> <p class="Estilo5"> <label> <textarea name="probldesotro" cols="95" rows="5" id="probldesotro"></textarea> </label></p> <p class="Estilo6">Observaciones y comentarios: </p></form><p> <label> <textarea name="observa" cols="95" rows="5" id="observa"></textarea> </label></p><p><input name="total" type="int" value=0 id="total" /> <label>Grabar <input type="submit" name="Submit" value="Enviar" /> </label></p></body></html>What I'm doing wrong? HELP ME!! PLEASE
Remote Application to Handle Server Code
4/8/2011 external link
I have a web app that currently use an ActiveX Control to run Credit Card Devices and other perpherials. My problem comes with when ever there is a change to code for these devices I have to push out an updated ActiveX Control. In most of the environments the user don't have rights to install an update to this control.Is there a way to have a generic ActiveX so that it makes remote calls to server code to run these devices. This way I don't have to make any changes to the ActiveX. Just the code that is managed on the server.Any help or suggestion are greatly appreciated.
curl question?
4/8/2011 external link
is there anyway for a user, that views my php page, to see what other pages my php page curls out to or reads response headers from..?
This script is driving me insane
4/8/2011 external link
I have been working with an algorithm that a mathematician came up with and trying to convert it into a useable php script for about a month now.I just can not seem to grasp how to do it.If someone is willing to take a look at this and make it work I will pay up to $100.I was givin this PDF to start withhttp://combatsportsrank.com/rank/mmaRanking.pdfit outlines the functions needed to be done in order to get the Rank.I have attempted to convert the majority of it into PHP but I have no idea how to implement it.From what I see it needs like 2 or 3 loops to just get one rank and its got to take a lot of time to get the info.Here is what I have so far: http://w3schools.invisionzone.com/index.php?showtopic=38459So i am thinking it might have to be a bunch of little cron jobs that can be ran to gather info and post it into a database so it can be grabbed faster when needed.Ultimately we are making a website that is a social network and doubles as a ranking site for MMA fighters. Fight data is entered then parsed to determine a specific fighters rank.This rank is used in dynamic images that can be used on the site and posted on other sites such as Facebook, Myspace, Etc.If anyone is up to the challenge I would greatly appreciate it. I would like to be all said and done with it in 2 weeks. definitely before the end of the month.
problems with regular expressions
3/8/2011 external link
I keep pulling parse errors with this code. Not sure whether the problem is the regular expressions, the switch statement or something else. Need fresh eyes. Help!CODEswitch($_FILES['photofile']['type']){ case 'image/jpeg' : if(eregi('(.jp(e)g)$',$_FILES['myFileUpload']['name']){ $ext = TRUE; break; } case 'image/gif' : if(eregi('(.gif)$',$_FILES['myFileUpload']['name']){ $ext = TRUE; break; } case 'image/png' : if(eregi('(.png)$',$_FILES['myFileUpload']['name']){ $ext = TRUE; break; } default: $ext = FALSE; break;
edit and update post
3/8/2011 external link
i wrote this code for edit posti wrote this query for mesage's table QUOTE $Query = mysql_query("SELECT * FROM `message` WHERE `id` = '".intval($_GET['id'])."' LIMIT 1 ");and i fetch data from mysql database with function QUOTE $row_rsEdit = mysql_fetch_array($Query); and i wrote this query for update postQUOTE $EditNews = mysql_query ("UPDATE `message` SET `title` = '".$title."', `text1` = '".$text1."' WHERE `id` = '".$_POST['id']."' LIMIT 1");but this code not run please guied me how can i change this code for update post and save in databaseQUOTE <input type="hidden" name="Act" value="<?php echo (isset($row_rsEdit)) ? "EditNews" : ""; ?>"> <?php echo (isset($row_rsEdit)) ? '<input type="hidden" name="id" value="'.$row_rsEdit['id'].'">' : ''; ?> <div align="center"> <table border="0" width="460" dir="rtl" cellpadding="0"> <tr> <td align="center" colspan="2"><?php echo $Prompt; ?></td> </tr>all code for edit postQUOTE <?php $con = mysql_connect("localhost","root","");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("admin", $con);if ( isset($_GET['id']) && ($_GET['id'] !== "") ){ $Query = mysql_query("SELECT * FROM `message` WHERE `id` = '".intval($_GET['id'])."' LIMIT 1 "); $row_rsEdit = mysql_fetch_array($Query); if(mysql_num_rows($Query)>0){ if ( isset($_POST['Act']) && ($_POST['Act'] == "EditNews") ){ $title=mysql_real_escape_string($_POST['title']); $text1=mysql_real_escape_string($_POST['text1']); $EditNews = mysql_query ("UPDATE `message` SET `title` = '".$title."', `text1` = '".$text1."' WHERE `id` = '".$_POST['id']."' LIMIT 1"); if ( $EditNews ) { $Prompt = '<font color="green"><b> update post successfully </b></font>'; } else { $Prompt = '<font color="red"><b>sorry</b></font>'; }}else{$Prompt = false;} }}?><form action="" method="POST" id="signupForm" name="posts"> <input type="hidden" name="Act" value="<?php echo (isset($row_rsEdit)) ? "EditNews" : ""; ?>"> <?php echo (isset($row_rsEdit)) ? '<input type="hidden" name="id" value="'.$row_rsEdit['id'].'">' : ''; ?> <div align="center"> <table border="0" width="460" dir="rtl" cellpadding="0"> <tr> <td align="center" colspan="2"><?php echo $Prompt; ?></td> </tr> title:<input type="text" name="title" id="man2" size="50" dir="rtl" class="bg-blue02" value="<?php echo $row_rsEdit['title']; ?>"><p>text:<textarea name='text1' rows='2' id='text1' style='WIDTH:80px; HEIGHT:100%;'><?php echo $row_rsEdit['text1']; ?></textarea> <script type='text/javascript'> //<![CDATA[ // Replace the <textarea id='editor1'> with an CKEditor instance var editor = CKEDITOR.replace( 'text1' ); //]]> </script> <input type="submit" name="send" value="send" /> </form>
Group by issue
3/8/2011 external link
Hi all I have the following Query :select mgr_num, CASE WHEN mgr_num = 6670 THEN 'Web Site' WHEN (mgr_num = 5349) or (mgr_num =6704) THEN 'HP' WHEN mgr_num = 5728 THEN 'Cisco' WhEN mgr_num = 6651 THEN 'SUN' WHEN mgr_num = 6688 THEN 'IBM' WHEN mgr_num = 6689 THEN 'Storage' WHEN (mgr_num = 6614) OR (mgr_num = 6705) THEN 'Asset Recovery' WHEN (mgr_num = 6706) OR (mgr_num = 5261) THEN 'Drury Group' WHEN (mgr_num = 6149) OR (mgr_num = 6698) THEN 'Stezzi Group' WHEN (mgr_num = 6121) OR (mgr_num = 6699) THEN 'Wing Group' WHEN (mgr_num = 6700) OR (mgr_num = 6107) THEN 'Elan Group' WHEN (mgr_num = 6701) OR (mgr_num = 6050) THEN 'Wade Group' WHEN (mgr_num = 6702) OR (mgr_num = 6671) THEN 'Swanson Group' WHEN (mgr_num = 6669) OR (mgr_num = 6702) THEN 'Willis Group' ELSE 'Unknown' END ,CAST(sum(smn_amt) as INT)from reports.tvsaleswhere mgr_num!=6614 and mgr_num!=6705 group by mgr_numORDER BY sum(SMN_AMT) desc it is working perfect so far but in the resault I am getting as follow: Cisco 5000 HP 2500 Sun 1350 HP 1100Is there anyway I can group the two HPs "this is happening because I have more than one mgr-num for HP "In other words, is there anyway to group by the titles inside the case ?
Database Tree Design
3/8/2011 external link
Hi guys,, I have something need logical solution not coding issues, the problem is that I have data in tree structure eg:1.abcd a.efg 11.hij2.cvb a.fgh 22.hijand I need to display every thing in the right order, and know what the user is check?? if you note that point 11 = 22 So I need something to store the above parent in mind.'what can I do????????????thanks in advance for any help or ideaBest Regards
Problem with comparing data in form
3/8/2011 external link
Hi!I have a form, in which I edit some data, which is retrieved from MySQL, then this data is sent to another file, submit_mag.php, in which I compare some of the data and update MySQL record. So, in the form I have 2 hidden fields: ""issue_current_month" and "issue_current_year". Also, I have 2 select menus: "issue_month" and "issue_year". And here's the part where I retrieve this data in submit_mag.php and compare the data: CODE$mag_id = (int) $_REQUEST['mag_id'];$issue_num = $_REQUEST['issue_num'];$issue_current_month = $_REQUEST['issue_current_month'];$issue_new_month = $_REQUEST['issue_month'];$issue_current_year = $_REQUEST['issue_current_year'];$issue_new_year = $_REQUEST['issue_year'];$issue_theme = $_REQUEST['issue_theme'];$issue_desc = $_REQUEST['issue_desc'];echo "current month: ", $issue_current_month, "</br>";echo "new month: ", $issue_new_month, "</br>";echo "current year: ", $issue_current_year, "</br>";echo "new year: ", $issue_new_year, "</br></br>";//Compare monthif ($issue_new_month == 0 || $issue_new_month == $issue_current_month){ $issue_month = $issue_current_month;}else{ $issue_month = $issue_new_month;}echo "issue month: ", $issue_month, "</br>";//Compare yearif ($issue_new_year == 0 || $issue_new_year == $issue_current_year){ $issue_year = $issue_current_year;}else{ $issue_year = $issue_new_year;}echo "issue year: ", $issue_year, "</br></br>";In the first block of echoes I only want to display which data is retrieved from the form (it's only for me, I'll remove this part once everything works correctly). And here's the result I'm having:current month: Augustnew month: Sеptembercurrent year: 2011new year: 2012So far - so good.Now, when I'm trying to make the comparison and to set variables $issue_month and $issue_year, I'm having a problem with $issue_month. The echoes of these variables show me this:issue month: Augustissue year: 2012So the year comparison and setting the $issue_year works just fine. But for some reason I'm having trouble with the month, after the comparison I keep getting current month. Any ideas why is that? Thank you!
Reload event handling in PHP?
3/8/2011 external link
Is there a way to tap into the refresh event with PHP? Ideally I want to handle only the refresh event if certain conditions are met such as the user refreshed by use of the browser refresh button or context menu... I've never seen code for this so it is all new to me.
PHP validation issue
3/8/2011 external link
I have a form that is being validated using PHP server side scripting. To show multiple errors, I store it in an array and used foreach to loop through the values and echo it for dislay. I thought i'm finished using PHP validation but I noticed that everytime I submit the form, even though it still contains some errors, all of the values that were inputted resets. Why? When I used javascript, the values remains so whats with PHP? The form's action is also to itself.
Change server method to GET on refresh.
2/8/2011 external link
I want to change the method from POST to GET whenever a user uses the refresh button in the browser. Can this be done?
Display data from mysql database from select drop down
2/8/2011 external link
I am working on an inventory page. I would like to have a select drop down that lists each stone type (Marble, Travertine, Slate, etc.). My current code only retrieves the first record. When the user selects a stone from the drop down, I would like it to display all the records for that stone.Here is my code so far:In the HEADCODE<script type="text/javascript">function showUser(str){if (str=="") if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); }else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) }xmlhttp.open("GET","getinv.php?q="+str,true);xmlhttp.send();}</script>Code for the select boxCODE<form><select name="stones" onchange="showUser(this.value)"><option value="">Select a Stone:</option><option value="1">Marble</option><option value="2">Travertine</option><option value="3">Slate</option><option value="4">Onyx</option></select></form><br /><div id="txtHint"><b>View current inventory here.</b></div>and finally my getinv.phpCODE<?php$q=$_GET["q"];$con = mysql_connect('localhost', 'username', 'password');if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("Inventory", $con);$sql="SELECT * FROM Products WHERE id = '".$q."'";$result = mysql_query($sql);echo "<table border='1'><tr><th>Stone Name</th><th>Stone Size</th></tr>";while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['StoneName'] . "</td>"; echo "<td>" . $row['StoneSize'] . "</td>"; echo "</tr>"; }echo "</table>";mysql_close($con);?>I would like it to display all of the records where StoneType=Marble, etc.Thanks in advance for any advice!
Eclipse and databases
2/8/2011 external link
Hello,I'm new to using (MySQL) databases through Eclipse, and would like to know how it's done.Currently I have my project for a windows application. It's fully written in Java. But to distribute the app, I'm using an executable wrapper that packs up the jar and necessary files into one exe, and then I rar it along with some gfx and sfx folders into one nice archive. The idea is that I further develop this windows application using a MySQL database (which I hereby want to start using), untill I port it to an applet for websites and then switch to an existing online MySQL server. If it is possible, I actually like to keep both windows distribution and website applet separately available using their own database when it comes to that.Because I'm having the (MySQL using) applet in mind, I think I should start with implementing a MySQL database. I'm not familiar with other DBMSs. But if there is a portable solution for another DBMS, please tell me.One of my questions would be, do I need to install the Connector/J to be able to use a MySQL database, or did the driver come bundled with Eclipse? As I just recently installed the Indigo version and got the Connector/J driver from mysql.org, but I don't know what to do with the latter. I researched myself, but can't find a simple answer. I know that NetBeans is bundled with these type4 drivers, so if Eclipse isn't, why not?So if I want to start using a database, keeping in mind it will eventually be redirected to an existing online one, what DBMS options do I have, should I use a bridge or not, what else do I need, and how do I do it? Please help Thanks,Jack
CURL + HTTP_X_FORWARDED_FOR
2/8/2011 external link
how can I set the HTTP_X_FORWARDED_FOR header in a curl request so when I curl this site:http://dawhois.com/my_ip_address.phpmy real IP shows up for the "IP Behind Proxy" Section..?
<option value...> selected from MySQL
2/8/2011 external link
Hello!I have this SELECT field in my form: CODE<select name="issue_month" id="issue_month"> <option value="0" selected="selected">Select month</option> <option value="Jan">January</option> <option value="Feb">February</option> <option value="Mar">March</option> <option value="Apr">April</option> <option value="May">May</option> <option value="Jun">June</option> <option value="Jul">July</option> <option value="Aug">August</option> <option value="Sep">September</option> <option value="Oct">October</option> <option value="Nov">November</option> <option value="Dec">December</option> </select>when I retrieve this data from MySQL it's $issue_month = $row['issue_month'];Now, if the record says May, for example, how can I make May be selected automatically in this field, so it would look like this: CODE<select name="issue_month" id="issue_month"> <option value="0">Select month</option> <option value="Jan">January</option> <option value="Feb">February</option> <option value="Mar">March</option> <option value="Apr">April</option> <option value="May" selected="selected">May</option> <option value="Jun">June</option> <option value="Jul">July</option> <option value="Aug">August</option> <option value="Sep">September</option> <option value="Oct">October</option> <option value="Nov">November</option> <option value="Dec">December</option> </select>Thanks!!
Add Comment on Post?
2/8/2011 external link
Hi again anyone here can help me figure out how to work on add comment on a post? like in a blog post.. i got confused on the database and code how it will work..please help me
Reading of a file, EOF, array concatenation.
2/8/2011 external link
Hi there,I am having issues reading a file.I want to open .csv file, and read each line into one array. I know fgetcsv() returns an array for each line of the file. I have 2 problems:1) I am not sure if I can concatenate arrays using the operator+=? Is there a better way of performing this task?2) Currently, my while loop is running infinitely. I am running this in Chrome, on a Mac, and the .csv file is written on a Mac.I have heard there are issues with feof depending on where the file is written. Is there a way I can overcome this problem?Here is my code:CODE if (file_exists("../uploads/".$this->fileArray["name"])){ $openFile = fopen('../uploads/'.$this->fileArray["name"]); $userLine; //Represents one line of the .csv file while( !feof($openFile, "r") ) { $userLine += fgetcsv($openFile); } fclose($file);}else{ die("File '../uploads/'". $this->fileArray["name"] ." not found.");}Thank you for any help.
php: dynamic includes. is this way safe?
1/8/2011 external link
I've been looking into using dynamic includes in my layout and I have found this tutorial which claims to be a safe way of doing it. As im still very new to php would someone more experienced kindly be able to tell me if this code is safe.Thanks for any help.CODE<?php if (isset($_GET['x'])) { if (strpos($_GET['x'], "/")) { $dir = substr(str_replace('..', '', $_GET['x']), 0, strpos($_GET['x'], "/")) . "/"; $file = substr(strrchr($_GET['x'], "/"), 1); if (file_exists($dir.$file.".php")) { include($dir.$file.".php"); } else { include("index2.php"); } } else { if (file_exists(basename($_GET['x']).".php")) { include(basename($_GET['x']).".php"); } else { include("index2.php"); } }} else { include("index2.php");} ?>
How to do the following
1/8/2011 external link
Hi i need a php script for my website which should do the followingif a user try to visit http://mywebsite.com or www.mywebsite.com php find the url and redrict the user to https://mywebsite.com Thanks
Problem with Cookie detection
1/8/2011 external link
I am using PHP to set a cookie and have a problem with detecting the cookie afterwards.In the script I check if cookie exsits with if(isset($_COOKIE["abc"]))if it does then I make a change to the expiry dateif it doesnt then I create a cookie with setcookie....I then check again to see if the cookie now exists and at this point the check says it doesnt exists and therefore displays my "please enable cookies message".I know that the setcookie works because if I reload the page the script detects the cookie correctly and no longer displays the message.Is this something to do with server side and client side and when the cookie is actually created or is it something else
Php Content and menu
1/8/2011 external link
Gidday I am not quite sure what this is call but I have built a template using php and youtube I haveused includes to call the content <?php include_once "info.php";?> <?php include_once "menu.php";?> etc what I would like to do is if a user select a product or service only that information is shown.service designarchitectengineeringif a user select design than the design <?php include_once "designinfo.php";?> is diplayed.I think it's an elseif statement.
Using isset to check form fields
31/7/2011 external link
I've been having some trouble using isset to determine whether any value has been entered into a form field. I'm learning Php using Welling & Thomson's "Php and MySQL Web Development". According to their definition of isset and some code examples, I should be able to do this. I've even seen similar examples in the W3 Php tutorial. For some reason my code never detects the error (I never enter anything in the address field). At the moment I'm only checking the email field, but I want this as atest of all entry fields. Here's the codeCODE<?php $date = date("m/d/y"); $db_ptr = fopen("guestlog.txt",'a'); $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $address = ($_POST['address']); if(isset($_REQUEST['address'])) { $guest_entry_str = $lastname."\t".$firstname."\t".$address."\t".$date."\n"; fwrite($db_ptr,$guest_entry_str); echo "Your name is " .$firstname. " " .$lastname; echo "<br />Your email is " .$address; echo '<br />The date is ' .date("m/d/y");} else { echo "No value entered has been entered. Please return to entry page"; } ?>The HTML form declares "address" to be a text field 30 chars wide. I've also tried using trim() on the address field. According to everything I've see this should work. Any ideas? Thanks
getting the data to databases error
31/7/2011 external link
Hi there,i have my little problem sorry im new in php and im expanding my knowledge in to this.i have a simple add data to the database and get it to show the result. my problem is the data was stored in the database but when i will show the resultonly the table was added but the content is not posted/showed.please anyone help me again thank you very much
Class Constant vs. Class Methods
31/7/2011 external link
This isn't really an important question, but since I've been going through my forum, optimizing as much as I can, I thought I might as well ask. I've already gone through and removed all double-quoted strings, almost all redirects, et cetera, so I'm working with the lesser details now.I have several object classes used to store different types of data in a flat file database. I have eleven, actually. Ten of the classes are extended from the eleventh class. Each class has a save_obj() method, to insure that all objects get saved to the correct files. Right now, the save_obj() method uses the static::type constant to determine the directory the file should be saved to. However, since I have to redefine that constant when I extend the class, I was wondering if it might be a good idea to just redefine the method to save to the correct directory, and remove the constant altogether.Obviously both work, but which format would be the better option?CODE<?php namespace us_0gb;/** * (c) Zero GigaBytes * ..... other documentation here ....**/class catfor {const type = 'catfor';final public function save_obj() {$data = \serialize($this);\file_put_contents(\us_0gb\FFF::$database.'/'.static::type.'/'.$this->_.'.txt', $data);} }class group extends \us_0gb\catfor {const type = 'group';}//And the file continues .....CODE<?php namespace us_0gb;/** * (c) Zero GigaBytes * ..... other documentation here ....**/class catfor {public function save_obj() {$data = \serialize($this);\file_put_contents(\us_0gb\FFF::$database.'/catfor/'.$this->_.'.txt', $data);} }class group extends \us_0gb\catfor {public function save_obj() {$data = \serialize($this);\file_put_contents(\us_0gb\FFF::$database.'/group/'.$this->_.'.txt', $data);} }//And the file continues .....
Need help creating download counter with MySQL
31/7/2011 external link
Hi!I need to create a download counter and I don't know how to do it. I have this code to select the last record from the table: CODE$query = "SELECT * from vanity_mag ORDER BY mag_id desc LIMIT 1";$result = mysql_query($query) or die ("Select query failed: " . mysql_error()); while ($row = mysql_fetch_array($result)) { $mag_id = $row['mag_id']; $issue_num = $row['issue_num']; $issue_month = $row['issue_month']; $issue_year = $row['issue_year']; $mag_url = $row['mag_url']; $mag_ereader_url = $row['mag_ereader_url']; $cover_url = $row['cover_url']; $issue_theme = $row['issue_theme']; $issue_desc = $row['issue_desc']; $mag_dl_counter = $row['mag_dl_counter']; $mag_ereader_dl_counter = $row['mag_ereader_dl_counter'];And later on I have this code for my download link: CODEClick <?php echo "<a href=", $mag_url, ">here</a>" ?> to download regular version</br>Click <?php echo "<a href=", $mag_ereader_url, ">here</a>" ?> to download monochrome version for ereadersWhen a person clicks one of these links, I need it to add +1 to the total number of downloads (mag_dl_counter for regular versions (the first link) or mag_ereader_dl_counter for the second link) and, obviously, download the file. I have no clue how to do that. I tried to google it, but found only solutions with some external file for counting, which isn't good for me. So... how do I do it? Thanks!
PHP Class naming conventions
31/7/2011 external link
Hi there,I am fairly new to PHP but have some experience in object-oriented programming and am wanting to take that approach in PHP. From what I have been reading, some people seem to save their classes with a ".class.php" extension, and some with just plain ".php". Are there conventions to do with this? I can understand using ".class.php" is useful, but I'm not sure if it's an outdated way of doing things or something.Thank you.
problem with variables
29/7/2011 external link
I have this codeif ($section == ''received" || $page == "summary'') { $nb_messages = $db->count_rows('messaging', "WHERE receiver_id='" . $session->value('user_id') . "' AND receiver_deleted=0" . (($page == 'summary') ? " AND is_read=0" : '')); $template->set('nb_messages', $nb_messages); $template->set('page_order_reg_date', page_order('members_area.php', 'm.reg_date', $start, $limit, $additional_vars, MSG_MESSAGE_DATE)); $template->set('page_order_sender_username', page_order('members_area.php', 'u.username', $start, $limit, $additional_vars, MSG_SENDER_USERNAME)); if ($nb_messages) { $nb_unread_messages = $db->count_rows('messaging', "WHERE receiver_id='" . $session->value('user_id') . "' AND receiver_deleted=0 AND is_read=0"); $template->set('nb_unread_messages', $nb_unread_messages); $sql_select_messages = $db->query("SELECT m.admin_message, a.name, u.username AS sender_username, w.name AS wanted_name, r.name AS reverse_name, m.* FROM " . DB_PREFIX . "messaging m LEFT JOIN " . DB_PREFIX . "auctions a ON a.auction_id=m.auction_id LEFT JOIN " . DB_PREFIX . "wanted_ads w ON w.wanted_ad_id=m.wanted_ad_id LEFT JOIN " . DB_PREFIX . "reverse_auctions r ON r.reverse_id=m.reverse_id LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=m.sender_id WHERE m.receiver_id='" . $session->value('user_id') . "' AND m.receiver_deleted=0 " . (($page == 'summary') ? " AND m.is_read=0" : '') . " ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit); while ($msg_details = $db->fetch_array($sql_select_messages)) { $background = ($counter++%2) ? 'c1' : 'c2'; $ico_read = (!$msg_details['is_read']) ? 'unread' : 'read'; $content_options = '<a href="members_area.php?do=delete_message&type=receiver_deleted&message_id=' . $msg_details['message_id'] . $additional_vars . $limit_link . $order_link . '" onclick="return confirm(\'' . MSG_DELETE_CONFIRM . '\');">' . MSG_DELETE . '</a>'; $received_messages_content .= '<tr class="' . $background . '"> '. ' <td class="contentfont" nowrap> '. ' <img src="themes/' . $setts['default_theme'] . '/img/system/' . $ico_read . '_mess.gif" border="0" align="absmiddle" hspace="5"><a href="' . $msg->msg_board_link($msg_details) . '">' . (($msg_details['admin_message']) ? GMSG_SITE_ADMIN : $msg_details['sender_username']) . '</a></td> '. ' <td class="contentfont">' . $msg->message_subject($msg_details) . '</td>'. ' <td align="center" nowrap>' . show_date($msg_details['reg_date']) . '</td> '. ' <td align="center" class="smallfont" nowrap><input name="delete[]" type="checkbox" id="delete[]" value="' . $msg_details['message_id'] . '" class="checkdelete"></td>'. '</tr>'; } } else { $received_messages_content = '<tr><td colspan="8" align="center">' . GMSG_NO_MESSAGES_MSG . '</td></tr>'; } $template->set('received_messages_content', $received_messages_content); if ($page != 'summary') { $pagination = paginate($start, $limit, $nb_messages, 'members_area.php', $additional_vars . $order_link); $template->set('pagination', $pagination); } $members_area_page_content = $template->process('members_area_messaging_received.tpl.php'); if ($page == 'summary') { $summary_page_content['messaging_received'] = $members_area_page_content; } $template->set('members_area_page_content', $members_area_page_content); }and if I understend well variable $nb_messages is defined only if section is received and page is summary and value of that variable is shown only on page members_area.php.If all that is corect how can I change this code to define variable for all sections,all pages and to be displayed where ever I put it.
Searching string split by commas in mysql
29/7/2011 external link
Hi there,I currently have a mysql database which i would like to use to get values from a database. One of the columns in the database holds a value and if more than one value exists for an entry, the values are split up by commas for that row under the ClubID column. Here is a copy of my current query:CODE$query="SELECT * FROM FootballPlayers WHERE ClubID LIKE '%$squad' COLLATE utf8_bin ORDER BY CASE WHEN Positions LIKE 'GK%' THEN 1 WHEN Positions LIKE 'RB%' THEN 2 WHEN Positions LIKE 'LB%' THEN 3 WHEN Positions LIKE 'SW%' THEN 4 WHEN Positions LIKE 'CD%' THEN 5 WHEN Positions = 'D' THEN 6 WHEN Positions LIKE 'RW%' THEN 7 WHEN Positions LIKE 'LW%' THEN 8 WHEN Positions LIKE 'DM%' THEN 9 WHEN Positions LIKE 'CM%' THEN 10 WHEN Positions LIKE 'AM%' THEN 11 WHEN Positions = 'M' THEN 12 WHEN Positions LIKE 'FW%' THEN 13 WHEN Positions LIKE 'ST%' THEN 14 WHEN Positions = 'A' THEN 15 ELSE 16 END";Ok i would like the query above to search the database and to show items where ClubID is like $squad. $squad is always a number or more than one number split up by commas, e.g. 100 or 1,2,3,4 etc.The rest of the query is fine where it displays the rows depending on what playing position they equal. The problem is that if $squad is equal to a range of numbers split up by commas they it will not find anything and just show blank. e.g. if $squad = "2" and i am looking at ClubID column for a ClubID which contains "2" then nothing seems to get displayed as ClubID might say "1,2" or "2,8" etc. My question is, how can i search the database so that after the WHERE clause i can see if part of the string $squad is in the column ClubID for the current row.I have tried using LOCATE and FIND_IN_SET but i cannot appear to get them to work, maybe the right syntax is all i need :-). I am using mysql version 5.0 and the variable i search the database with is created using PHP. Any help is apprechiated.Thanks,Mark
need regex help
29/7/2011 external link
following pattern matches file name that looks like abc.dfCODE$pattern = '/\\}/s';but how can i make it mach file name hat has random number of dots in it and slash?like ./abc/def.ghany one got any ideas?
Validating uploaded files types (RESOLVED)
29/7/2011 external link
Hi!I'm trying to validate that the uploaded files are in correct format. So I have this code:CODE if ($_FILES["magazine"]["error"] > 0) { echo "Error: " . $_FILES["magazine"]["error"] . "<br />"; } elseif ($_FILES["cover"]["error"] > 0) { echo "Error: " . $_FILES["cover"]["error"] . "<br />"; }else { if (($_FILES["cover"]["type"] == "image/jpeg")|| ($_FILES["magazine"]["type"] == "pdf/pdf")|| ($_FILES["magazine"]["type"] == "application/zip")||($_FILES["magazine"]["type"] == "application/x-zip-compressed")) { echo "Upload: " . $_FILES["magazine"]["name"] . "<br />"; echo "Type: " . $_FILES["magazine"]["type"] . "<br />"; echo "Size: " . number_format(($_FILES["magazine"]["size"] / 1024), 2) . " Kb<br />"; //Retrieve magazine file if (file_exists("../magazines/" . $_FILES["magazine"]["name"])) { echo $_FILES["magazine"]["name"] . " already exists. "; } elseif (file_exists("../magazines/" . $_FILES["cover"]["name"])) { echo $_FILES["cover"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["magazine"]["tmp_name"], "../magazines/" . $_FILES["magazine"]["name"]); $mag_url = "../magazines/" . $_FILES["magazine"]["name"]; move_uploaded_file($_FILES["cover"]["tmp_name"], "../magazines/" . $_FILES["cover"]["name"]); $cover_url = "../magazines/" . $_FILES["cover"]["name"]; $issue_num = $_REQUEST['issue_num']; $issue_desc = $_REQUEST['issue_desc']; $issue_month = $_REQUEST['issue_month']; $issue_year = $_REQUEST['issue_year']; $query = "INSERT INTO vanity_mag (issue_num, issue_month, issue_year, mag_url, cover_url, issue_desc) VALUES ('$issue_num', '$issue_month', '$issue_year', '$mag_url', '$cover_url', '$issue_desc')"; mysql_query($query, $connection) or die ("Query failed" . mysql_error()); echo "Stored in: " . "../magazines/" . $_FILES["magazine"]["name"]; $query = "SELECT * from vanity_mag ORDER BY mag_id desc"; $result = mysql_query($query) or die ("Query failed: " . mysql_error()); echo "<table border='1'>"; echo "<TR>"; echo "<TH>ID</TH><TH>Issue number</TH><TH>URL</TH><TH>Cover URL</TH><TH>Description</TH>"; echo "</TR>"; while ($row = mysql_fetch_array($result)) { echo "<TR>"; echo "<TD>", $row['mag_id'], "</TD><TD>", $row['issue_num'], "</TD><TD>", $row['mag_url'], "</TD><TD><a href='", $row['cover_url'], "'>", $row['cover_url'], "</TD><TD>", $row['issue_desc'], "</TD>"; echo "</TR>"; } echo "</table>"; } } else { echo "<span class='message_error'>Only .pdf, .zip and .jpg files are allowed!</span>"; } }It does upload the files, but it uploads ANY file, not only the ones I want to allow. How do I fix it? Thanks!
What do you StingReplaceFile() I made in php
29/7/2011 external link
I made this little function. to work with templates. Just want to know what you think of it and if you have any suggestions.CODEFunction StingReplaceFile($string){ $pattern = '/\\}/s'; preg_match_all($pattern, $string, $matches); foreach ($matches[0] as $key => $match) { $data = StingReplaceFile(file_get_contents($matches[1][$key])); $string = str_replace("}",$data,$string); } return $string;}example usage:CODEecho StingReplaceFile(file_get_contents("a.html"))."\n";a.htmlCODEomg}omgb.htmlCODE</b>nice</b>}c.htmlCODEHello from c.htmloutput of callCODEomg</b>nice</b>Hello from c.htmlomg
SQL Database, PHP 'pages' ?
29/7/2011 external link
Ok actually I got two things.look at my websiteScroll all the way to the bottom. The first two posts have diamond shaped symbols with ?. Can anyone explain this? Each post is put on the page from a database. The code was copied and pasted directly. Like look at the current live version. All the way on the bottom is also those same two posts. I just copied and pasted the code into the database. Here is the code for one of the posts:CODE<div class="postEntry"> <img src="images/Michael.jpg" width="100" height="105" alt="Michael" id="profilePic" /><p><strong>February 21, 2011<br/> Michael Schoell</strong></p> <p><a href="darkForge.html">DarkForge</a> is one of my main projects that I continue to work on and expand. It is an engine I wrote utilizing DirectX9 and is used with: <a href="thePassage.html">The Passage</a>, <a href="mandelbrot.html">Mandelbrot</a>, and <a href="match.html">Match</a>. More information can be found on it's page. For me it is a recurring process: I expand code then I revise what I have done based on what was learned. In this fashion my code has become more robust and flexible while maintaining speed.</p> <p>While flipping through the pages of <a href="http://www.gameenginegems.net/">Engine Gems 1</a>, I came across a gem by Colt McAnlis on a camera centric engine design. The first section touched on getting DirectX9 to be usable with multiple threads. I decided to try this method out and set to work. For me, the challenge was to seamlessly integrated this concept with <a href="darkForge.html">DarkForge</a> without putting the burden on the user.</p> <p>The process is rather simple but requires some skill with synchronization between threads. No multithreaded flag is used with DirectX as it can have a serious performance hit. To do this, two command buffers are first created that will be used as memory pools. An update thread will fill one command buffer out with rendering and state calls. Once render is called, the command buffer is swapped with the render thread's and another frame can be updated while the DirectX API is working on the one the render thread owns. Only one frame ahead can be updated and each thread syncs when they are complete.</p> <p>This project has been a major challenge as it is one of my first multithreaded applications outside of school. As it is still in the early stages, it is unknown as to what performance boost will be seen though such tests are currently in the works. When a working rendering example is established I hope to show it along with a detailed report on benchmarks between single and multithreaded performance.</p> </div>It's just regular HTML code pasted directly into the database. I don't understand why those symbols appear.Ok and my second thing is, I was wondering if someone could point me in the right direction on how to do something. Pertaining to the same posts coming from the database, I want to be able to have only a certain number of posts displayed at a time and if the number of posts exceed that, then a new 'page' is formed where users can click to view the next set of posts. I hope that I am explaining this correctly. This practice is done everywhere so it's nothing new and Im sure its nothing too complicated, I just need help getting started on how-to is all. I know it will take PHP and some if statements.Please and thank you.
Searching a String
29/7/2011 external link
Hey all,I am trying to figure out a way to search a string and return only the url in it. My string is an iframe so it looks something like this...<iframe src="http://www.site.com/something" width="400" height="200" frameborder="0"></iframe>And I'd like to search this and return only the URL. I guess the catch is that the URL will change in length and value so I need a function that will work dynamically.I was able to do it for a static URL, but I am having a difficult time coming up with a way to strip the iframe code out only leaving the URL left no matter how long or different the url becomes.Any tips or tricks would be appreciated. Thanks.
How to keep $_GET variable
28/7/2011 external link
How can I keep the $_GET variables filled after refreshing the page? Do I need to work with a session or with cookies? Or should you do it totally different? When browser closes, then I don't need variables anymore next time they open page. Then I start from scratch again
Setting up ASP on new website
28/7/2011 external link
Hi all, I work for a company that uses ASP files on the website. I'm not sure if it's ASP or ASP.net. The company site is here.I would like to recreate the same environment for a website I recently purchased from GoDaddy. There's two main reasons I want to use ASP:1.) Use include files in ASP2.) Define and pass variables through the query stringNow, I've just gone ahead and saved the first page as default.asp. I've created a separate header file, and the default.asp calls for the header as an include file. When I uploaded these files to the server, the include file does not show up.I was hoping that making the site ASP would be easy, but I'm not sure if it works like that. Can someone help me out?Is my work website ASP or ASP.NET? I want to set up my new website just like that, so what steps do I need to take in order to do this?Thanks to anyone who can help out and set me straight.
DDI-TCP
28/7/2011 external link
Question ONE: What is DDI-TCP?Question TWO: How does it differ from TCP?Question THREE: When and how is it used? For example, should it be used to replace TCP when setting the $protocol parameter of the socket_create() function?Roddy
Repeat Nesting record
28/7/2011 external link
HI ALLI need help with the following code, please excuse my lack of knowledge in asp, I need to repeat a record and pass it to an object as shown, but I cant get the repeat nesting to work correctly, can you please advice, how i can make it work correctly.thank you<%Dim HEADDim Repeat3__numRowsDim Repeat3__indexWhile ((Repeat3__numRows <> 1) AND (NOT text_head.EOF))HEAD = (text_head.Fields.Item("head_TX").Value)Repeat3__index=Repeat3__index+1Repeat3__numRows=Repeat3__numRows-1text_head.MoveNext()Wend%><object type="image/svg+xml" data="/gallery/svg/layout1.svg" width="500" height="640"> <param name="text-label1" value="<%=HEAD%>" /><param name="text-label3" value="<%=HEAD%>" /></object>
adding to a database (code not working)
28/7/2011 external link
heres what im trying to do; imageshackand iv tried CODEmysql_query("UPDATE users SET update = update + 1 WHERE username = $show_username");
htaccess - non case sensitive redirects?
28/7/2011 external link
I have the simplest of redirects in my htaccess fileRedirect /folder /folder.htmBut if someone hits mydomain/FoldeR - the redirect will not kick in and they will get a 404How can I get round this?Thanks!
[solved]Need regex help
28/7/2011 external link
I am trying to match }CODE<?php$string = '} some random crap }';$pattern = '/\\}/s';preg_match_all($pattern, $string, $matches);foreach ($matches as $match) { echo $match[0]."\n";}?>but this code outputs meQUOTE }file.htmlWhat and how I need to change if I want that output look like that?QUOTE }}Edit: found code from internet and built thisCODEforeach ($matches[0] as $key => $match) { echo $matches[1][$key]."\n";}I can't understand what $key => $matchwhat does => do in there.
PHP Login System
28/7/2011 external link
Hi there,I need some help about the login system i made a usual login system which the user and pass will store to database and get the information in the databaseand my problem is the permission or access to the likei have my post for example and i will put the link the edit post. i want to hide that to the guest/viewers.anyone here can share the codes thanks so much.
Register Globals
28/7/2011 external link
Hi I have to make additions to a custom admin that was made awhile ago. The program uses register_globals.There are some registration forms that are passing variables like this:----------------- registration.php ---------------<input name="address" type="text" value="abc" />----------------- formhandler.php ---------------echo $address; ___________________________________________in other words not using POST or GET. They also are not escaping quotes when entering into the database. Would re-writing them as $_POST make any sense? Or should I just skip that and make the data safe going into the database?I am not sure what vulnerability register_globals is besides those variable names being a problem. hope someone can clear up the confusion
PHP / SQL question
27/7/2011 external link
Hi I am having a strange problem that I've been stuck on all day. Please help.SELECT `x_info`.`UID`, `x_info`.`company`, `x_info`.`state`, `x_info`.`h_phone`, `x_info`.`fax`, `x_info`.`b_phone`, `x_info`.`fax`, `x_info`.`b_phone`, `x_info`.`addr`, `x_info`.`city`, `x_info`.`zip`, `z`.`UID`, `z`.`username`, `z`.`fname`, `z`.`lname` , `z`.`email` FROM `z` LEFT JOIN `x_info` ON `x_info`.`UID` = `z`.`UID` WHERE `z`.`UID` > 0 AND `x_info`.`zip` IN (89108,89109,89118)The query works when I test it inside of phpMyAdmin (SQL tab) but in php mysql_query returns false. does anyone know why this might be happening?(x and z aren't the real table names)
Display HTML before PHP Functions load..?
27/7/2011 external link
Is it possible at all to Display HTML on a page before PHP Functions are loaded..?I have a page that reads the data and headers of some links of another page, and it makes my page take a while to load..so would there be a way to make the HTML elements of my page, like the background image and a table that has another background image load and display 1st, then have the php functions load that get the contents of the other site...is something like this possible at all...?
search form
27/7/2011 external link
HelloI am a beginner with sql.I am, however, knowledge of programeren in VBA, we have an access ADP database as frontend.en the table stand as backend on sql server.now I want make search form in which we can search registered, address, etc.I don, t how I must start this can you help me please greet M.Lammerts
login and register system using xml and .net (help)
27/7/2011 external link
hiI am a web developer that been asked by a client to create a login and register system that uses XML to pulls data from a external database server. i know hmtl, php and phpthe login and register system is for a loyalty card. i have already create the website. the client want the loyalty card holder to be able to go to the website click on the login button enter their card number and password then be taken to the next page that displays only their name, card number and points earned.the client was given a xml codes to choose from, what do they want to display and they choose to displays only loyalty card holder name, card number and points earned.that xml was given to them by the company that manages the loyalty card transactions. example of xml code:the code in code is the code that the client wants to pull outthis is only some of the code provided Account History <AccountHistory><standardHeader> <requestId>string</requestId><localeId>string</localeId><systemId>string</systemId><clientId>string</clientId><locationId>string</locationId> <terminalId>string</terminalId><terminalDateTime>string</terminalDateTime><initiatorType>string</initiatorType><initiatorId>string</initiatorId><initiatorPassword>string</initiatorPassword> <externalId>string</externalId><batchId>string</batchId><batchReference>string</batchReference></standardHeader><account><accountId>string</accountId> <pin>string</pin><entryType>string</entryType></account><report><type>string</type><minimumDate>string</minimumDate><maximumDate>string</maximumDate> <offset>string</offset><maxRecords>string</maxRecords></report></AccountHistory><EOF>is it a good idea to follow this:Build a Login and Registration System with XML http://net.tutsplus.com/articles/news/buil...ystem-with-xml/please help thanks in advance
Import Excel sheet into mySQL
27/7/2011 external link
Hi all,i have serious problem i need to find help for iti need code help me to upload excel file and insert it into mySQL database.but very important point.the excel file MORE THAN 50,000 ROWS ( File size about 6 MB )Please i need code valid to insert this large excel file into mySQL database.thanks very much
PHP Shopping cart
27/7/2011 external link
Hi - I used APPHP Shopping cart for client, but clients need multiple price list option as apposed to single pricing structure offered by this solution. I have tried several things, but so far has not been able to succeed.If anyone can help, it will be much appreciated.Regards,
Multiple DB population
27/7/2011 external link
Hi - I need some help populating two different databases with the same information from shopping cart website. Is this possible, and if, does anyone have some ideas please?Regards,
Get Real Referrer If Blocked or Forged..?
27/7/2011 external link
Is it possible at all to Get the Real Referrer If its Blocked or Forged by some browser add-on or something.?
Poll Results - Percentage
26/7/2011 external link
I have a database table with the following informationCODEpoll_id | option_id | option_name | option_votes---------------------------------------------------------1 | 1 | option_1 | 31 | 2 | option_2 | 21 | 3 | option_3 | 61 | 4 | option_4 | 781 | 5 | option_5 | 651 | 6 | option_6 | 11 | 7 | option_7 | 31 | 8 | option_8 | 51 | 9 | option_9 | 121 | 10 | option_10 | 8The 'option_votes' column shows how many votes each option has from in the poll. What I want to be able to do is return these results as a percentage.I have been trying the following query:CODESELECT *, FORMAT((`option_votes`/SUM(`option_votes`)*100),2) AS `total_votes` FROM `poll_options` WHERE `poll_id` = '1'However, this only returns the first row of the table and I want each row to display, so long as the 'poll_id' is equal to 1 (more polls will follow, with each poll taking it's own id).I have read elsewhere that you can solve the problem with 'GROUP BY', but this doesn't seem to be working either. Any help that can be provided will be very much appreciated.
Make php file exist off root directory
26/7/2011 external link
Hi, I have a simple PHP question. I usually write code in HTML or ASP. In HTML when I want to access my file off of the root directory, I will name it "index.html" and can just type in the folder name to access the page. In ASP I can do the same thing with "default.asp". What can I name it in PHP to do the same?
How to store images in mysql via php
26/7/2011 external link
I have a database setup with the following fields: ID, StoneName, StoneSize, StoneType, Thumbnail.Essentially, this is an inventory database that the user can view, edit, delete the records. This all works wonderfully. The user would like to have the form display the records and a thumbnail of the product. I cannot seem to figure out what the best method of housing the images and how to display them. I have read that it is not wise to store the images in the database. I should have the path to the thumbnail in the Thumbnail field.I want the thumbnail to be a hyperlink to the full size image (I would like it to have a lightbox effect). I currently have the inventory in a static html page with the lightbox js.I have all of the full size images in a /images directory. What do I put in the mysql 'Thumbnail' field to make this work?Any help or examples would be greatly appreciated.P.S. - for now, I will manually upload the pics to the directory, but eventually I will want to give the user the ability to upload their own pic when they are adding new inventory items.Thanks!
Upload a file and insert its location to MySQL
26/7/2011 external link
Hello!I'm trying to upload a file and write its location on the server to MySQL table. I'm trying to use an external file with connection script. This is the script (and I don't have any other code in this file): CODE<?php$connection = mysql_connect("localhost", "root", "mypasswordhere") or die ("Couldn't connect to server.");$db = mysql_select_db("only_test", $connection) or die ("Couldn't select database.");?>Then in my uploader.php file I have this line of code before my <body> tag: CODE<?phpinclude '../includes/connection_open.php'?>Then I have this code to upload the file and write to the DB:CODE<?phpif ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; }else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . number_format(($_FILES["file"]["size"] / 1024), 2) . " Kb<br />"; //echo "Stored in: " . $_FILES["file"]["tmp_name"]; if (file_exists("../magazines/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "../magazines/" . $_FILES["file"]["name"]); $mag_url = "../magazines/" . $_FILES["file"]["name"]; $query = "INSET INTO my_mag (mag_url) VALUES ('&mag_url')" or die ("Query failed" . mysql_error()); echo "Stored in: " . "../magazines/" . $_FILES["file"]["name"]; } } ?>Then after the </body> tag I have this code for external file to close connection: CODE<?phpinclude '../includes/connection_close.php'?>This file has this line of code: CODE<?phpmysql_close($connection);?>The file is uploaded and moved to the correct location, but its location isn't inserted into MySQL table. What am I doing wrong here? Thank you!
Write to a database instantly
26/7/2011 external link
Id like to be able to change variables from my database, change them and write them back onto the databaseiv tried doingCODE$showDays = ['days'];echo $showDays<a href="#" onclick="<? $showDays += 1 ?>">Buy</a>i assumed it would change visibly at least but it seems to work once then not respond to anything and then i dont know how to make it update the databaseany help would be great
Can someone help me make CSS browser specific with PHP?
26/7/2011 external link
I'm trying to get PHP to screen web browsers so that I can associate browser specific CSS files. I was wondering; can I get PHP to use the $_SERVER or HTTP_USER_AGENT to sort them out using not their HTTP_USER_AGENT value, but the CSS code -Webkit, -moz, -o, -ms, or any other browser identifying tag? Any help on how to make CSS browser specific would really help. If it's PHP, please give me an example of coding (I don't know much PHP). Thanks!
Remote File Download..?
26/7/2011 external link
is it possible to get a remote file from another site and download it through my site like a proxy, saving it to my computer..?what does the php code look like for this..?
JSON coding.
25/7/2011 external link
I have this URI that I need to call with PHP:CODEapi.tumblr.com/v2/blog//info?api_key=The URI is returning a JSON object I think. My question is how in PHP do I call the URI and store the result. Once the result is stored I think I can use json_decode(): to decode the result. My version of PHP is 5.3 so I should not have to add any extensions for json functionality from what I have read. Does anyone know how the URI is called from PHP?Thank you.
Uploading large files with PHP
25/7/2011 external link
Hello!I'm new to php programming, now I'm trying to build a small site using this language and I encountered into this problem: I'm trying to make a form for uploading files (this form will be for me only, not for other users), later I'll want to add these files to MySQL DB, but for now I'm just trying to make a form that will upload the files. I used a tutorial found on this site: http://www.w3schools.com/php/php_file_upload.aspIt works just fine with small files, but once I tried to upload a bigger file (I test everything locally), 22 MB, it didn't work. I tried to google it and I found some info that php supports only files up to 2 MB, and I have to change settings in php.ini in order to allow bigger file sizes and longer time for execution of php (here's the link: http://www.sitepoint.com/upload-large-files-in-php/). So I changed the php.ini file, and I also, just in case, defined these constraints in my php code. so now my code looks like this:CODEini_set('upload_max_filesize', '50M'); ini_set('post_max_size', '50M'); ini_set('max_input_time', 600); ini_set('max_execution_time', 600);if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; }else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"][ceil("size")] / 1024) . " Kb<br />"; //echo "Stored in: " . $_FILES["file"]["tmp_name"]; if (file_exists("../magazines/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "../magazines/" . $_FILES["file"]["name"]); echo "Stored in: " . "../magazines/" . $_FILES["file"]["name"]; } }I restarted the server after I changed the php.ini, but it still doesn't work, I still can't upload large files. Need some help with it... Thank you!
Book about PHP
25/7/2011 external link
Hi all,I have a book (some years old) which I bought long time ago...Now I am again into programming, but can I still use that book, or is it to much old school? Its a book about PHP, published in May 1999.It is called PHP Dynamische websites professioneel ondersteunenPHP Dynamic websites professional support (translation)ISBN 90-430-140-6These names are on the cover: Egon Schmid, Christian Cartus and Richard Blume
is it ok to change data type?
25/7/2011 external link
Hi i have a database and a field for an artilcles the database for this field is text is that ok to change it to long text? i have to much datas in this field this data will be crashed or not?
PHP Local Time
25/7/2011 external link
Now, before you go "This guy's an Idiot" and move on, just hear me out.I've been trying to get this to work for hours.I've tried getdate(), date(), localtime(), and everything else I can find.Any time I try to return the hour, I get 6 hrs ahead of what I want to recieve,For example if it's 12:30, I get 6:30 PM.I can't have this at all.I need EACH user to return the time in THEIR time zone.For example, if a user in the EST time zone logs on at 4:00 PM EST, it shows that it is 4:00 PM. If someone in say, California logs on at the same time, (At 4:00 PM EST, or 1:00 PM PST) it shows 1:00 PM PST)I have no clue how to do this, for testing i'm just subtracting 6 hrs from the time...Any help?
Java Web Development frameworks
25/7/2011 external link
Anyone have any idea what the hot Java Web Development frameworks are? I have been using Struts 2 at work, but I find the online support and user base to be pretty minimal. I guess that brings me to another question, is Java web development still big at all and worth pursuing to continue to learn in my spare time for projects outside of work?
RESOLVED: Requesting Help - Simple PHP Sendmail Form Problem - Thanks!
25/7/2011 external link
W3Schools Community,I'm trying to get this to send to email, but when you fill out the form and hit send, it just blanks out the form and does nothing - it doesn't send either.'contact.php' uses 'sendmail.php' to send the email - they are both in the root directory.Here is the page live (it's hosted on Linux):http://www.mywilliamsmedia.com/contact.phpsendmail.phpCODE<?php //CHECK FOR REQUIRED FIELDS if ($_REQUEST['name'] != "" AND $_REQUEST['email'] != "" AND $_REQUEST['message'] != "") { $to = "info@mywilliamsmedia.com"; $subject = "Williams Media Contact - ".$_REQUEST['name']; $message = $_REQUEST['name']; $message .= "\n".$_REQUEST['phone']; $message .= "\n".$_REQUEST['email']; $message .= "\n\n".$_REQUEST['message']; $headers = "From: ".$_REQUEST['email']."\r\n". "Reply-To: ".$_REQUEST['email']."\r\n" . "X-Mailer: PHP/".phpversion(); //SEND EMAIL mail($to, $subject, $message, $headers); //IF INCLUDING, PROVIDE USER FEEDBACK! $msg = "Message sent, thank you!"; } else if (isset($_REQUEST['submit'])) { //IF INCLUDING, PROVIDE USER FEEDBACK! $msg = "Please make sure all required fields are provided!"; } //IF NOT INCLUDING, FORWARD USER BACK TO CONTACT PAGE //header("Location: contact.html"); //exit(); ?>contact.phpCODE<?php #include "sendmail.php";?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Williams Media - Contact</title><link href="style.css" rel="stylesheet" type="text/css" media="all" /></head><body><div id="body_wrapper_container"><div id="body_wrapper"> <div id="body_header"><a id="williams_media_logo" href="index.html"><h1>Williams Media Logo</h1></a> <ul id="nav_ul"> <li class="nav_first"><a class="nav_a" href="index.html">home</a></li> <li class="nav"><a class="nav_a" href="photography.html">photography</a></li> <li class="nav"><a class="nav_a" href="design.html">design</a></li> <li class="nav"><a class="nav_a" href="news.html">news</a></li> <li class="nav"><a class="nav_a" href="services.html">services</a></li> <li class="nav"><a class="nav_a" href="about.html">about</a></li> <li class="nav"><a class="nav_a_current" href="contact.php">contact</a></li> </ul> </div> <div id="body_content"> <div id="contact_column_first"> <p class="p_contact"></p><h4 id="h4_first">jay williams</h4><p></p> <ul class="contact_dividers"> <li id="content_divider_first">CEO</li> <li class="content_divider">Creative Director</li> <li class="content_divider">Photographer</li> <li class="content_divider">Designer</li> </ul> <p class="p_contact"></p><h4>phone</h4><p></p> <ul class="contact_dividers"> <li id="content_divider_first">000.000.0000</li> <li class="content_divider"><a class="contact_phone">M-F</a></li> <li class="content_divider"><a class="contact_phone">9am-5pm (GMT-5)</a></li> </ul> <p class="p_contact"></p><h4>email</h4><p></p> <p class="p_contact"><a class="a_contact" href="mailto:info@mywilliamsmedia.com">info@mywilliamsmedia.com</a></p> <p class="p_contact"></p><h4>resume</h4><p></p> <ul class="contact_dividers"> <li id="content_divider_first"><a class="a_contact" href="resume.pdf">View</a></li> <li class="content_divider"><a class="a_contact" href="resume.pdf">Download</a></li> </ul> <p class="p_contact"></p><h4>network</h4><p></p> <ul id="contact_ul"> <li class="contact_li"><a id="social_linkedin" href="http://www.linkedin.com/profile/view?id=129932354&trk=tab_pro/" target="_blank">Linkedin.com</a></li> <li class="contact_li"><a id="social_twitter" href="http://twitter.com/#!/Williams_Media/" target="_blank">Twitter.com</a></li> <li class="contact_li"><a id="social_facebook" href="http://www.facebook.com/WilliamsMedia/" target="_blank">Facebook.com</a></li> <li class="contact_li"><a id="social_myspace" href="http://www.myspace.com/williams_media/" target="_blank">Myspace.com</a></li> <li class="contact_li"><a id="social_behance" href="http://www.behance.net/williamsmedia" target="_blank">Behance.com</a></li> <li id="contact_li_last"><a id="social_vimeo" href="http://www.vimeo.com/mywilliamsmedia" target="_blank">Vimeo.com</a></li> </ul> </div> <div class="contact_column"> <form action="" method="POST" enctype="application/x-www-form-urlencoded" id="contact_form" lang="en" height="0"> <p class="p_contact"><h4 id="h4_first"><label for="name">name *</label></h4></p> <p class="p_contact"><input name="name" type="text" id="name" /></p> <p class="p_contact"><h4><label for="phone">phone</label></h4></p> <p class="p_contact"><input name="phone" id="phone" type="text" /></p> <p class="p_contact"><h4><label for="email">email *</label></h4></p> <p class="p_contact"><input name="email" id="email" type="text" /></p> <p class="p_contact"><h4><label for="message">message *</label></h4></p><?php if ($msg != "") echo "<p id='feedback'>".$msg."</p>"; ?> <p class="p_contact"><textarea name="message" id="message" cols="" rows="11" lang="en"></textarea></p> <p class="p_contact_send"><input name="submit" type="submit" id="submit" lang="en" value="send" /></p> </form> </div> </div> <div id="body_footer"> <ul id="validation_ul"> <li id="valid_xhtml"><a href="http://validator.w3.org/check?uri=http%3A%2F%2Fwww.mywilliamsmedia.com%2F&charset=%28detect+automatically%29&doctype=Inline&group=0" target="_blank" class="validation_a_xhtml">W3C Valid XHTML 1.0 Transitional</a></li> <li id="valid_css"><a href="http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fwww.mywilliamsmedia.com%2F&profile=css21&usermedium=all&warning=1&vextwarning=&lang=en" target="_blank" class="validation_a_css">W3C Valid CSS 2.1</a></li> </ul> <p id="copyright">all content copyright © 2011 <a id="copyright_williams">williams</a> <a id="copyright_media">media</a> all rights reserved</p> </div> </div></div></body></html>Thanks for your assistance and support,Jay Williams - Williams Media.
easy to implement php framework
24/7/2011 external link
right now, i don't have much user input on my site. but soon, i want to add a search function. basically, i'm worried about the security of my site against xss and sql injection.is there a simple php framework i can implement that will reduce the effectiveness of these attacks? i'd rather not have a giant framework, i'm just looking for something small but effective.
display datetime from an array variable
24/7/2011 external link
i'm using an array to display different variables from mysql entries. i'm trying to display the date, but it keeps giving me an error:Warning: date_format() expects parameter 1 to be DateTime, string given in (blah) on line (blah)what's the best way for me to display the time using arrays? my relevant code is below.CODE<?php require("scripts/config.php"); mysql_connect($db_host, $db_user, $db_password) or die(mysql_error()); mysql_select_db($db_database) or die(mysql_error()); if(isset($_GET['pagenum'])) { $pagenum = $_GET['pagenum']; } else { $pagenum = 1; } $result = mysql_query('SELECT ID FROM linkstab') or die(mysql_error()); $num_rows = mysql_num_rows($result); $page_rows = 4; $last = ceil($num_rows/$page_rows); if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } $max = 'LIMIT ' .($pagenum - 1) * $page_rows .',' .$page_rows; $result_p = mysql_query("SELECT * FROM linkstab ORDER BY ID DESC " . $max) or die(mysql_error());?><?php while ($row = mysql_fetch_array($result_p)) { echo '<div class="contentBlock bar">'; echo '<div class="contentDesc">'; echo '<dl>'; $linkdate = $row['Date']; echo '<dt><a href="', $row['Website'], '" >', $row['Name'], '</a> - ', DATE_FORMAT($linkdate, '%a'), '</dt>'; //here's where i'd like the date echo '<dd>', $row['Description'], '</dd>'; echo '</dl>'; echo '</div>'; echo '<a class="contentBack" href="', $row['Website'], '" style="background-image:url(', $row['Image'], ')"></a>'; echo '</div>'; } mysql_free_result($result); mysql_close();?>
php database
24/7/2011 external link
I'm not connecting to my database... anything wrong with the code you can see? i'm not sure how to put hostname in, before I had localhost but it didn't workCODEfunction inserthistory($x, $y, $color){global $Login, $Password; $connection=mysql_connect('hostname:184.168.45.20',$Login,$Password) or print 'main connect failed'; mysql_select_db('ca081919',$connection) or print "main select failed"; $q="INSERT INTO history VALUES (null, '$x','$y', '$color')"; $result = mysql_query ($q, $connection) or print "query '$q' failed"; } #inserthistory
Query issue in file with .htaccess entry
24/7/2011 external link
I have at top of page:CODE if (isset($_GET['id'])) { $id = $_GET['id']; } else { $id = 'normal'; }$getQuery = "SELECT styleName FROM mmstyles WHERE styleID = '$id'";I have also an entry within .htaccess as:CODEOptions +FollowSymlinksRewriteEngine OnRewriteRule ^([^/]+)\/index.php styles/index.php?id=$1 [NC]Now my query does not work as it looks for 'styles' instead of 'normal'. I have use this sort of coding before, only that then I had all in root folder. Now, it has to go in separate folder and as this is the differentiating factor I wonder if the folder name requires a change in .htaccss that I am not aware of. Can you see where I am going wrong?Thanks,Son
how to display multiple values from a database
24/7/2011 external link
What would be a good way to display values received from a database?for example, depending on the value of some variables, some things will be visible and some things wont be.how could i display these visible values neatly, like add to a table?
PHP as CGI vs Apache module
24/7/2011 external link
What does it mean that PHP can run on the server either as CGI oras an Apache module?
accessing mysql from external program
23/7/2011 external link
I have data that is being generated with VB6. How can I access mysql directly from the VB6 application? I can generate a CSV file and then use php to load it but I would like to not have the extra step.Thanks
Can you skip an iteration in foreach() ?
23/7/2011 external link
is there a way to access the implicit index to jump ahead one step or would one just have to usefor ($i=0;$i<(count($array)-1);$i++)instead of foreach($array as $member) ?
help with form
23/7/2011 external link
hello,i need a help in creating a form. i have something like this :Enter your name : -------Submiton the next line, the output should beYour referral URL is : http://sitename.com/?referral=namecan anyone help me please!sorry im not a programmer. i just need this help from you people.thanks alot
Looking for an specific search result based on a variable and having COUNT
22/7/2011 external link
Here I am again, now I am having trouble merging two queries. I want to be able to search my recipe inventory by ingredient, but I also want it to tell me how many ingredients I am missing for that certain recipe. I am able to do a search by just ingredient and I am also able to do a search by just showing me how many ingredients I'm missing, but I have not been successful to combine the two. This is my codeSQLSELECT Recipes.name_of_recipe,Recipe_Ingredients.quantity, Recipe_Ingredients.measurement, Ingredients.ingredient_name, Category.category_name, Recipes.recipe_id, COUNT(Ingredients.availability)FROM Recipes, Category, Ingredients, Recipe_IngredientsWHERE Recipes.category_id = Category.category_id AND Ingredients.ingredient_id = Recipe_Ingredients.ingredient_id AND Recipe_Ingredients.recipe_id = Recipes.recipe_id AND Ingredients.ingredient_name LIKE varIngredient AND Recipe_Ingredients.recipe_id = Recipes.recipe_id AND Ingredients.availability IN (SELECT Ingredients.availability FROM Ingredients WHERE Ingredients.availability = "no") When I run the query I get this server error "Parse error: syntax error, unexpected T_STRING in page.php on line 47", which is where my SQL query resides on the document.If anyone can help, that'd be great, this is the last piece of the SQL puzzle in order to make my site work the way I want it to work.
Enter integer into db
22/7/2011 external link
I think that I have been coding incorrectly for many years with regard to integers and I just stubled upon this. I use:CODE if (!isset($_POST['webStyle']) OR empty($_POST['webStyle'])) { $webStyle = FALSE; $errors['webStyle'] = 'Colour'; } else { $webStyle = escape_data($_POST['webStyle']); }something like this when I offer selections on web form that feed into table column that holds integer. Having had a tiny issue and using var_dump it became now apparent that I treat those integer values like strings. Do I need to code some other special precausion into the code or could I simply set $webStyle = $_POST['webStyle'] for example?Son
Auto Notification Without Accessing Scrip File, Possible?
22/7/2011 external link
Hi Friend.Please Tell Me How Can I Send Auto Notifications To My Customers Automatically After Every 24 Hours.Is It Possible To RUN NOTIFICATIONS SCRIPT Without Accessing SCRIP FILE?I Heard About "CRON JOB", But I'm Not Sure About It.Please Guide Professionals
search for other fields by username
22/7/2011 external link
in my table i haveusername | age | --------------------1-------------202-------------253-------------30how can search for a users age by there username?like: find username 1's age and echo it
Generate Tables from .SQL
22/7/2011 external link
So I get how to create a new database via PHP. But is there a way to load the tables from a .SQL file so I don't have to manually do 100's of table creates via php?Note* the .sql file would be on my server so no upload would be required.Any help would be great thanks!
setting default integers
22/7/2011 external link
how can i set a default value for an integer?iv tried:luck int DEFAULT '0'but im returned:#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' luck int DEFAULT '0' at line 4EDIT: My mistake; i didnt realise i needed to put ADD in front of every new collum i wanted.
Can't run MySQL query
21/7/2011 external link
Some time ago I've been here on this forum, but now, after some time, I'm trying to make a PHP script again...and as usual, I need some help.I'm trying to run this query:SQLCREATE TABLE movies ( id MEDIUMINT NOT NULL AUTO_INCREMENT, name CHAR(30) NOT NULL, agelimit CHAR(30) NOT NULL, release CHAR(30) NOT NULL, added DATE NOT NULL, PRIMARY KEY (id)); But violently, just out of the sky, this error message appears:QUOTE #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'release CHAR(30) NOT NULL, added DATE NOT NULL, PRIMARY KEY (id) )' at line 5
Filtering SQL results for recipe database
21/7/2011 external link
Hello all, I hope I can get some help with this. I am still pretty new to SQL and now after three days of tinkering with this code I have come to a stand still. I am trying to create a personal database on which I can store my recipes by book and be able to display my recipes based based on the ingredients I have on hand. Now I'm trying to make that page. This is the code SQLSELECT Recipes.recipe_id, Recipes.name_of_recipe, Category.category_name, Ingredients.availabilityFROM Recipes, Category, Ingredients, Recipe_IngredientsWHERE Recipes.category_id = Category.category_id AND Recipe_Ingredients.ingredient_id = Ingredients.ingredient_id AND Recipe_Ingredients.recipe_id = Recipes.recipe_idGROUP BY Ingredients.availability, Recipes.name_of_recipeORDER BY Recipes.name_of_recipe and these are the results that I get so farCaribbean Chicken with Creamy Avocado Main Dishes yesCaribbean Chicken with Creamy Avocado Main Dishes noChicken and Mushroom Marsala Main Dishes yesChicken with Chipotle Sauce Main Dishes yesAs you can see, the caribbean chicken shows up twice because I'm missing ingredients and therefore there is a "no" on part of the ingredients side. If anyone can help me with the SQL code, it would be greatly appreciated. I can wait to have this recipe database up a running
Easily distributable PHP framework for applications
21/7/2011 external link
Hi,I was wondering if anybody knew of any PHP frameworks, specially suited for re-distributable applications? Modern frameworks are very good for splitting the different layers of an application, but they don't strike me as very distributable. I want a good structure and feel to the framework, without quite so much of the bloat and no special requirements to get it running. My application isn't huge, so doesn't need complex routing or multi-application capabilities, etc. Anybody have any to recommend?ThanksAdam
Problems w/ mysql_fetch_array()
21/7/2011 external link
Hi all!!!I've adapted the code of http://www.w3schools.com/php/php_ajax_livesearch.aspto my MySQL table so I can show a live search with AJAX. Evething looks fine but when I choose the category a get an error mesage:Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\UsedMachines\getuser.php on line 25PLEASE! anyone can help??????JaumeI copy the code---------------------------------------------------------------------------------------<?php$q=$_GET["q"];$con = mysql_connect('localhost', 'UsedMachines', 'jauman');if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("usedmachines", $con);$sql="SELECT * FROM usedmachines WHERE family = '".$q."'";$result = mysql_query($sql);echo "<table aling=center><tr><th>Family</th><th>Model</th><th>Hours</th><th>Price</th></tr>";while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['Family'] . "</td>"; echo "<td>" . $row['Model'] . "</td>"; echo "<td>" . $row['Hours'] . "</td>"; echo "<td>" . $row['Price'] . "</td>"; echo "</tr>"; }echo "</table>";mysql_close($con);?>-------------------------------------------------------------------------------------
FedEx Shipping API Issue.
21/7/2011 external link
Hi Friend,I'm Using FedEx Shipping API in PHP Format, But I'm Getting Some Errors In It.Can Anyone Please Provide Me Another FedEx API Code Or Can Resolve This Code.You Download Code From Here: http://www.varnagiris.net/wp-content/uploa...06/06/Fedex.zipI've Also Enabled "cURL".I'm Using Correct Account# & Meter# In It.Still Getting An Errors.Please Help Me Out.
Store multiple usernames in the same field as a String?
21/7/2011 external link
How can i store multiple usernames in the same field as a string on a database?Each user has a field for freinds and when they click 'add as friend' on someones profile, id like it to add to their friends field so i can use it when it comes to sending message.
Store multiple usernames in the same field as a String?
21/7/2011 external link
How can i store multiple usernames in the same field as a string?Each user has a field for freinds and when they click 'add as friend' on someones profile, id like it to add to their friends field so i can use it when it comes to sending message.
str_replace();
21/7/2011 external link
I can not understand at all why my call to str_replace is returning a null string:CODEif($artsize > 9) { for ($i = 0; $i < 10; $i++) { $colpos = strpos($articles[$i][1], ":" ); $twithandle = substr($articles[$i][1], 0, $colpos); $new = str_replace($twithandle, '<a href="">Testing:</a>', $article[$i][1]); echo " <br>"; echo "...<a class='feed' href='' target='_new'>More ></a><br/><br/>"; }}$twithandle clearly contains a string as does $article[$i][1]. Something is very fishy with this.
when php, mysql, html intersect
21/7/2011 external link
Yesterday morning, I would've said I knew how php, mysql, html work together. Yesterday afternoon, it was obvious that I didn't have a clue or at least didn't know enough probably because I started with an assumption that all I had to do was get the html/css containing php variables in a mysql table, SELECT it, and place it as needed.Though I worked through my problem successfully (with indispensable help from the forum), I learned that storing HTML in a mysql table is odd to a lot of people.Why is that?What's the preferred approach?Please use use this script as a starting point for a reply if possible: CODE<p style="font-size:9px;margin:0px;"> <span style="background-color:yellow">Expires VARIABLE DATE GOES HERE. </span></p>
private variables/scope conflict?
20/7/2011 external link
so the other day I was stumped trying to implement usort, using a simple custom function, wherein I needed the comparison key to be dynamic. Basically I was sorting a bunch of sport stats and needed to sort the stats according to a specific mapping that was being passed into my class (in order to maintain integrity with javacript functionality for showing hiding the stats based on a link being clicked on the page). Given that the class has been instantiated, and we are calling the render method, this is what wasn't working...CODEclass LeadersTabContentRenderer{ private $leaders; private $leadersMap; private $sportId; private $leadersByStat = array(); private $currentStat = ''; function __construct($leaders, $leadersMap, $sportId){ $this->leaders = $leaders; $this->leadersMap = $leadersMap; $this->sportId = $sportId; } private function sortStats($a, $b){ if ($a[$this->currentStat] == $b[$this->currentStat]) { return 0; }; return ($a[$this->currentStat] > $b[$this->currentStat]) ? -1 : 1; } private function render(){ $output = ''; $temp = array(); $output .= '<ul class="tabs"> '; foreach($this->leadersMap as $key => $value){ $output .= '<li><a href="" class="stat" name="' . $key . '">' . $value . '</a></li>'; $this->currentStat = $key; $temp = $this->leaders; usort($temp, sortStats); $this->leadersByStat[$key] = $temp; }; $output .= '</ul> '; return $output; }}basically the output was fine, as far as the page was concerned, but nothing was being sorted. I couldn't figure out why it wasn't working. I had implemented usort in another application where the sorting key was known, and the data structure was the same as this one; $leadersMap is a numeric array of associative arrays. When I hardcoded the key in the sort function, it would work. i.e.CODEif ($a['bbasst'] == $b['bbasst']) { return 0;};return ($a['bbasst'] > $b['bbasst']) ? -1 : 1;eventually I got it working using something I found online, making the sort function accept the field for sorting, and changing the render functionCODEprivate function orderStatsBy($data, $field){ $code = "return strnatcmp(\$a['$field'], \$b['$field']);"; usort($data, create_function('$a,$b', $code)); return array_reverse($data);}..$menu .= '<ul class="tabs"> ';foreach($this->leadersMap as $key => $value){ $menu .= '<li><a href="" class="stat" name="' . $key . '">' . $value . '</a></li>'; $this->leadersByStat[$key] = $this->orderStatsBy($this->leaders, $key); }; $menu .= '</ul> ';so two questions (hopefully I didn't leave anything critical out in the code basic code snippets, having written this after committing my completed work): 1) any reason why in the above contect $this->currentStat wasn't being interpreted correctly (or in a way I thought would/should have worked), while a hardcoded value would have? a conflict of scope?2) is the implementation of orderByStats good? I have to admit, I found it online, so I don't want to use something that promotes bad practices, and it kind of feels like's it written using the eval() of PHP.
printf()
20/7/2011 external link
I have this code that displays properly:CODEprintf("<p style=\"font-size:9px;margin:0px;\"> <span style=\"background-color:yellow\">Expires %s. </span></p>",$expdat); Now, I need to turn the code between in <span> in to a variable with a variable.How do I code for the second variable in printf() when?:$dclaim = <span style=\"background-color:yellow\">Expires' . $expdat . '.</span>
Primary key?
20/7/2011 external link
How do I set a primary key? Are there any examples in the tutorial?
HTML/JS page wont call PHP script or PHP isn't being run.
20/7/2011 external link
Hi everyone. I'm new here and new to making a website too so this might be a really dumb request, I've searched though and done the tutorials and I don't know what is wrong so.. here I am. The problem is that I've made a HTML and JavaScript page which calls a PHP script with an XMLHttpRequest Object and an Open/GET command (I hope this is the right terminology, please do correct me if it isn't) and as far as I can tell all the code is hunky dory but when I press the button to get the PHP script to work it doesn't seem like anything happens...I got fed up trying to figure out what was wrong with the script and wondered if I'd done something fundamentally wrong so I uploaded the examples from this page:http://www.w3schools.com/php/php_ajax_php.aspand that didn't work either.I used the same filenames it said on the tutorial with the right file extensions and I had them both in the same directory but no dice, I type in the box but nothing happens. :sAnyway, I took those back off the server and put my one back on and I found if I just went straight to my PHP script by typing the url used in the javascript call (including the bit with the question mark, like script.php?passedParameter=10 or something similar) straight into the browser, the browser showed the text that should be sent to the html page. But if I try and get at it from the HTML page, nothing. Oh, and the server I'm using is a free page on www.zymic.com which says it supports PHP and even has a bunch of PHP tutorials on there as well (though none of them helped with my problem).I think I must've missed something fundamental to how it all works but I just don't know what it is or where to find it, so I'd be really thankful for any suggestions.Cheers. Wannabecoder.
website works on local machine, error when hosted
20/7/2011 external link
i tested my script for my website on my local machine (setup with xampp), and it works fine.so i uploaded it to my website today, and it gives two errors. long story short, i made a test page that removed all the html from the php script.CODE<?php ob_start(); ?><?php $db_host = 'localhost'; $db_user = ''; $db_password = ''; $db_database = ''; mysql_connect($db_host, $db_user, $db_password); mysql_select_db($db_database); $result = mysql_query('SELECT * FROM linkstab ORDER BY ID Desc'); ?> <?php print_r(mysql_fetch_array($result)); /*while ($row = mysql_fetch_array($result)) echo $row['Website'], $row['Name']; echo $row['Description']; mysql_free_result($result); mysql_close();*/ ?><?php ob_end_flush(); ?>the website and error are located here hometest.phpfor some reason, it doesn't like the array that i set up to display the $result query information.does anyone have any suggestions?
echo a html form?
20/7/2011 external link
Is it possible to echo a html form?this is what im currently doing:<?echo("<form action=\"" . $_SERVER['PHP_SELF'] . "\" method=\"post\"></form>");?>is there a way to, i don't know, reference it to a html form? for example:<?echo($html_form_name);?>
While Looping Issue
20/7/2011 external link
I have a database table named count. Inside lives some fields for example, date, song, playcount.I've managed using SUM() to get the total playcount based by date. Nice, so I have a way to look at daily TOTAL play counts. How it works is every song has a date and the playcount is an integer that gets updated every time someone plays a song, so I sum() playcount based on the date. Anyways back to the issue. For instance I have 2 songs, so the fields look like thistablename:countsong playcount datesong1 12 07/19/11song2 25 07/19/11But what is stumping me is trying to get a break down based by song and day. The trickory behind it is it needs to be looped/echo'd out in this manor.['$date' , $song1count, $song2count]I just cant think of a way to sort by date and have it loop the different songcounts NEXT to each other... Everything I've attempted will result in this...['07/19/11', 12]['07/19/11', 25]When it needs to spit it out like...['07/19/11', 12, 25]Any pointers/ideas would be much appreciated!
Possible escaping quotes problem
20/7/2011 external link
This script displays the way I need it to when I manually insert it into my script with the correct value for $expdat: <span style="background-color:yellow">Expires ' . $expdat . '. </span>How should I escape the quotes to be able to echo it from a mysql table?If I just INSERT it (as is) into a mysql table and echo it from there, it displays as: Expires ' . $expdat . '.
check is logged in
19/7/2011 external link
how can i check that the user is logged in on a webpage?currently i have this on the page you are directed to when you have successfully logged in:<? session_start();if(!session_is_registered(myusername))?>which immediately returns you to the login page which i think is because i changed session_register() to $_SESSION[] on the checklogin page, this is what i have now: $_SESSION['username'] = $myusername; $_SESSION['password'] = $mypassword;how do i check this? im thinking i need to change:session_is_registeredto something else? any help would be great
PHP Form
19/7/2011 external link
Hello I need some help with a basic PHP mail form. I need to have one field be required only if another is selected. So say preferred contact method is selected as "email" (I'm using a drop down menu) then only the email field would be required and not telephone. Is there an easy way to do this?Thanks




