3
Contributors
18
Replies
70
Views
2 Years
Discussion Span
Last Post by SimonIoa
0

I press the </>code and >_Inline code tabs. Neither of them open the dialog box

0

I press the </>code and >_Inline code tabs. Neither of them open the dialog box

Only </> Code should open a dialog. What browser are you using? Any interfering plugins?

Apart from that you can paste your stuff, then select all text and press tab to indent as code.

0

I am using firefox. Neither working for me. Neither code or inline code. Yes only code used to open a dialog box and inline code used to get the code in brackets or something. That doesnt work for me. Nothing of the text processing working for me. B,I LINK and so on.. what did i do wrong?>

Edited by SimonIoa

0

html
<input type='hidden' value="selected_ids" name="selected_ids[]" multiple="yes" id="selected_ids" />

0

Alternative: paste your code into the editor, ensure a blank line between your last bit of text and the first line of the code block. Select all entire code block and press TAB.

So back to the question. Show your SQL, your table and structure. The code you posted is of little value as we don't even know if you're using the right enctype in your form tag. C'mon Simon - help us to help you.

0

the editor works on Chrome

i want it to store like this
INSERT INTO table (title,desc,url, img, uid_fk, created, to_uid_fk) VALUES ('something','something','something','something','12','something','100,102,204')

The php code

$update=mysqli_real_escape_string($_POST['update_press']);
    $press_image=$_POST['photopress'];
    $update_description=mysqli_real_escape_string($_POST['update_descr']);
    $press_url=mysqli_real_escape_string($_POST['pressUrl']);



    $values = array();

    foreach ($_POST['selected_ids'] as $i => $value) {
        $values[] = sprintf('(%d)', $value);
    }

    $values = implode(',', $values);





    $data=$Wall->Insert_Press_Release($uid,$update,$update_description,$press_url,$press_image,$values);

the ajax js code

$(".press_update_button").click(function()
{
    var updateval = $("#update_press").val();
    var pressUrl=$("#pressUrl").val();
    var update_descr=$("#update_descr").val();
    var uploadvalues=$("#photopress").val();
    var selected_ids=$("#selected_ids").val();


    var dataString = 'update_press='+updateval+'&photopress='+uploadvalues+'&update_descr='+update_descr+'&pressUrl='+pressUrl+'&selected_ids='+selected_ids;

        $("#flashPress").show();
        $("#flashPress").fadeIn(400).html('Loading Press Release...');
        $.ajax({
            type: "POST",
            url: $.base_url+"press_release_ajax.php",
            data: dataString,
            cache: false,
            success: function(html)
            {
                $("#flashPress").fadeOut('slow');
                $("#presscontent").prepend(html);
                $("#update_press").val('').focus().css("height", "40px");
                ('#update_descr').val('');
                $('#selected_ids').val('');
                $('#pressUrl').val('');
                $('#photoimg').val('');
            }
        });
return false;
});

the function that Inserts tha data

public function Insert_Press_Release($uid,$update,$update_description,$press_url,$press_image,$values)
    {
        $update=mysqli_real_escape_string($this->db,$update);
        $update_description=mysqli_real_escape_string($this->db,$update_description);
        $press_url=mysqli_real_escape_string($this->db,$press_url);
        $press_image=mysqli_real_escape_string($this->db,$press_image);
        $time=time();

        $query =  mysqli_query($this->db,"INSERT INTO `table` (title,desc,url, img, uid_fk, created, to_uid_fk) VALUES ('$update','$update_description','$press_url','$press_image','$uid','$time',$val)") or die(mysql_error());
        $result = mysqli_fetch_array($newquery,MYSQLI_ASSOC);

            return $result;
    }

Edited by SimonIoa: change

0
public function Insert_Press_Release($uid,$update,$update_description,$press_url,$press_image,$values)

You are passing $values, but are using $val:

('$update','$update_description','$press_url','$press_image','$uid','$time',$val)

