PHP - Error Code When I Run Localhost
Hi, I still a noob in PHP programming I hope somebody in the forum can help me and give an ideas how to fixed to this problem, everytime I run localhost this message appear: ErrorException in Builder.php line 1023:count(): Parameter must be an array or an object that implements CountableBut if I type localhost/(anycharacter) the page appear but with error 404(kindly refer to image, all other buttons are working except the one indicated with the arrow( kindly refer on the last image, note: app_debug set to true), this problem keeps bugging me for a few weeks now that I still cannot find a way to fixed it. Thank you in advance. )
Similar TutorialsHi everyone! I am building an application in PHP with MySQL on my localhost. I tried to connect to the database like this: mysql_connect("localhost", "root", "password"); mysql_select_db("app-db"); but the message I get is: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'user'@'localhost' (using password: NO) in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\app\Source\includes\db_connect.php on line 3 Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\app\Source\includes\db_connect.php on line 4 Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\app\Source\includes\db_connect.php on line 4 I never wrote user 'user' in the whole application but root and even when I comment out that line of mysql_connect, the first error doesn't go away. The url of the index of the application is localhost/app/Source/index.php When I make a page: localhost/index2.php with the same content as my db_connec file then there is no error. When I move or copy the db_connect file to localhost/db_connect.php it also gives me those warnings. Also, when I change things in the code, PHP does not recognize them and nothing changes - meaning, that I can comment out those connect statements and still get the warnings. Can anyone offer me some advice and help me solve this, please? Thanks in advance! MiRed I've made my own customized admin panel to edit tables. The script worked fine on my localserver(wamp) but is showing this error when i try to update or insert a record ...select and delete is working fine.. Have used same function for update, delete, and insert If anything is unclear please ask me.. ??? I'm looking to connect to a MySQL localhost on my mac. I've been working for a few hours at this and I still can't figure it out. Below is my code. I've tried a number of different ways to connect to the database including using new mysqli, mysql_connect and PEAR MDB2. Any suggestions as to what I can do? Thanks in advance. <?php $first=$_POST['first']; $last=$_POST['last']; if (!$first || !$last) { echo 'Error: Enter the required data.'; exit; } if (!get_magic_quotes_gpc()) { $first = addslashes($first); $last = addslashes($last); } $hostname = 'localhost:8889'; $username = 'root'; $password = 'root'; $dbname = 'phonebook'; @ $db = new mysqli($hostname,$username.$password,$dbname); if (mysqli_connect_errno()) { echo 'Errer: Could not connect to database'; exit; } echo '.....Connected Successfuly'; $query = "insert into contact values ('null','".$first."','".$last."')"; $result = $db->query($query); if ($result) { echo $db->affected_rows." contact inserted into the database"; echo 'Contact Entered: '.$first.' '.$last.''; } else { echo 'Error: Contact not added.'; exit; } $db->close(); ?> Hi, my school say not to use XAMPP, and I already have PHP installed, MySQL installed, Apache I am not sure, but assuming if I have it installed, how do I connect to localhost b/c beforer when I use XAMPP, the default for where to get php/mysql running was: C:\xampp\htdocs\ Please any help appreciated! does anyone know of a simple tutorial which will show me how to receive email sent via my localhost? i cant develop my script fully because of the email errors. thanks Hi, would like to know if there is any way to send email using localhost? is it possible and how can i do it? this problem really drives me crazy..hope that anyone could help. I left my page only with <?php session_start(); ?> with no script at all..and i still got error Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at E:\Program Files\XAMPP 1.5.4\xampp\htdocs\folder\page1.php:1) in E:\Program Files\XAMPP 1.5.4\xampp\htdocs\folder\page1.php on line 2 No white space at all. I tried to upload this file into the server (not local) and no error appeared. but when i run it in my local server, error appeared. I restart my xampp so many times but still didn't fix this. what's the problem then? thanks in advance This topic has been moved to Other. http://www.phpfreaks.com/forums/index.php?topic=327407.0 I've installed Drupal 7.1 on my computer and I'm trying to access it via localhost. However, the site does not load the "index.php" file. Instead, I get the list of files and folders in the working directory with the heading "Index of /drupal71" (drupal71 is the temporary site name). The .htaccess file has the following lines, so I'm confused as to why index.php doesn't load automatically. Code: [Select] # Set the default handler. DirectoryIndex index.php index.html index.htm Any suggestions? Hello, I am trying to create a registration module where an email would be sent to the user after registration. I am using xampp and have tried php mailer http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php4/0.90/ but couldn't get it to work... I've been told that it is possible to send an email from localhost through smtp... I need to know how to accomplish that. Am a beginner. suggestions and help would be appreciated I seem to be seeing a problem I havent noticed before when I use header for a redirect the session data passes to the new page when I use href it seems as though even when I do a session_start() on the new page the session data doesnt pass Is this normal or is there a setup issue on my server (bluehost) everything works fine on wamp but when i upload to implement it no good I am using this to generate PDF reports using fpdf, I want it to open a new page instead of just redirecting Is it that it is unable to pass the data to a new page on a server?? I have a Login Script with a Remember me Function. The Script works flawlessly on my local server but when I upload it doesn't work on my web server. From what I can tell its a Session issue, When I log in, I make a session with the user ID, in which is used to pull all there information on other pages. On my local host it makes the sessions and everything is dandy, but on the web server it doesn't seem to make the session. Can anyone shed any light on this, I'm clueless once again ^_^ Hi, folks -- I've been working on this for quite awhile, and have done lots of searching, but I still cannot make it work. Using Xampp on Win 7 x64, with PHP 5.3. Here is my simple PHP code just trying to get something to work: $to = 'my_real_email@gmail.com'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: someone@localhost.com' ; mail($to, $subject, $message, $headers); ?> (NOTE: "my_real_email" is set to my actual email address.) Here are my php.ini settings: Code: [Select] [mail function] ; For Win32 only. ; http://php.net/smtp SMTP = localhost ; http://php.net/smtp-port smtp_port = 25 ; For Win32 only. ; http://php.net/sendmail-from ; sendmail_from = postmaster@localhost ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ; http://php.net/sendmail-path sendmail_path = "\"E:\xampplite\sendmail\sendmail.exe\" -t" ; Force the addition of the specified parameters to be passed as extra parameters ; to the sendmail binary. These parameters will always replace the value of ; the 5th parameter to mail(), even in safe mode. ; mail.force_extra_parameters = ; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename mail.add_x_header = Off ; Log all mail() calls including the full path of the script, line #, to address and headers mail.log = "E:\xampplite\apache\logs\php_mail.log" I'm not getting an error and the email seems to be getting "logged", but I do not receive an actual email in my account. Thanks for any suggestions. Hi all I am running XAMPP on my laptop and working with files not in the localhost directory. For functions like fopen, there is no problem, I specify a path starting from the localhost directory to wherever I want to work and that's fine. For some reason though, it is NOT working with IMG SRC. I get my PHP to generate the following line of code : <IMG SRC = "http://localhost/../../../wherever/android.jpg"> (which in this case points to C:\wherever\android.jpg) However the browser misses the middle bit of the URL out and interprets it just as localhost/wherever/android.jpg - which clearly doesn't exist ! Likewise, if I try typing the address straight into the address bar, the '../../../' bit of it immediately vanishes. I've tried formatting the URL in a variety of ways, none of them seem to work, where am I going wrong ? Many thanks ! Hi Guys I don't why it happen. probably i missed out something. Here is my code. Code: [Select] <?php if($_REQUEST["xtvt"]=="addEdit") { $sql02="INSERT INTO attachment (remarks, attached_by, attached_date) VALUES('".$_REQUEST["remarks"]."', '".$_SESSION["SESSION_ID"]."', now())"; $res02=mysql_query($sql02); //--------- attach file ---------------------------- $name = $_FILES["file"]["name"]; if ($name != "") { $selectDB="SELECT max(id) AS id FROM attachment"; $qryDB= @$res1=mysql_query($selectDB); $fetchDB=mysql_fetch_array($qryDB); $maxid=$fetchDB[0]; $result=move_uploaded_file($_FILES["file"]["tmp_name"], "upload//" . $_FILES["file"]["name"]); if (!$result) { echo "Error uploading file"; } $update_faultLog = "UPDATE attachment SET attachment='$name' WHERE id='$maxid'"; $res1=mysql_query($update_faultLog); } } ?> <table width="625" border="0"> <tr> <td width="78">Select File <span class="style1">*</span></td> <td width="5">:</td> <td width="539"><input type="file" name="file" id="file"/></td> </tr> <tr> <td>Remarks <span class="style1">*</span></td> <td>:</td> <td><pre><textarea name="remarks" id="remarks" cols="45" rows="3"></textarea></pre></td> </tr> <tr> <td> </td> <td> </td> <td><input type="reset" id="bttnReset" name="bttnReset" value="Reset" onclick="Reset()"/> <input type="button" id="bttnAdd" name="bttnAdd" value="Add" onclick="addEdit()"/></td> </tr> </table> Its work at localhost but not when i put at server... please help me... Thank You I have pretty much the same problem.
I am just starting without any previous experience with xampp, php or MySQL, I have been coding in C for a few years and have used Java before.
Just wanted to play with a local website design using a Joomla template as my method for learning php etc.
I installed XAMPP 1.8.3 and then a Joomla template into htdocs.
Xampp runs fine and I have localhost and other pages without issue.
localhost/myphpadmin is blank.
I have not yet created a DB as I cannot access myphpadmin and have no code yet either.
The error reporting is set as you suggest but no errors are reported.
For error_reporting I used a - 1, phpinfo shows it as 22527 while display_error is On
The source for the phpmyadmin is blank but using FF dev tools the error console shows:
Error: The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol. Source File: http://localhost/phpmyadmin/ Also tried with Opera and IE I have installed Xampp on a USB drive labelled as V: as my SS C: drive has limited space. I installed the Java SDK as well (Version 8 update 20 build 1.8.0_20-b26 php is reported as 5.5.15 in xampp. This all happened straight from install, so no editing of files by me. All I have edited since is the error entries in php.ini hello. i want to create an oop website on my localhost but im having trouble getting the initialize file to find my config file. if i point my browser to my local host my index page works fine because it does not need the initialize file at this stage, but if i point my browser to my admin index (http://localhost/djsonrotation/admin/) i get this error Quote Warning: require_once() [function.require-once]: URL file-access is disabled in the server configuration in /Applications/MAMP/htdocs/djsonrotation/includes/initialize.php on line 9 Warning: require_once(http://localhost/djsonrotation/config.php) [function.require-once]: failed to open stream: no suitable wrapper could be found in /Applications/MAMP/htdocs/djsonrotation/includes/initialize.php on line 9 Fatal error: require_once() [function.require]: Failed opening required 'http://localhost/djsonrotation/config.php' (include_path='.:/Applications/MAMP/htdocs/php5/lib/php') in /Applications/MAMP/htdocs/djsonrotation/includes/initialize.php on line 9 the initialize file is basically 1 place that points to lots of different places and mine looks like this: Code: [Select] <?PHP defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR); defined('SITE_DOMAIN') ? null : define('SITE_DOMAIN', 'http://localhost/djsonrotation'); defined('SITE_ROOT') ? null : define('SITE_ROOT', $_SERVER['DOCUMENT_ROOT']); defined('LIB_PATH') ? null : define('LIB_PATH', SITE_DOMAIN.DS.'includes'); defined('CSS_PATH') ? null : define('CSS_PATH', SITE_DOMAIN.DS.'css'); require_once(SITE_DOMAIN.DS.'config.php'); require_once(SITE_DOMAIN.DS."functions.php"); require_once(SITE_DOMAIN.DS."session.php"); require_once(SITE_DOMAIN.DS."database.php"); require_once(SITE_DOMAIN.DS."user.php"); ?> this is the config file its looking for: Code: [Select] <?PHP defined('DB_SERVER') ? null : define("DB_SERVER", "localhost"); defined('DB_USER') ? null : define("DB_USER", "admin"); defined('DB_PASS') ? null : define("DB_PASS", "*************"); defined('DB_NAME') ? null : define("DB_NAME", "djsonrotation"); ?> this is how my mamp is set up Quote PORTS - 80 - 3306 PHP - 5 APACHE - /Applications/MAMP/htdocs this is where my file are located on my wwwroot /index.php /includes/initialize.php /includes/config.php /admin/index.php this is the line of code calling the initialize on /admin/index.php Code: [Select] require_once("../includes/initialize.php"); thanks rick Hi, I am trying to send mail from my localhost but i am getting the below error ""Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in F:\test\xampp\htdocs\sendmail.php on line 42'" I am using xampp server. Can anyone please tell me what is the error My "php.ini" code is [mail function] ; For Win32 only. ; http://php.net/smtp SMTP = smtp.gmail.com ; http://php.net/smtp-port smtp_port = 587 ; For Win32 only. ; http://php.net/sendmail-from ;sendmail_from = xxxxxxxx@gmail.com ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ; http://php.net/sendmail-path ;sendmail_path = "\"F:\test\xampp\sendmail\sendmail.exe\" -t" ; Force the addition of the specified parameters to be passed as extra parameters ; to the sendmail binary. These parameters will always replace the value of ; the 5th parameter to mail(), even in safe mode. ;mail.force_extra_parameters = ; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename mail.add_x_header = Off ; Log all mail() calls including the full path of the script, line #, to address and headers ;mail.log = "F:\test\xampp\apache\logs\php_mail.log" $download will print on the screen on my localhost, but once I've uploaded it to my host and go to the website, everything else prints to the screen fine, but $download will not. When I view page source, shows nothing where $download should be. $link_pattern = "/<tr><td><a(.*)<\/tr>/sU"; preg_match_all($link_pattern,$cr,$dm); $downloads = $dm[0][0]; $pattern = '/src=\"/'; $replacement = 'src="http://www.triplestarent.com/images'; $download = preg_replace($pattern, $replacement, $downloads); ?> <div class ="container"> <br> <h1> <?php echo $title; ?> </h1> <br> <?php echo $image; ?> <br><br> <h2> Track List </h2> <?php echo $tracks; ?> <br><br> <h2> Download </h2> <br> <table> <?php echo $download; ?> </table> <br><br> </div> I have create a working site at localhost but when I upload it to webhost, it's not working, all link broken.
This is the site.
this is the directory :
The index.php content is :
<?php header('location:home.html'); ?>and the .htaccess content is : RewriteEngine on RewriteRule ^home.html$ main/home.php?main=home [L] RewriteRule ^penyakit.html$ main/home.php?main=penyakit [L] RewriteRule ^review-(.*)\.html$ main/home.php?main=detilgejala&id=$1 [L] RewriteRule ^solusi.html$ main/home.php?main=solusi [L] RewriteRule ^proses$ main/home.php?main=prosessolusi [L] RewriteRule ^bukutamu.html$ main/home.php?main=bukutamu [L] RewriteRule ^send-contact$ main/main_bukutamu/proses_bukutamu.php [L] RewriteRule ^about.html$ main/home.php?main=about [L] RewriteRule ^ensiklopedia.html$ main/home.php?main=ensiklopedia [L] Options All -indexesThis config work in localhost. Thanks for your attention and respond, it help me so much and sorry for the topic's title can't edited it. Edited by havide, 31 October 2014 - 12:35 PM. |