scootstah
Staff Alumni-
Posts
3,858 -
Joined
-
Last visited
-
Days Won
29
Everything posted by scootstah
-
Export mysql to txt / xml file and download it
scootstah replied to thaidomizil's topic in PHP Coding Help
Maybe if you define "doesn't work" we would be able to help you. -
Then you don't need it here. Without knowing more about your app we can't really help any further. You are trying to use a session when it hasn't been set. From you example I can wager a guess that you are trying to get data from a logged in user that isn't logged in. I don't know where you are setting the username or how this code is being called.
-
Sure, but that's only like 3MB give or take. I'm sure most people can spare 3MB on their hosting.
-
Use OR. $makeQuery = mysql_query("SELECT * FROM points_tags WHERE tag_id="term1' OR tag_id='term2'");
-
So then $_SESSION['username'] obviously wasn't set. This is either because you are not calling session_start() at the top of your script or it just wasn't set in a way you expected. And because it isn't set, it messes up the SQL query which is why you get the next error. And the other two errors are likely because you are trying to use the data returned from the query which didn't run.
-
Using PHP OOP concept connecting to MySQL database
scootstah replied to raaks's topic in PHP Coding Help
You already run the query here: $query = $connection->query($myquery); So now $query contains the mysql resource. Then you pass it to fetch here: while($array = $connection->fetch($query)) Then in fetch, you try to run the query with the already-run resource: $array = mysqli_fetch_array($this->query($sql)); Instead, just use the $sql variable to fetch the array. $array = mysqli_fetch_array($sql); A couple pointers, if I may: 1. Don't use var at the top of your class. This is old syntax. Use Public, Private, or Protected instead. 2. In addition to the above point, make sure you set the visibility responsibly. Does the database connection (dbc) really need to be public? Why would you ever need to access it outside of the class? 3. Using die() in a class is generally not something you want to do. It can cause your site to break in fantastic ways. You should set your query errors to an error class variable. Then make a method to retrieve these errors if you need to show them. You could also log them to a file. 4. Don't use mysqli_fetch_array() unless you specifically need that functionality. The reason is because it returns both a numerical and associate array which is unnecessary and inefficient. Since you are using array keys to access the data, just use mysqli_fetch_assoc() to only return an associative array. Hope that helps. -
Did you even read the errors? Undefined variable: _SESSION In C:\wamp\www\includes.php on line 2. This tells you that the error is on includes.php on line 2. Rinse and repeat.
-
Code would be nice.
-
Wouldn't you just want to throw some <img /> tags around the echo? while($file = readdir($odir)){ if(filetype($file) == "image/JPEG") { echo '<img src="' . $file . '" />'; }/code]
-
It is because in the box model, your third div is under both of the other divs. So your layout looks like: [1] [2] [3] Then using relative positioning you "move it" over and up, but its space in the box model remains. Why not use floats instead? http://jsfiddle.net/y9gzA/
-
While I believe frameworks are not for every project, I don't agree on this reason. Most frameworks only use what you want it to use and therefore have a pretty small footprint.
-
The general idea is to have them enter their email into a password reset form. Your script will generate a random token, store it in their users table, and then email it to the email they entered. They will be given a link to follow that has the token in it. If the token matches that of the one you stored in the database, they will be able to create a new password. The token must be random and unique.
-
So then you can easily fix this error with an if statement. if (isset($_SESSION['cart']) && is_array($_SESSION['cart'])) { foreach(array_keys($_SESSION['cart']) as $i) { if (isset($_REQUEST['q'.$i])) { $_SESSION['cart'][$i]['q']=$_REQUEST['q'.$i]; if ($_SESSION['cart'][$i]['q']>999) $_SESSION['cart'][$i]['q']=999; if ($_SESSION['cart'][$i]['q']<1) $_SESSION['cart'][$i]['q']=1; } //end of if } // end of foreach }
-
Did you mean textarea then? Just replace input[type=text] with textarea. Working example here: http://jsfiddle.net/kRRrQ/1/
-
I see now that you are talking about the part of the function that actually generates the options whereas I was simply talking about comparing to a selected value. So then I concede, you win this round.
-
Well users wouldn't necessarily have to be sorted by language, so they could still private message and such. But to view other language's forums I would imagine they should have to change the sites language. Maybe make it a convenient dropdown box or something. If you don't want the change for all forums then put the flag in the forum table instead.
-
This is a long shot...but here it goes
scootstah replied to son.of.the.morning's topic in PHP Coding Help
It doesn't matter. Unless specific circumstances say otherwise, you should never store formatted content. -
input[type="text"]:focus { background:red; color:white; }
-
Maybe this will help? http://www.sitepoint.com/interactive-cli-password-prompt-in-php/
-
move onto next item in loop without a bunch of if statements?
scootstah replied to dadamssg87's topic in PHP Coding Help
Can you give a real-world example? -
But you are deciding which to use inside the function, which isn't necessary. You are giving the function too much responsibility. All it needs to do is compare the value. For example if this was our data: $names = array( 0 => 'john', 1 => 'debbie', 2 => 'matt' ); You are determining whether to use the the value or the array key inside the function. In my opinion you should determine this ahead of time. foreach($names as $key=>$val) { if ($id == $key) $selected = $key; } And then just pass $selected to the dropdown function. In the end either way works, just preference I guess.
-
That would be a looooooooot of tables depending how many languages you support. I would just add a flag to the post that denotes its language, and then you can simply use a WHERE clause in the query to get posts with that language.