This really does look like a lot of work with all that sanitizing. Why not create a prepared statement?

Is there any reason why you're placing multiple values into a single record field: '100,102,204'

This violates 1NF (1st normal form) for relational models. This makes searching for foreign ids very labour intensive - you should use a link table, just:

idTable1 | idTable2 (where both are FKs and make the composite PK for the link table)

So for instance, you'd have:

3 | 100
3 | 102
3 | 204
0

The values was a mistake but its not this. The '100,102,204' are finctional ids, the point is that i want to store multiple values in one row. Here is the code that i dont know if its right..

php

$val=array($s);
$val = implode(',', $s);

$data=$Wall->Insert_Press_Release($uid,$update,$update_description,$press_url,$press_image,$val);

or

$values = array();
foreach ($_POST['selected_ids'] as $i => $value) {
$values[] = sprintf('(%d)', $value);
}
$values = implode(',', $values);

and the js

var selected_ids=$("#selected_ids").val();

var dataString ='update_press='+updateval+'&photopress='+uploadvalues+'&update_descr='+update_descr+'&pressUrl='+pressUrl+'&selected_ids='+selected_ids;
$.ajax({
        type: "POST",
        url:$.base_url+"press_release_ajax.php",
        data: dataString,

the html

<input type="text" name="friends" id="inputbox">
                <input type='hidden' value="selected_ids" name="selected_ids[]" multiple="yes" id="selected_ids" />

i know that the js and html are fine. I am not sure about the php.
You mean i should it by creating another row on my table? Can you give an example?

0

Posting the same code again? Not sure why.

The values was a mistake but its not this. The '100,102,204' are finctional ids, the point is that i want to store multiple values in one row. Here is the code that i dont know if its right.

The whole point about NOT storing multiple values in one row is that it's the WRONG way to do it. If you insist on this approach, I don't really know what to suggest, other than to wish you well with it.

0

I read both articles. I dont think that this will apply to my situation. Because there is no violation of first normal form. I use child tables or second and third normal forms in many cases on my db. Let me explain what i want to do. Lets say that you want to send the same message to more than one user. As far as i understand i ll have to make a second formal form with each user id and the message itself or only the same message id right? Why do that? The same message will go to several users. There will be no conflict in the db. There is not going to be the same message again anyway because they will be unique by their id.

0

The issue comes when the user searches for messages to him/her. At the moment you want to place

'102,786,234,...' into a field. So if I'm user #786, the DB needs to search every row for 786 within that field. You'd probably need to use a FIND_IN_SET()in your WHERE clause. Urgh.

I'd use an index and normalized table, as I noted previously. But that's just MY opinion. Anyhow your original question is about the building of the string. Print the query to the screen (followed by exit) to see what it says.

0

Ok. I am not so advanced to fully understand what you are saying but i got the picture. In this case its not going to have a search option for the user but that its not the point, i ot what you are saying. I did an echo not print the values are showing ok but there not stored in the database and i dont know why

Edited by SimonIoa: change

0
$query =  mysqli_query($this->db,"INSERT INTO `table` (title,desc,url, img, uid_fk, created, to_uid_fk) VALUES ('$update','$update_description','$press_url','$press_image','$uid','$time',$val)") or die(mysql_error());
$result = mysqli_fetch_array($newquery,MYSQLI_ASSOC);

$query or $newquery?

ANyhow my suggestion is this:

$sql = "INSERT INTO `table` (title,desc,url, img, uid_fk, created, to_uid_fk) VALUES ('$update','$update_description','$press_url','$press_image', '$uid', '$time', $val)"
echo $sql;
$newquery =  mysqli_query($this->db, $sql) or die(mysql_error());

See what the SQL looks like.

0

It returns this.
2 and 17 are the ids that i want to store in the row

2,17INSERT INTO advertisments (title,desc,url, img, uid_fk, created, to_uid_fk) VALUES ('','','','', '16', '1441550633', '2,17')

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.