Mysql Error: Table does not exist [closed] - mysql

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
When I try to login a user account on my Page, I get the following error:
Table 'mysql.users' doesn't exist
I have checked that I have only one 'mysql' table and that is named User not Users.
Someone please guide me how to get rid of this error. Can I change the Table name to "User"?
Right now I have the following code:
query("SELECT * FROM `users` WHERE `username`='" . $mysqli-
real_escape_string($useroremail) . "' and `password`='" . md5($password) . "'
and `userlevel`='".($vendor==true ? 30 : 20)."'LIMIT 1;") or die($mysqli->error);

Can i change the Table name to "User"?
Yes you can.
Try this.
RENAME TABLE `oldTableName` TO `newTableName`
RENAME TABLE 'Users' TO `User`
Hope this helps.

Related

how to remove spaces from a field in mySQL db? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I have a database where i store my photos title, tags, and their path on sever some of the records have names like:
photo 1234.png. I need to make them like photo1234.png
Why can't I use a query like
UPDATE tblPhoto a
set a.photoLink = replace(a.photoLink , ' ', '')
where a.photoLink like '% %';
And which is the best way to rename them in Linux Server, can I use php ?
You don't need where clause
UPDATE tblPhoto SET photoLink = REPLACE(photoLink , ' ', '');
For replacing the file name on your Linux Server you can try to look in this answer.
https://stackoverflow.com/a/2709619/7921383
Use php method for example:
$old_name="Hello World";
echo str_replace(" ","",$old_name);
//output Helloworld

Error While Deleting row from multiple dependent tables [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
ERROR: syntax error at or near "r"
Query was:
Delete r,ur from un_received_compansation_reason ur join received_compensation_info r on received_compensation_info.compensation_info_id = un_received_compansation_reason.compensation_info_id where compensation_info_id=2
You have specific table aliases, so try writing the query as:
Delete r, ur
from un_received_compansation_reason ur join
received_compensation_info r
on r.compensation_info_id = ur.compensation_info_id
where r.compensation_info_id = 2;
You need to use table aliases in time joining key like below
Delete r,ur from un_received_compansation_reason ur join
received_compensation_info r on
r.compensation_info_id = ur.compensation_info_id
where ur.compensation_info_id=2

Random Number in MySQL column [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I am trying to add random number in one of my database column called likes which have about 5000 row in it. currently I have tried like below to get random number from 10 to 50.
$randomnumberlike = (rand(10,50));
but this is setting same number in all row...instead I want different number in row...anyone can please suggest how can I do it ?
Thanks
Try: UPDATE Table SET fieldName = ((rand() * 1000) % 40) + 10;
Because when you preset it in a variable, it'll be the same for all...
You're setting a variable:
$randomnumberlike = (rand(10,50));
If you're then using $randomnumberlike to add to the db then it will always be the same, its already be assigned (unless within a loop), you need to use (rand(10,50)) (or working similar) directly in the query like this:
UPDATE <table_name> SET <field_name> = ROUND((RAND() * (50-10))+10) WHERE ...;

How can I write the following query in CodeIgniter? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I am working on an app in CodeIgniter, but I am not able to write the following query using active records,
select price, count(*) from fake_apps where downloads > 20000 group by price;
How can I write this query using CodeIgniter's active records?
Thank You.
$this->db->select("price,count(*)",FALSE);
$this->db->from("fake_apps");
$this->db->where("downdoad>","20000");
$this->db->group_by("price);
$res = $this->db->get();
It would be like this:
$this->db->select("price, count(*)",FALSE);
$this->db->where("downdoad > ","20000");
$this->db->group_by("price");
$sql = $this->db->get("fake_apps");
echo '<pre>';
print_r($this->db->last_query());
echo '</pre>';
For FALSE in Codeigniter select:
$this->db->select("price, count(*)",FALSE);
Note:
If you set it to FALSE, CodeIgniter will not try to protect your field
or table names with backticks. This is useful if you need a compound
select statement.
Reference:
https://ellislab.com/codeigniter/user-guide/database/active_record.html

Date is showed with unexpected value in html [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I used Bootstrap datepicker to get date from the user. I stored that value in database.
But when i render this date in html, it showed unexpected value with the date !
I give the screen shot of the result.
Can anyone help me to solve this ?
How have you stored the date in the database?
Make sure you used DATETIME and not VARCHAR
Also how did you get the date from the database?
I would use:
$query = "SELECT DATE_FORMAT(ColumnName, '%Y-%m-%d %H:%i:%s') AS Date FROM Table";
$result = mysqli_query($cxn,$query) or die(mysqli_error());
$date = $result->fetch_object()->Date;