Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I couldn't find an anwser on google, so here's my question.
Let's say, I have a table which has name,lastName,Age columns.
What I want to do, is insert only "name" into the table.
I have a function
function c_mysqlInsert($ptable,$pvaluename,$pvalue,$database=""){
global $con_dbaccounts;
$dbname = ($database=="")?$con_dbaccounts:$database;
$con = c_dbconnect($dbname);
mysql_query($con,"INSERT INTO $ptable ($pvaluename) VALUES('$pvalue')");
}
/**
which doesn't seem to insert any new things into the $pdbtable, even when $ptable, $pvaluename and $database are all correct. It does connect to the database $database.
I thought it would create a new row with $pvalue and the other columns empty (or NULL), but it doesn't.
So I guess I can't do it this way - call c_mysqlInsert function multiple times to insert into all three columns, so is there any other way I could make this function work?
Your insert statement has the $pdbtable variable but the variable passed into your function is $ptable. Change the variable in your insert and you should be golden.
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I have a table where I want to delete a member from the club but I don't want to delete the member from the database, just leave the member without the club, reason why I'm trying to use patch instead of delete in this case. I tried to set the value to null but it is returning me this error Trying to get property 'NULL' of non-object, is there a way I could do this?
I am not using migrations for the table, it's a table I already had created in postgreSQL, the column I'm trying to edit is nullable.
This is what I'm trying to do:
$trash = null;
Member::where('doc_iden',$id)->update(array(
'id_club'=> $trash,
));
Membresia::where(['id_lec'=>$id,'id_club'=>$idclub,'fec_f'->$trash])->update(array(
'fec_f'=>date('Y-m-d'),
));
I tried to do it with NULL instead of null and setting the value directly without using a variable but I have the same error and I don't know what to do here.
Update: The first bit works, the second doesn't
You have a typo.
'fec_f'->$trash]
should be
'fec_f'=>$trash]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
Could someone please point me where did I go wrong?
I've an apps using PHP and mysql. The thing is, we are using some file uploader plugins that require us to save the unique id that has format something like this a41ddc78-3fee-4bf3-88c1-83028ae22f1. At some point, I need to select data from the database using this fields and as you can see, I can't get the field when I do manual query on it. any help is appreciate on how to solve this problem. Thank you
SELECT * FROM product_image WHERE unique_id = 'a41ddc78-3fee-4bf3-88c1-83028ae22f1'
the query works fine...
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I would love a starting point for this problem.
I have a list of IP's retrieved from a source, the IP's along with ID's get stored in a table.
I want to check the table against my array each time it grabs new data, to make sure the array is not putting a duplicate IP in the said table.
Wrong way to think about the problem. Let the database control the data. You can ensure no duplicates by defining a constraint or unique index on the IP column (they are pretty much equivalent):
create unique index unq_iptable_ip on iptable(ip);
Then, if you attempt to insert a duplicate ip, the database won't let you. This ensures data integrity, and the database can do this better than you can (consider what happens if multiple users try to modify the table at the same time).
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
SO, I want to create a pretty big mysql table that should save all of the squares of a chess board and their value, I'm using a PHP for() since it has 64 squares.
This always gives me 'not working'
<?php
mysql_connect('localhost','pierostesting','');
mysql_select_db('my_pierostesting');
$query="CREATE TABLE board (";
for($i=0;$i<63;$i++){
$query .= "i".$i." INT(1) NOT NULL,";
}
$query .="turno BOOL";
if (mysql_query($query)){
echo 'working';
}else echo 'not working'; ?>
I'm an idiot, didn't close the bracket.
try echoing out your complete SQL string, then use phpMyAdmin and see if the sql string actually works, or if it throws errors. You may have a sql syntax error.
If it does work, make sure your connection variables are correct (host, db name, username, password)
that should get you close to the answer.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I am trying to get this to update a record and was wondering why I cant get this to work?
I can write a new record no problem but the update doesn't work; is it something simply I am missing?
else {
echo "ID NOT EMPTY-";
//---inside else statement shows this echo and the $id number printed on screen WHERE should have varible $ID but I changed it to debug
echo "$id";
$SQLstring3 = "UPDATE $Tablename SET(blank='1') WHERE(id='5')";
$QueryResult = #mysql_query($SQLstring3, $DBConnect);
}
I think the problem might be the way you are using SET and WHERE. Putting them the parentheses () immediately following them might make them seem like a MYSQL function, which it tries to execute. What you have is this:
"UPDATE $Tablename SET(blank='1') WHERE(id='5')";
Try removing the parentheses:
"UPDATE $Tablename SET blank='1' WHERE id='5'";