"DELETE FROM email_list WHERE email = '$delete_id'";
Quotes
"DELETE FROM email_list WHERE email = '$delete_id'";
Quotes
lol yea i have uncommented it, still no luck. Thanks, i do appreciate the help
Ok, well repost your code because there is something wrong still.
ok that seemed to work, but its still not deleting it from the database...thanks a lot for the help i appreciate it. The echo query shows that only one selected checkboxes email is shown at the end of the echo query command
stupid question, did you uncomment the part that is deleting? ie. remove the /* */. Also, you didn't put quotes around the email like I showed
Of course it's going to be empty, there is no ID field in the table. I'm going to assume you're using the email as the primary key, so change id to email in both the $row['id']
and changed WHERE id = $delete_id
to WHERE email = '$delete_id'
.
Also, edit your post to remove those emails.
http://davidwimbley.com/mysql/emaillist/removeemail.php
There is the link to the page
Your values are empty which means there is now id field in your table. var_dump($row);
before you echo the <input> tag
If you're getting empty values then $row['id']
is empty when you're writing the checkboxes. View the source of the page and make sure their values aren't empty. If they are the only explanation is that there is no "id" field
Do the checkboxes show up on the form? And are you checking a checkbox when you test the delete?
Ok, now post your form from which this is getting submitted to.
Hey i hate to do this to you but i did the echo $query; and it displayed my query but it still did not delete anything.
this is what it displayed
DELETE FROM email_list WHERE id =
Which tells you what? That $delete_id
is empty. Change the current
// Delete the customer rows (only if the form has been submitted)
if (isset($_POST['submit'])) {
foreach ($_POST['todelete'] as $delete_id) {
$query = "DELETE FROM email_list WHERE id = $delete_id";
mysqli_query($dbc, $query)
or die(mysql_error());
}
echo 'Customer(s) removed.<br />';
}
to
if (isset($_POST['submit'])) {
var_dump($_POST['todelete']);
/*
foreach ($_POST['todelete'] as $delete_id) {
$query = "DELETE FROM email_list WHERE id = $delete_id";
mysqli_query($dbc, $query)
or die(mysql_error());
}
echo 'Customer(s) removed.<br />';
*/
}
and tell me the output
>That is the "new" code under the comment:
Thanks,
Please mark this thread as Solved.
haha, I don't think (s)he actually had it solved, (s)he was just responding to my request to repost the new code.
If you didn't get an error then it means it deleted the row. Before mysqli_query do echo $query;
just to make sure it's deleting what you think it is deleting.
Is it corrent?
SELECT FROM email .....
If this statement is select then he/she must have to include column list or *.
// Delete the customer rows (only if the form has been submitted) if (isset($_POST['submit'])) { foreach ($_POST['todelete'] as $delete_id) { $query = "SELECT FROM email_list WHERE id = $delete_id"; mysqli_query($dbc, $query) or die('Error querying dHIHIHIHIHIHI.'); }
That code will always fail because SELECT FROM
is invalid MySQL syntax. The comment says that it should be deleted, all that has to be changed is SELECT to DELETE
Ive changed the SELECT back to DELETE and have entered the die(mysql_error()) and now no error pops up. But its not deleting the record, it is still fetching the records out of the database.
When you tell us you changed code and you're getting a new error the smart thing to do would be to post the new code. We're not telepathic nor do we live in this here computer-box and can travel through the wires to see what you're doing.
The error being desplayed is this one here, i edited the display error so i could narrow it down.
I dont understand, if it can query the database and bring the rows of information and display it on the page, then why cant it delete it?
The connection string is the same for the other two scripts i have written and they work fine, the adding and sending email script
Thanks for the help
// Delete the customer rows (only if the form has been submitted) if (isset($_POST['submit'])) { foreach ($_POST['todelete'] as $delete_id) { $query = "SELECT FROM email_list WHERE id = $delete_id"; mysqli_query($dbc, $query) or die('Error querying dHIHIHIHIHIHI.'); }
Because as adapost said, you're not deleting with that query, you're just selecting. Changed SELECT to DELETE. And for future reference, when you're doing or die() on a query, don't put in arbitrary text do die(mysql_error()) (In other words, read the damn FAQ)
Thanks for the response but i actually have tried that and i still get a connection error. Any other thoughts?
If you get a connection error than it's not the query that is wrong.
What EXACTLY is the error being displayed to the page?
alright..i put the code tags and the table appeared with the random numbers. but the box that is suppose to show the max numbers does not appear. how else would i get the program to work without using the the function again the second time?
I meant use code tags in your post, not in your code. Take a gander at the PHP manual and come back once you have a grasp on how functions work. http://www.php.net/functions
Well there's a whole lot wrong. A) You didn't use code tags, B) You're using global
instead of passing arguments to the functions, C) You're duplicating a function for no reason, D) You're not taking advantage of built-in language functions http://www.php.net/arrays
Hi
I am trying to modify a class and I found this code in it:$query = " SELECT * FROM menus WHERE show = '1'"; $id = $this->menuid; if((isset($id)) && ($id != '')) { $query .= " and menuid in($id)"; } $query .= " ORDER BY menuorder ASC"; $result = $db->query($query); while($row = $db->dbarray($result)) { @extract($row); if(($checkuser == 1) && ($_COOKIE['mid'] != $var['Guestid'])) { $menu .= $this->$menutitle(); } elseif(($checkuser == 2) && ($_COOKIE['mid'] == $var['Guestid'])) { $menu .= $this->$menutitle(); } elseif($checkuser == 0) { $menu .= $this->$menutitle(); } }
what does "$this->$menutitle()" refer to? and how does it work? To my understanding you can not put a $ sing after "->" in a class. $menutitle() does not seem to me as a variable neither as a function. What am i missing?
That is a variable property in the same why variable variables are created. For example:
// variable variable example
$var = "hello";
$hello = "world";
echo $$var; // world
// variable property example
class TestClass
{
public $hello;
public function __construct()
{
$this->hello = "World";
}
}
$test = new TestClass();
$var = "hello";
echo $test->$var; // world
See http://us2.php.net/manual/en/language.variables.variable.php
Thanks all, for your input..
I have tried all but none is success..the same error still appear on the same line.thanks
Then show all of the code, not just one line.
Thanks djjjozsi I seem to be getting somewhere !:)
I have the site back up but at the top of the page it says//
Warning: Wrong parameter count for explode() in /home/flyagdei/public_html/templates/lingerie_4/main_page.tpl.php on line 15which is this bit $time = explode( $time);
Any more ideas?
Thanks again guys
Jo
Yeah, here's an idea, go read the documentation for explode
. php.net/explode
The { at the end, before the ?> should be }.
Hi.
Sure, I can give you an example.
It's pretty basic at this point, but I assume you are going to be adding your own methods to it.Note that I don't store the actual password used for the connection, but rather a SHA1 has of it. (For security reasons)
And I don't allow the outside code to alter the stored database connection information. (No reason to allow that, really)Also note that I use the constructor to connect to the database.
If you want the class to support reusing an instance for multiple connections, you will need to createopen()
andclose()
methods.<?php class MySQL_Database { /** The database link,. * Used by the code to execute queries and such **/ private $dbLink; /** Connection property values **/ private $host; // Host name. E.g. "localhost" private $user; // Name of the MySQL user private $dbName; // Name of the database to use private $password; // A hash of the user's password /** * The constructor. * Establishes a connection to the database. * @param string $host * @param string $user * @param string $password * @param string $dbName */ public function __construct($host, $user, $password, $dbName) { // Connect $this->dbLink = mysql_connect($host, $user, $password); if(!$this->dbLink) { throw new Exception("Connection to database failed."); } if(!mysql_select_db($dbName)) { throw new Exception("Failed to set the database."); } // Set getter values. $this->host = $host; $this->user = $user; $this->dbName = $dbName; // Create a hash of the password and store it. // …
No, please avoid them like the plague. They're annoying, old, and rickety just like websites that use them. The only function they serve now are for hacks for file upload.
Use one or the other, not both. PHP was originally used as a replacement for SSI bull. Bottom line is, don't use SSIs
It seems to be a max execution time error. I got some other error messages as well for the image resizing but I always get these but they resize anyhow.
Just changed the max execution and input times to zero for now as that will give it unlimited and will allow me to find out if this is indeed the issue.
If it were a maximum execution time issue you would get "Maximum execution time of X exceeded by FILE. This is indeed a puzzling question.
The code that I posted worked against the file you gave so there's something wonky you're doing with the adtext variable in between there. As a start, get rid of all those damn str_replaces for newlines, you don't need them you're inserting into a CDATA field. I'm not about to decode what the heck those other str_replaces/strpos's are doing, I'll leave that to you
If it were a memory issue you'd get Allowed memory size of X blah blah, trying to allot X bites on line X. Make sure you have error_reporting turned on.
Yep make another file called page.php then use JavaScript and AJAX to retrieve it once your document is ready.
In this page.php you use file_get_contents() to retrieve the files contents.
Note that you cannot use AJAX to fetch content from a domain other than the one the script runs on. The browser will not let you execute cross-domain AJAX requests.
A) use php -l <scriptname> to run PHP Lint to check for syntax errors
B) If you haven't already, remove the damn @ (error suppression)
C) Check your memory limit
D) If all else fails load the page, edit the script to die at one step, then upload and see if it still white-screens, repeat steps until it DOES whitescreen.
Also, remove all of the @#$% error suppression, it's slow and makes it hard as hell to debug.
Do you get an error or does it just white-screen?
Oh, that's just for a makeshift title, we display the first 50 characters or whatever. A couple lines down you'll see $adtext and that's where the whole thing gets displayed (or would if I could get it to work properly).
yeah, I noticed that 3 seconds after I posted it, hence the edit :)
So... the content you gave me is obviously nothing like the content you're using because there were no HTML tags in the example file you gave. Don't put a newline after every attribute, its wasted space, only put a newline after the tag if even then. And paste your output.
I just tested it again and it definitely works. What exactly is your code?
What the code does is reads in the file into an array with each index being a line. What the loop does is goes through each line and checks to see if it starts with your first key which is a series of numbers followed by |. So 3335| or 67341|. If it doesn't match this pattern then it is assumed that it is part of the last row so it is appended to the last row and it continues from there.
This is a bit of a tricky one but you could do something along these lines:
$somefile = file('blah');
$rows = array();
$row_counter = 0;
foreach($somefile as $line => $content) {
if(!preg_match('/^[0-9]+?\|/', $content)) {
$rows[$row_counter] .= $content;
} else {
$rows[++$row_counter] = $content;
}
}
$rows
should contain your corrected array
responSe, not responCe
Firstly, don't put this inside a loop
$sql = "SHOW COLUMNS FROM $dbname.dealerPrice";
$result = mysql_query($sql);
That's going to be the same for each iteration of the loop so you're wasting database time. Do it above the loop and store the result in an array.
Secondly, don't use value1 as a variable name, pick something meaningful.
Thirdly, I have no idea what your 2 inner loops are trying to do and you're tossing arround array_push like there's no tomorrow, []= exists for a reason.
This is what Console.log is telling me:
Object length=0 prevObject=Object context=document <-- votes_count Object length=0 prevObject=Object context=document <-- vote_bottons
I don't know how to interpret that..
length=0 means it isn't returning an element. Right click on each of those, if it doesn't have "Inspect in HTML Tab" then the element doesn't exist in the dom, make sure you actually have something in the HTML that would match "#votes_count"+the_id
Make sure that $("span#votes_count"+the_id)
and $("span#votes_buttons"+the_id)
are actually returning elements by using console.log from FireBug
// in your success function
console.log($("span#votes_count"+the_id));// do the same for votes_buttons
As a side note, you don't have to specify span in front of the #. An ID is supposed to be absolutely unique, there should never be more than one so having extra identifiers is unnecessary.
If that's the case then it means your success function is failing somehow. Do an alert() at the top of the success function to make sure its being called and do any other debugging you see fit to make sure that the actions in that function are actually happening
Parse error: syntax error, unexpected T_VARIABLE, expecting ']' in /home/bluetek/public_html/dac/main.php on line 30
Line 30 is this part:
// This will echo out all the links to the downloads 28 $count = 1; 29 while( $row = mysql_fetch_array( ) ) { 30 if( $row[file$count] == 1 ) } 31 $file_dets = fetch("SELECT * FROM `files` WHERE `file_id` = '$count'"); echo '<a href="'.$file_dets['file_src'].'" target="_blank">'.$file_dets['file_name'].'</a><br />'; } $count++; } echo '<br/ >'; echo "Welcome <b>$session->username</b>, you are logged in. <br><br>" echo "[<a href=\"process.php\">Logout</a>]";
thus this line
if( $row[file$count] == 1 ) }
... ... ... then fix it, you can see where the error is . file$count
is not a valid variable
Make sure you check the Net tab and you're not getting any 404s. If that's not the case then in the Console tab check to see what the AJAX call is actually returning by looking at the Response sub-tab on the Request once its sent
If you're using Firefox get Firebug and see if you're getting any errors
Try using absolute paths(start with /, as opposed to relative that use ../)
It's usually better to add/remove CSS files for specific browsers using HTML conditions like so
<link rel="stylesheet" type="text/css" href="somestyle.css" />
<!--[if lte IE 7]>
<link rel="stylesheet" type="text/css" href="ie7specific.css" />
<![endif]-->