I created a database through an online site and would like to connect to it from my android Activity. I believe that the core issue is my PHP file. I keep getting a syntax error from this line of code:
$con = mysqli_connect('h31.170.234.43', “markf”, “boston”, “a9208078_mydb”);
The name of my file is Register.php and the error is:
Parse error: syntax error, unexpected T_VARIABLE in /home/a9208078/public_html/Register.php on line 2
First, I'm curious if my parameters are correct, Host Name, the username that I used for that site, my password, and the database name?
Does anyone know why this error is occuring? Thanks so much!
PS: I changed the information around from my actual password and database name for obvious security reasons but the idea is the same
You're using funky quotes around three parameter values. That's what happens when you copy and paste your code from a blog post or tutorial.
$con = mysqli_connect('h31.170.234.43', 'markf', 'boston', 'a9208078_mydb');
FYI, your IP address is invalid and probably also a copy and paste error or typo.
Related
For some reasons I am getting parse error on the last line of the file even it is blank. I've used connect.php file as a connection file for putting the comment into the database. I'm using wampserver as a local server & coded all by myself
It must be some thing did not closed properly , like { or some line ending left post your php file for give proper solution
I am fairly new to the PHP scene, and I am trying to solve a bug in a friend's website. However, I have encountered a basic problem when testing it on localhost.
Essentially, the website is old and uses deprecated mysql command. Although mysql queries are spread out through the entire code, I only need to modify a couple of files where the bug is located.
However, in the config.inc file which is used in all php files, the following lines are included :
define("ML",mysql_connect("localhost:/tmp/aaaaa.sock","dbocccccccc","pass"),true);
define ("DB",mysql_select_db("dbcccccccc"));
I am getting a fatal error ad PDOException when converting this to PDO :
define("ML", new PDO('mysql:host=localhost/tmp/aaaaa.sock;dbname = dbcccccccc', 'dbocccccccc','pass'), true);
I'm guessing my syntax is incorrect in some way or another, yet when I try a simple direct connect to the database (same as above, but without the define), I get the following error :
Error : SQLSTATE[HY000] [1045] Acces denied for user 'dbocccccccc'#'#localhost' (password: YES)
The double # is what bugs me here. The input is the same (changed password and database name for privacy, but that's all) as the one found in the website sources.
So, what is the issue ? What have I got wrong here ?
You could try specifying unix_socket=/tmp/aaaa.sock instead of host=.
The PDO documentation describes the options in more detail.
Per the Php ManPage...
new PDO('mysql:host=xxx;port=xxx;dbname=xxx', 'user', 'xxx', array( PDO::ATTR_PERSISTENT => false));
I have a website which works fine on host, but I'm currently trying to install it on localhost.
I've downloaded everything and configured to work on localhost - Database & URL.
The problem is this error:
Unhandled Exception
Message:
syntax error, unexpected end of file Location:
C:\Program Files (x86)\EasyPHP-12.1\www\laravel\view.php(386) :
eval()'d code on line 118
And I don't know what causes it. Any solutions?
P.S. I've setup in my windows' host file 127.0.0.1 myproject.dev.
There is an error within one of your views. If there is a more detailed stack trace it should show you details of a view, although the name will be an md5() string so it's a bit hard to find. You might want to delete all compiled Blade views in storage/views and let Blade re-compile the views.
If you still get the error then check your views to make sure you have all the proper closing tags, e.g., #endif or #endforeach
Always double check your views for any syntax errors.
I've run into this same error and I was able to fix it by adding spaces to the content within an inline if statement. For example:
Experienced error with:
#if( BLAH )Output#endif
Fixed error with:
#if( BLAH ) Output #endif
This may not be a problem in all cases and it was certainly difficult to track down but it is just one example that can cause this exact error.
A variation of this problem -- I had a php block, which I'd opened with
<? as opposed to <?php worked fine on LocalHost/MAMP, but gave the above error under Nginx/Ubuntu 16.04/PHP7 (both Laravel)
you should remove a character from view file. for example my character was "," (a comma) before some "#endfor". when i remove those worked!
I am having problems with creating a PHP form for a web site that popluates a MySQL database.
Here is the error message I am getting at the following URL: http://www.laboro.biz/employer.php:
Parse error: syntax error, unexpected $end in /hermes/bosoraweb013/b1108/ywh.tsarge83/laboro/employer-FormToEmail.php on line 228
The other file that is the action file is http://www.laboro.biz/employer-FormToEmail.php.
I need help with scripting to make this work.
Can anyone please help?
You're missing a curly brace somewhere in your script.
You're missing a { or have one more } or ; than needed. Look it over.
I am working with MySQL in conjunction with ExpressionEngine 2.2.1. This version of ExpressionEngine automatically comes with a Query Module, which I am using to filter and display entry results from a module called Freeform. I am using Freeform version 3.1.1. All of these elements are working well together and displaying the desired results on my local setup. However when I push my code to production, I am receiving this error:
Fatal error: Call to a member function num_rows() on a non-object in /var/www/vhosts/xxxxxxxxx.com/systemxxx/expressionengine/modules/query/mod.query.php on line 183
Here is this section of the code beginning on line 183 of mod.query.php (I did not code this php, nor have I ever coded php, this was already included with the site that I am working on.):
183 if ($query->num_rows() == 0)
184 {
185 return $this->return_data = $this->EE->TMPL->no_results();
186 }
Here is how I am using the Query Module in my HTML Template:
{exp:query sql="SELECT first_name, last_name, email, city FROM exp_freeform_entries WHERE city = 'New York'"}
<tr>
<td>{first_name}</td>
<td>{last_name}</td>
<td>{email}</td>
<td>{city}</td>
</tr>
{/exp:query}
Does anyone know why this error is occurring? Why would it be occurring on production but not locally?
Any help would be greatly appreciated!
Check to make sure the database in Production has the same structure as your Local environment.
Perform the following steps from phpMyAdmin or your favorite MySQL GUI client:
Select your ExpressionEngine database
Execute the following SQL Statements:
DESCRIBE exp_freeform_fields;
SELECT name FROM exp_freeform_fields;
Compare the results from your Local MySQL Database to your Production MySQL Database.
You probably got different database content on production and local systems so the statement fails on the production system producing an error.
You should try executing the statement in phpmyadmin or something like that to see if your sql statement is error-free and doesn't have any conflicts with naming.
Seems that your $query object has no valid connection. Control your username, password and database configuration.
Enable debugging in your config.php and database.php to see detailed error messages:
/system/expressionengine/config/config.php
$config['debug'] = '1';
/system/expressionengine/config/database.php
$db['expressionengine']['db_debug'] = TRUE;
It also wouldn't hurt to:
Verify your MySQL database credentials
Check Apache's and/or PHP's error_log
Hopefully, these steps will allow you to get more insight into your problem.