-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
Problem in creating a dynamic unordered list using php
Ch0cu3r replied to AtifMahmood's topic in PHP Coding Help
$qry_secs="SELECT DISTINCT groupid FROM usersgroup WHERE userid =0"; You are selecting groupId from the usersgroup table. Shound't it be the usergroups table $newqry = "SELECT distinct subgroupid FROM groupitems WHERE groupid ".$row_secs['groupid']; You need to add a = before ".$row_secs['groupid']; in your query Having said that, doing sub queries on results from another query is very inefficient for the database. You should look into using JOINS, untested code result_secs = mysql_query("SELECT ug.groupid, gi.subgroupid FROM usersgroups AS ug JOIN groupitems AS gi ON USING(groupid) WHERE ug.userid = 0"); $usergroups = array(); while($row_secs = mysql_fetch_assoc($result_secs)) { $usergroups[$row['groupid']][] = $row['subgroupid']; } echo '<ul>'; foreach($usergroups as $groupid => $subgroups) { echo '<li><b>Group ID: ' . $groupid . '</b><ul>'; foreach($subgroups as $subgroupid) { echo '<li><a href="#">' . $subgroupid . '</li>'; } echo '</ul></li>'; } echo '</ul>'; -
This is not how mod_rewrite works. It does not automatically change the urls for you. You need to change your existing urls to the new url format that matches the rewriteRule you setup in the .htaccess. eg change your links to echo '<a href="/hotels/id/'.$hotel_id.'>View Hotel</a>'; When you click the link you'll go to locahost/hotels/id/21. Here mod_rewrite will match that url with the rewriterule in the htaccess. It'll now pass the number 21 to hotels.php?id=21.
-
You'll need to add the hi/lo difference to an array and then use min/max on that array eg function displayData($fp) { //define an array to store data $stocks = array(); //read each line into an array, save name and team using an associative array while(!feof($fp)) { // read the current line $info = fgetcsv($fp, 250, ','); // add dataa only if data is nonempty if ($info[0] !="") { // read the date into a variable $date = $info[0]; // add this information to associative array //use $date as the key $dif = $info[2]-$info[3]; $dif_o = $info[1]-$info[4]; $stocks['dif'][] = $dif; // add hi/low differenc to array $stocks['dif_o'][] = $dif_o; // add open/close differenc to array }// end if echo "Date: ".$date.", Difference between Hi and Lo: ".$dif.", Difference between Open and Close: ".$dif_o."<br/>"; }//end while // get the min/max hi/lo difference $min=min($stocks['dif']); $max=max($stocks['dif']); echo "<b>DIF</b> Min: ".$min." Max: ".$max."<br/>"; // get the min/max open/close difference $min=min($stocks['dif_o']); $max=max($stocks['dif_o']); echo "<b>DIF_O</b> Min: ".$min." Max: ".$max."<br/>"; }
-
Reusing a variable, but the variable is empty.
Ch0cu3r replied to antbates1991's topic in PHP Coding Help
Remove the single quotes. Variables are not expanded in single quotes. $CustomerID = $rowcustomer['CustomerID']; $FirstName = $rowcustomer['FirstName']; $SecondName = $rowcustomer['SecondName']; $PhoneNumber = $rowcustomer['PhoneNumber]; -
Thread Locked. You already have asked about this before. http://forums.phpfreaks.com/topic/286265-psd-files-and-a-web-gallery/ I have given you the answer for how to handle the PSD files in your gallery. You'll have to find some way to implement the PSD reader class into the plogger code so it converts the psd image into a jpeg. If you are new PHP and dont have much coding skills then you'll need hire someone to do the edits for you.
-
Did you not bother looking at http://php.net/mysql_query to see how to use that function? The missing code is. $results = mysql_query($select);
-
You have defined the query ($select) but you have not executed it. You need to call mysql_query to run a sql query on a mysql database (provided you have connected to MySQL and selected a database first)
-
A simple oversight install latest MySQL, Apache & PHP
Ch0cu3r replied to yshua's topic in PHP Installation and Configuration
I have been goggling Apache exit status 255, which appears to mean that Apache is crashing. Seeing as it immediately crashes after serving a php file. it would appear PHP is causing this. What is causing this I do not know as I have never experienced this behaviour with Apache and PHP on Windows. It could be a Windows8 specific bug (I cannot confirm this as I only have Windows 7). What I think could be the cause is a php extension. Try disabling all extensions you have enabled in the php.ini (making sure apache after editing the php.ini). Then try index.php again. If it does not crash then enable one extension at a time until you do get a crash. Post here what extensions are causing this. -
You just need to check to see what value $_POST['txtRadio'] holds when the form is submitted if(isset($_POST['txtRadio'])) { if($_POST['txtRadio'] == 'Purchase') { // the Purchase radio button was selected } elseif($_POST['txtRadio'] == 'Sell') { // the Sell radio button was selected } else { // the user submitted an unexpected value? } } else { // the user did not select a radio button }
-
A simple oversight install latest MySQL, Apache & PHP
Ch0cu3r replied to yshua's topic in PHP Installation and Configuration
The PHP Warning message can be solved by setting date.timezone to your timezone in the php.ini Find ;date.timezone = And change it to date.timezone = Place/Your/Timezone/Here Save php.ini and restart Apache. But what I don't get is. Apache is restarting itself immediately after serving phpinfo.php -
How and when is the checkB4SaveForm() JavaScript function called? If you are trying to call that function from PHP then you cant. PHP and Javascript are two complete different languages, you cannot read each others variables/functions.
-
The newlines are infact being saved in the database. The problem is the web browser ignores whitespace characters such as newlines. What you need to do is convert the newlines in to a HTML line break tag <br /> in order for the web browser to render the text on a new line. PHP has a handy function to do this for you called nl2br You'd use the function when outputting the data from the database
-
Yes, you can match different urls to different files. But you need to add some sort of unique identifier in your url in order for mod_rewite to know which file to route the request to. What is the current contents of your .htaccess file?
-
need help w/ emsgs loading php ext files
Ch0cu3r replied to yshua's topic in PHP Installation and Configuration
Sorry, I left this step out of my instructions posted earlier. Open the php.ini and find ; On windows: ; extension_dir = "ext/" Change it to ; On windows: extension_dir = "C:/php/ext" Save the php.ini and restart Apache. -
Simple RewriteRule works on one production server, not on dev
Ch0cu3r replied to sKunKbad's topic in Apache HTTP Server
You may have a setting called MultiViews enabled on your dev-sever. Does adding Options -MultiViews To the top of .htaccess help? -
Do you mean create a folder using the value stored in the $reference variable. If that is the case, you'd just pass that variable to mkdir mkdir($reference); If you want to create folder in a specific place, then you'll need to prepend the parent path mkdir('path/to/patent/folder/'.$reference);
-
When renaming the variable, you are not changing its value. The value will still be the same. The problem is the $province variable used in your include is overriding the $province variable used in the parent file. To prevent this you need to rename the $province variable used in the include file. This will be the code for the include, with the $province variable being renamed to $theProvince <?php $country=$_GET[country]; $province_numbers=array(); $additional = array(); $select="SELECT distinct province FROM rental WHERE country = '$country' order by province asc "; $results = mysql_query("$select", $link_id); if(mysql_num_rows($results)>0){ while ($query_data = mysql_fetch_row($results)) { $theProvince=$query_data[0]; if(trim($theProvince==""))continue; $theProvince=stripslashes($theProvince); echo "<li><a href=\"rentals.php?province=$theProvince&country=$country\" title='$theProvince $country'>$theProvince</a></li>\n"; } } ?> The $province variable used in the parent file will not be affected by the code in the include file.
-
PHP add some string to filename in address bar and display
Ch0cu3r replied to durgaprasadcs's topic in PHP Coding Help
Sorry, my rewriteRule should of been RewriteRule ([a-z]+)-([0-9]+)/? viewrecords.php?ID=$2&cityname=$1 [NC]- 6 replies
-
- php
- addressbar
-
(and 1 more)
Tagged with:
-
PHP add some string to filename in address bar and display
Ch0cu3r replied to durgaprasadcs's topic in PHP Coding Help
Oh now I understand. What you'll want to look at is mod_rewrite. You don't dynamically create new files on the fly. So if you want your urls to be site.com/delphi-123 (like this forum) you'd use the following mod_rewrite rule a in a .htaccess file RewriteEngine On RewriteRule ([a-z+])-([0-9+)/ viewrecords.php?ID=$2&cityname=$1 [NC] The above rewrite rule will match a url like site.com/delphi-123 and then pass delphi and 123 as querystring parameters to viewrecords.php. Now for your code create that url you'd use this $id = $row['ID']; $city = $row['CITYNAME']; echo "<a href=\"/$city-$id/\">$city</a>";- 6 replies
-
- php
- addressbar
-
(and 1 more)
Tagged with:
-
How to show static image when there is no dynamic image
Ch0cu3r replied to parlanchina's topic in PHP Coding Help
Does all images that appear broken have the following url http://imagesus.homeaway.com/mda01/1b79ecc4-46fe-49fe-bb75-ac1ec359a177.1.3 -
PHP add some string to filename in address bar and display
Ch0cu3r replied to durgaprasadcs's topic in PHP Coding Help
Dont, know why you'd do this but. What you need to do is build the filename from the values in the ID and Cityname field from the database, eg $id = $row['ID']; $city = $row['CITYNAME']; $linkFile = $city.'-'.$id.'.php'; echo "<a href=\"$linkFile\">$city</a>";- 6 replies
-
- php
- addressbar
-
(and 1 more)
Tagged with:
-
How to show static image when there is no dynamic image
Ch0cu3r replied to parlanchina's topic in PHP Coding Help
What is the output of var_dump($data['thumbnailUrl']) -
You need to create a delete link for each file, passing in the file to be deleted in the link. The delete link will be similar to the link used for viewing the file. Example delete link could be $deletelink = "<a href=\"delete.php?folder=$view&file=$file\">Delete</a>"; Now in delete.php you'd make sure a) the user owns that file (it should be in their own folder) and b) the file exists. Then you you can pass the file to the unlink function suggested by paddyfields to delete it.
-
How to show static image when there is no dynamic image
Ch0cu3r replied to parlanchina's topic in PHP Coding Help
Maybe use empty instead of is_file