Tag Archives: mysql

Insert user value into messages table where user division = division.divisionid

Can anyone shed any light on how I insert a table entry in my messages table for each user.ID where the users.MM_Division = division.divisionid
I want to include the user ID value in the messages.messagesuserid
I think I need a… Continue reading

Tagged , , , | Leave a comment

PHP MySQL session_set_save_handler race condition

I have written a simple session_set_save_handler using a MySQL innoDB table as the storage backend. MySQL is 5.5.
Code looks like so (very simplified, but hopefully illustrates the flow of code), I am using RedBean ORM for interacting with the… Continue reading

Tagged , , , , | Leave a comment

php get mysql result not as array, but as text

I want to get text result like:

+----+-------+----------------------------------+----+
| id | login | pwd                              | su |
+----+-------+----------------------------------+----+
|  1 | root  | c4ca4238a0b923820dcc509a6f75849b |  1 |
+----+-------+----------------------------------+----+
1 row in set (0.00 sec)

in PHP (string).
Example in php: Continue reading

Tagged , , | Leave a comment

BCrypt Salts, PHP and MySql

When my bcrypt hash is stored into the database it contains the salt and the hash together.
From my understanding is that the the salt contains $2a$ to define bcrypt and two digits as the work amount. (Ie 10) It… Continue reading

Tagged , , , | Leave a comment

Populate a table with Foreign keys in it

I have a schema like this

CREATE TABLE TrainManager(
    train_name    VARCHAR(5) REFERENCES Train(name),
    station_id      INT REFERENCES Station(station_id)
);

The two reference tables have an indirect relations.
control (ctrl_id, train_name);
controlremote (ctrl_id, station_id);
As you can, in order to get train … Continue reading

Tagged , | Leave a comment

MySQL Join query in PHP

I have got the following code that does the correct function for the Project_Title, However i need to get the Student_Surname and Student_Forename that is connected to this Project_Title. The code will only show the name of the logged user… Continue reading

Tagged , , , | Leave a comment

Chinese characters in form submission

Client page:

<head>
<meta http-equiv="Catchup Scheduler" content="text/html; charset=UTF-8">
</head>

<body>
<form action="next.php" method="POST" >
<input type="text" name="programme_name"></br>
<input type="submit">
</form>
</body>

Server page:

$name = $_POST['programme_name'];

mysql_query("SET character_set_client=utf8",$con);
mysql_query("SET character_set_connection=utf8", $con);
mysql_query("SET character_set_results=utf8", $con);

$query = "Select * from programme 

Continue reading

Tagged , , , , | Leave a comment

Effective wayto sum values in MySQL table rows

I have a MySQL table that looks something like this:

+--------------------------------------+
|   id   |    product_id   |   qty     |
+--------------------------------------+
|    1   |        0        |    1      |
|    2   |        1        |    3      |
|    3   |        0        |    2      |

Continue reading

Tagged , | 1 Comment

Fetch data from MYSQL and display in JSON file

I’m building and iOS application which fetches data from my MYSQL database,so to do such thing i need to use JSON(i know other methods,but i need specifically to use JSON).The problem is, how can i fetch data from my mysql… Continue reading

Tagged , , , | Leave a comment

Result is empty after while loop

Why is this not possible? Is there some way I can make the resolut not to be empty?

$sqlAllInfo = "SELECT item1, item2 FROM example";
$resAllInfo = mysql_query($sqlAllInfo);

while($rowAllInfo = mysql_fetch_assoc($resAllInfo)){

    echo $rowAllInfo['item1'];

}

$rowAllInfo = mysql_fetch_assoc($resAllInfo);

echo $rowAllinfo['item2'];

Thanks Continue reading

Tagged , | Leave a comment
287 pages