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
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
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.
Improve this question
as we all know,there is a data type 'resouce' in php!I sometimes can encounter this data type!but I have some problems about this type!
when I have a db connect,I print the data type,it displays"resource(4, mysql link)",
when I create a image,I print the data type,it displays "resource(2, gd)"
i want to know what the number eg.'4','2' means in the "()".
sorry for my bad englis!
When you see resource(4, ...) what that means is that PHP is keeping a reference to a more complex object that isn't a normal PHP object, and thus can't be manipulated directly. It's typically used by libraries that interface with non-PHP code (such as database client libraries and the GD library).
The number is simply the ID number of that particular external object.
These resources are managed by the external library and only really given to PHP as an indirect reference; they only have meaning to the library code that created them.
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
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.
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.
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 am trying to separate my code into functions to make it more readable.
I made a function to update a field in a database. What I am trying to do is that when they change the username it goes to update Account function then updates the session variable , the smarty var,and the database regarding the name.
Everything gets updated after the form is submitted but the smarty variable and I can't figure out why(i know its something to do with the scope) because if i declare it out of the function it works fine.
All the magic that i need fixed is in the Home portion of the routing section of my code. Thank you for any help :)
code :http://pastebin.com/VdRPz3hc