mysql_real_escape_string is not working in one server [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
<?php echo mysql_real_escape_string('tientrer') ;?>
The above code is return an empty string in one server but is working fine in other servers. Why is it so?

Wildly random guess:
You are not connecting to a database using mysql_connect. mysql_real_escape_string needs a database connection to do its job (because you are escaping for the database; you are escaping this for a database query, right?!). If no connection exists yet, it'll try to establish one automatically using a standard username and password. On one server this standard password works, on another it doesn't.

you are escaping a string ?
you mean maybe like that
<?php echo mysql_real_escape_string($tientrer) ;?>
to escape the variable tientrer if its a variable.
EDIT:
then maybe the server which not working maybe the mysql is deprecated there , try change to mysqli or pdo

Related

Add database username and password along with server usrnm and pwd [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have this code that inserts user data into a database.
mysql_connect("server address","username","password");
mysql_select_db("login");
mysql_query("INSERT INTO login(name,username,password,email)VALUES('$_POST[fname]','$_POST[username]','$_POST[pw]','$_POST[email]')") or die("cannot execute the query");
I have an issue here. There is a username and password to enter into my server and there is also another username and password to use my database.
Where should I mention both username's and password's?
The mysql_connect() has absolutely nothing to do with server logins, and only has to do with MySQL login.
That being said, you have a number of issues:
You are using deprecated mysql_* functions. You should use mysqli extension of PDO instead.
You are horribly vulnerable to SQL injection attackes. NEVER, EVER, EVER use directly input data from the user (like $POST, $_GET, etc.) without first sanitizing/validating it.
You really should get in the habit of checking the response for each function and handling errors appropriately. For example, you should never even get to mysql_query() line of code if you mysql_connect() and mysql_select_db() calls are not successful.

Mysql_num_rows not Valid - PHP [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I use the method or function mysql_num_rows() in my php code, it worked great and had no issues. I later just changed my web host. I created a new database that is identical to my old one. I changed all the information to access the database and am getting access to the new database but it is throwing an error once the code reaches mysql_num_rows. Why am I getting an error for mysql_num_rows? The results are suppose to be 0 when the function is ran because I have no information in my new database, but I also added information just so I didn't get a 0 and it is still giving my an error. Why?!!!!
Sounds like you've moved to a server with a newer version of PHP - mysql functions are deprecated, use mysqli (and convert the rest of your database functions to mysqli):
http://au1.php.net/manual/en/mysqli-result.num-rows.php

Writing query results to a text file [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am a new user of php.
I have one table in mysql database. I have a form which the users use to query the mysql database. I am testing my html form page on my linux laptop which has APACHE server.
I am able to make a connection to the mysql database and display results in the browser.
I am not sure how to capture the results from the variable which has query results which has several rows of data and be able to write the results to a text file in /var/www/
Thank you
I noticed every time you check if the POST variable is set you use something like
if(isset($POST["submit"])){
Was that a typo in this post or are you forgetting the underscore?
if(isset($_POST["submit"])){
Also try to use mysql_fetch_assoc instead of mysql_fetch_array.
And always prepare the variabes for usage in a query if you do not want to get hacked instantly.

MySQL pdo and legacy [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
Is there a way by which I can make the result set returned by PDO same as the data set returned by the legacy mysql functions?
Actually, all the files in my application call a function to execute any SQL query. Currently that function uses old mysql functions. I want to change it to PDO in that single function, effectively changing to PDO over the whole application.
Hence, I need a way so that the format of the result coming out is the same as the old mysql functions.
If you mean the result set resource returned by mysql_query, then: no. Resources are specific to the extension that defines them and are meaningless to anything else. PDO returns an object, mysql_query a resource; that's apples and oranges.
If you mean an array you'd build with mysql_fetch_assoc and PDOStatement::fetch, then: of course, you can make them look identical if you bother to do so.

Saprfc connection issue [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I 'm having issues configuring the saprfc_open to actually connect.
saprfc_open does not support the saprouter string (i.e. unlike java).
How do you actually make it connect if you need to use the saprouter string?
It should be the same as a direct connection, except you put the router string into the ASHOST parameter, instead of the just the system hostname/IP:
/H/<SAP router hostname or IP>/S/<SAP router port>/H/<SAP system hostname or IP>
For example:
/H/saprouter.mycomp.local/S/3299/H/sapsystem.mycomp.local
It seems saprouter is not supported by the extension, so I had to switch to the java connector for this part.

Categories