PHP - Errors Developing Locally After Downloading Php Site
Hi guys, PHP Noobie here. Sorry if I am not using the correct terminology.
I am editing a site that was developed in php and all their page.php files are in one folder, the public_html folder. I downloaded the site locally and am using EasyPHP to view changes to the site. My initial problem is, when developing locally, only some of the links work. The following link works. <a class="red" href="benefits.php">Click here</a> The following link does not work. Error 404 <a class="red" href="/placement/">Click here</a> Also, the links in the flash banner do not work... They request this url: http://127.0.0.1:8888/services.php If I type in: http://127.0.0.1:8888/MyCompany/services.php , the browser will then render the page. Finally the scripts cant connect to the database and any user requesting information does not have access. Warning: mysql_query() [function.mysql-query]: Access denied for user ''@'localhost' (using password: NO) in C:\Program Files (x86)\EasyPHP-5.3.6.0\www\MyCompany\placement\index.php on line 108 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\Program Files (x86)\EasyPHP-5.3.6.0\www\MyCompany\placement\index.php on line 108 Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\EasyPHP-5.3.6.0\www\MyCompany\placement\index.php on line 109 Any Ideas on this problem or and foresight on other problems I may run into... with the database maybe? Similar TutorialsThis is the view of the events (basic) Can I do the if/else statement to chose font color base of a MySQL Query Result? (see below) And No matter how I have written this, it will not turn into a scrolling table. I want the headers to stay fixed. I also don't want to rely on Java-most of the staff logs in mobile. I will if I have to though! The other thing I am not seeing how to do, but I know is also possible.... having an "edit event" "view positions" buttons. I am thinking it has to do with storing a variable, but how do you make sure the variables code pulls the event singularly from your query using the Event_ID ?? This is my first site outside of an HTML site. This is the raw synopsis: Building a site that has users with profiles & 6 permission levels. Client & various staffing levels; I use php to code the access because it is not so much about being able to query/change the database-its more so I am handling with php. There is a time log, and keeps up with the pay to the staff and what the client owes per their hours. This is the first layer view once logged in as any staffmember (sans the edit event which is reserved for high perm staff) upon clicking "view positions" they need to be able to request the shift (separate table-please correct me if I am wrong-I have all foreign keys in database in place so making this event table should be along the same as all the others but with diff variables/queries etc. So in theory all I have to do is get the grabbing of the ID field and using it down) Here is my code. Why is it not setting the client named in green? <html> <body> <?php require_once('auth.php'); ?> <?php $sql = "SELECT * FROM Events ORDER BY EventDate DESC LIMIT 40"; $sqlRes = mysql_query($sql); $req1 = mysql_num_rows($sqlRes); $colorpick = $sqlRes['BusinessName'];?> <div class="event_view"> <table border="1" cellspacing="2" cellpadding="2" width="100%" height="100%" bgcolor="silver" style="border-collapse:collapse;"> <tr> <th><font face="Arial, Helvetica, sans-serif" color="black">Event Date</font></th> <th><font face="Arial, Helvetica, sans-serif" color="black">Event Name</font></th> <th><font face="Arial, Helvetica, sans-serif" color="black">Start Time</font></th> <th><font face="Arial, Helvetica, sans-serif" color="black">End Time</font></th> <th><font face="Arial, Helvetica, sans-serif" color="black">Client Name</font></th> </tr> <?php $i=0; while ($i < $req1) { $f1=mysql_result($sqlRes,$i,"EventDate"); $f2=mysql_result($sqlRes,$i,"EventName"); $f3=mysql_result($sqlRes,$i,"Hour"); $f4=mysql_result($sqlRes,$i,"EndHour"); $f5=mysql_result($sqlRes,$i,"BusinessName"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif" color="black"><?php echo $f1; ?></font></td> <td><font face="Arial, Helvetica, sans-serif" color="black"><?php echo $f2; ?></font></td> <td><font face="Arial, Helvetica, sans-serif" color="black"><?php echo $f3; ?></font></td> <td><font face="Arial, Helvetica, sans-serif" color="black"><?php echo $f4; ?></font></td> <td><?php if($colorpick == 'ClientA') { ?> <font face="Arial, Helvetica, sans-serif" color="green"><?php echo $f5; ?></font>; <?php } else($colorpick != 'ClientA'); ?> <font face="Arial, Helvetica, sans-serif" color="black"><?php echo $f5; ?></font></td> </tr> <?php $i++; } ?> </table> </div> </body> </html> this is on amensharma.co.uk/testing Code: [Select] <?php $db_link = mysql_connect("amensharma.co.uk","amenshar_admin","amen001"); if (!$db_link) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db('amenshar_calender', $db_link); if (!$db_selected) { die ('Can\'t use database : ' . mysql_error()); } ?> this is the error it returns Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'amenshar_admin'@'neptune.servers.rbl-mer.misp.co.uk' (using password: YES) in /home/amenshar/public_html/testing/functions/database.php on line 4 Could not connect: Access denied for user 'amenshar_admin'@'neptune.servers.rbl-mer.misp.co.uk' (using password: YES) bit stumped here any help would be great all the details are correct, just confused why im having these errors Hi all, I am looking for scripts/tutorials to create a range of simple graphical displays like bar graphs and pie charts. Does anyone know of some good tutorials to get me started? Thanks I would like to develop a classifieds website like olx.in. For that choosing a PHP as language is good or not? Please let me know your suggestions for starting the development. Hi guys, I am developing an MVC application and need some advice about how to set up url routing. Currently I can map a uri to modules/controllers and actions. I though I might leave the routing to last but it seems like that might have been a bad idea. Initially I though I might implement a Zend style routing approach and I still want to do this, but I am lost for thoughs on how I might go about this, I have looked at the zend router classes and understand the principle but cant seem to implement it in my own mvc. So far I have this, $router is an instance of a router class. mapRoute takes a route name and a route object as parameters. The name will be used for convinience. The second parameter takes a route instance which currently takes two parameters, where param1 is a route pattern and param2 is deafult values for when a uri macthes the route pattern. So if a user types http://example/user/23, the router should map to user controller, profile action. The id, which is 23, will need to be injected into a request object. Finally the router object will be added to a front controller instance, so the front controller object can gain access to all the routes. Code: [Select] $router->mapRoute("user", new Route( "user/<id>", array( "controller"=>"user", "action"=>"profile" ) ) ); If any one has any ideas please do share, im not after code, unless you want to supply some, I just need some advice to stream line the whole process or what the best way might be. Any help will be greatly appreciated. HI everyone, Here is my code: Code: [Select] $myFile = "newuser.txt"; $fh = fopen($myFile, 'r'); $theData = fread($fh, 55); fclose($fh); $pices=explode(' ', $theData); And it opens up newuser.txt which is: "I love girls LOL 77" The "I Love GIRLS LOL" is the username of the user and the 77 is the id of the user! But when I echo it out like this: Code: [Select] <a href=".?act=Profile&id='.$pices[1].'">'.$pices[0].'</a> It shows only the letter "i"? How do I make it show the full username even if it has spaces? Hey guys, i was wondering if any1 cud help me. I have a database search engine that I'm currently working on, everything seems to be working fine locally including pagination but as soon as i upload the site online, the pagination doesn't work properly. when you use the search bar the results on the first page are correct, but as soon as you click next or page 2 it automatically returns wrong data. how can i fix this since it works fine locally???
Hi Everyone !!!! This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=317036.0 I am working on a project where I want a select form to display information from a MySQL table. The select values will be different sports (basketball,baseball,hockey,football) and the display will be various players from those sports. I have set up so far two tables in MySQL. One is called 'sports' and contains two columns. Once called 'category_id' and that is the primary key and auto increments. The other column is 'sports' and contains the various sports I mentioned. For my select menu I created the following code. <?php #connect to MySQL $conn = @mysql_connect( "localhost","uname","pw") or die( "You did not successfully connect to the DB!" ); #select the specified database $rs = @mysql_SELECT_DB ("test", $conn ) or die ( "Error connecting to the database test!"); ?> <html> <head>Display MySQL</head> <body> <form name="form2" id="form2"action="" > <select name="categoryID"> <?php $sql = "SELECT category_id, sport FROM sports ". "ORDER BY sport"; $rs = mysql_query($sql); while($row = mysql_fetch_array($rs)) { echo "<option value=\"".$row['category_id']."\">".$row['sport']."</option>\n "; } ?> </select> </form> </body> </html> this works great. I also created another table called 'players' which contains the fields 'player_id' which is the primary key and auto increments, category_id' which is the foreign key for the sports table, sport, first_name, last_name. The code I am using the query and display the desired result is as follows <html> <head> <title>Get MySQL Data</title> </head> <body> <?php #connect to MySQL $conn = @mysql_connect( "localhost","uname","pw") or die( "Err:Db" ); #select the specified database $rs = @mysql_SELECT_DB ("test", $conn ) or die ( "Err:Db"); #create the query $sql ="SELECT * FROM sports INNER JOIN players ON sports.category_id = players.category_id WHERE players.sport = 'Basketball'"; #execute the query $rs = mysql_query($sql,$conn); #write the data while( $row = mysql_fetch_array( $rs) ) { echo ("<table border='1'><tr><td>"); echo ("Caetegory ID: " . $row["category_id"] ); echo ("</td>"); echo ("<td>"); echo ( "Sport: " .$row["sport"]); echo ("</td>"); echo ("<td>"); echo ( "first_name: " .$row["first_name"]); echo ("</td>"); echo ("<td>"); echo ( "last_name: " .$row["last_name"]); echo ("</td>"); echo ("</tr></table>"); } ?> </body> </html> this also works fine. All I need to do is tie the two together so that when a particular sport is selected, the query will display below in a table. I know I need to change my WHERE clause to a variable. This is what I need help with. thanks Error: Code: [Select] No error, Im trying to Make it Download But it wont Download... Code: Code: [Select] <table border="2" cellpadding="2" cellspacing="2" width="100%"> <tr> <td>ID</td><td>NAME</td><td>TYPE</td><td>SIZE</td><td>DATE ADDED</td><td>DOWNLOAD</td> </tr> <?php //porperties $result = mysql_query("SELECT * FROM uploaded"); while($r=mysql_fetch_array($result)) { $link=$r["link"]; $name=$r["name"]; $type=$r["type"]; $size=$r["size"]; $date=$r["date"]; $id=$r["id"]; echo " <tr> <td>$id</td><td>$name</td><td>$type</td><td>$size</td><td>$date</td><td><a href='$link'>Download $name</a></td> </tr> "; } ?> </table> Hello, I have a php page from where anyone can download mp3 songs. my database table contain song title and the directory link of every song. the page retrieve song title with the link that people can click and download. but if u click the mp3 started to play on new window. if u right click and save as then it download. but I want that people click and it will start download or give a prompt to save the file in pc. I hv the following code please help me... thankx Code: [Select] <?PHP $artist=$_GET['artist']; $album=$_GET['album']; $query=("select *from Band where artist='$artist' and album='$album'"); $result=mysql_query($query); while ($row=mysql_fetch_array($result)) { ?> <a href="<?php echo $row["link"];?>"><strong><?php echo $row["title"];?></strong></a> <?PHP } ?> How can I make that if I click on the title then it will start download. pls need help. Hello I'm trying to make a php script that when run updates an image folder based on a photobucket feed. Here is my code so far. Code: [Select] <?php function download_feed($path) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $path); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 15); $retValue = curl_exec($ch); curl_close($ch); return $retValue; } $sXML = download_feed('http://feed242.photobucket.com/albums/ff185/xivanari/account.rss'); $oXML = new SimpleXMLElement($sXML); foreach($oXML-> channel->item as $oDocuments) { $fileName = $oDocuments->title; $fileTmpLoc = $oDocuments->link; if(!file_exists("album1/".$fileName."/")) { if(!mkdir("album1/".$fileName)) $upload_location = "album1/".$fileName; $moveResult = move_uploaded_file($fileTmpLoc, $upload_location); } } ?> Hi, I'm wondering if anyone knows of any good information regarding downloading files. I'm looking into creating a relatively simple download system, where people will be sent a link say (download.php?id=dnjwaAYFDAg734) (where id would be an encrypted value, and obviously a lot longer!). That script would then decode the id number and allow the user to download the appropriate file. Any help would be hugely grateful as I'm a little unsure of where to go and a quick look through google doesn't show too much up. Thanks Edd Alrighty, I have posted about this before, but for a very different question. So different, i figured it merited a different post. anyways... I have a php script that downloads a webpages html code, then shows that code as its own on another server. I got it to work great, but it does not download/show the images and css. Using <base href> works great for the links, but the images are an issue, along with the css. Here's what I have got so far: (any scripts or other stuff is greatly appreciated) <?php //download the webpage $contents = file_get_contents($url); //we have downloaded the html from the page, //but not the external files such as css, and images //so now we add the images and css //start by splitting it into an easy to manage array $contentchunks = explode("/n", $contents); //mess with the html we downloaded foreach($contentchunks as $varname => $varval){ //varval is the single line of html //go through every line of the html code and replace it to my heart's content if(stristr($varval, 'src=') === TRUE) { //check to see if has what im looking for //get the url to download //download and insert the image } } //put the modified array back together $contents = implode("/n", $contentchunks); //view the webpage echo $contents; ?> I have a demonstration of what it does over at http://dageek247.tk/viewit/ Hi, I want that user can only read my article but can't download it. neither with save page as or with view source, even not with selecting text. and copy and paste. is there any solution in php to do that. Please help Thanks Hello There , I want to download a file from the server to the computer . How can i do this ?? i found out this code: header("Content-type: image/jpg"); header("Content-Disposition: attachment; filename=test.jpg"); the problem is , what i get is the file that the code was executed from saved in the .jpg format. how can i direct to a specified path to select a certain file then download it . example let's say i have a folder that contains 2 files: download.php and image.jpg how can i download the image.jpg from the server with the Save As window?? Thank You Hello, I'm trying to use php to have a user upload a file and then, have my site create a link --- I'm ALMOST there. My last hitch is in creating the link. From the code below, Code: [Select] echo "this is the current filename: ". $supplemental_file; echo '<a href=../../supplemental_files/' . $supplemental_file . '">Supplementary Download</a>'; I get: this is the current filename: Complaint.doc But, when I hover over the link, I get: http://localhost:8888/algebra_book/supplemental_files/Complaint.doc%22 Any thoughts on the extra %22 ?? Thanks so much.... I wonder if some kind-hearted person can help me? I am trying to download a video file which has a wmv. The protocol is either mms:// or http:// I can see the video in my browser but I cannot download it using curl or wget in a program and I need to download a few of these. They are publicly viewable so they are not private stuff. The URL is http://210.150.12.140/vod11/tepco/other/1111_01.wmv?MSWMExt=.asf or mms://wmt.stream.co.jp/vod11/tepco/other/1111_01.wmv All I get at the moment is a text file of less than 1K and not the movie itself. How would I download this file please? Thanks Paul |