rgb192
asked on
without editing the core code, add values from mysqli to the array
I am using mysqli
this query itterates through the messages I want to delete
select * from search where wrong=1
but it has to fit the config file
$config['username_to_delet e_message' ] = array("user1","user2","use r3");
I do not want to edit the core code
I am adding mysqli to the config file
this query itterates through the messages I want to delete
select * from search where wrong=1
but it has to fit the config file
$config['username_to_delet
I do not want to edit the core code
I am adding mysqli to the config file
ASKER
create table search(
search_id int auto_increment primary key,
profile_id varchar(20),
wrong int
);
the config file is the only file I want to edit
currently the config file has this variable
$config['username_to_delet e_message' ] = array("user1","user2","use r3");
I think I want the array to fit this pattern:
array("user1","user2","use r3")
I am sure that the answer is
$config['username_to_delet e_message' ] = array(list of users goes here);
no need to put a delete statement because I think the delete is in the core file
mysqli_connect
search_id int auto_increment primary key,
profile_id varchar(20),
wrong int
);
the config file is the only file I want to edit
currently the config file has this variable
$config['username_to_delet
I think I want the array to fit this pattern:
array("user1","user2","use
I am sure that the answer is
$config['username_to_delet
no need to put a delete statement because I think the delete is in the core file
mysqli_connect
<?php # Script 16.4 - mysqli_connect.php
// This file contains the database access information.
// This file also establishes a connection to MySQL
// and selects the database.
// Set the database access information as constants:
DEFINE ('DB_USER', 'user');
DEFINE ('DB_PASSWORD', 'password');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'dbname');
// Make the connection:
$dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if (!$dbc) {
trigger_error ('Could not connect to MySQL: ' . mysqli_connect_error() );
echo "not connected";
}else{
//echo "connected";
}
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
include('mysqli_connect');
$used_table='search';
$qcheck ='select '.$used_table.'_id from '.$used_table.' where profile_id=\''.trim($contact_name).'\' ;';
$rcheck =$mysqli->query($qcheck);
$search_id='';
while ($rowcheck=$rcheck->fetch_object()){
$search_id=$rowcheck->search_id;
}
http://www.laprbass.com/RAY_temp_rgb192.php
Outputs:
array(1) {
["username_to_delete_messa ge"]=>
array(3) {
[0]=>
string(5) "user1"
[1]=>
string(5) "user2"
[2]=>
string(5) "user3"
}
}
Outputs:
array(1) {
["username_to_delete_messa
array(3) {
[0]=>
string(5) "user1"
[1]=>
string(5) "user2"
[2]=>
string(5) "user3"
}
}
<?php // RAY_temp_rgb192.php
error_reporting(E_ALL);
$config['username_to_delete_message'] = array("user1","user2","user3");
var_dump($config);
Please clarify the question, thanks.
ASKER
yes, that is the correct var_dump for the config file
ASKER
>>Please clarify the question, thanks.
how can I pass the array
mysqli "select search_id from search"
to the variable
$config['username_to_delet e_message' ]
how can I pass the array
mysqli "select search_id from search"
to the variable
$config['username_to_delet
ASKER
The only thing I could do is
while ($rowcheck=$rcheck->fetch_ object()){
$variable.=' " '.$rowcheck->search_id.' ", ';
}
and strip out the last comma
$config['username_to_delet e_message' ]=$variabl e;
But you always have a better solution :)
while ($rowcheck=$rcheck->fetch_
$variable.=' " '.$rowcheck->search_id.' ", ';
}
and strip out the last comma
$config['username_to_delet
But you always have a better solution :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
first checking with var_dump as you advised
I saw that
$variable[] = $rowcheck->search_id;
$config['username_to_delet e_message' ] = $variable;
is the same as manually creating a comma separated list,
so your answer was better than my automatically creating and with quotes and commas rtriming the last comma of a automatically created list
thanks
I saw that
$variable[] = $rowcheck->search_id;
$config['username_to_delet
is the same as manually creating a comma separated list,
so your answer was better than my automatically creating and with quotes and commas rtriming the last comma of a automatically created list
thanks
foreach ($config['username_to_dele
{
DELETE FROM seach WHERE user='$u' AND wrong=1
}
If you can post the test data and the CREATE TABLE scripts we might be able to avoid the guesswork and show you a more dependable answer.