premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
Well you are echoing $sql, which echos that whole statement. I would avoid doing that, just because of the binary data. What do you mean "the image doesn't change". You will not be able to access the image on that page directly, as it has to have the correct headers. You would need another script to fetch the recently inserted image from the $user IE: echo "<img src='image.php?id={$user}>"; Where the image.php script retrieves an image from the mysql database at that id and uses header call to print out the actual image.
-
Explain what you mean by that. The loop should go to however many you tell it. Do you want it like 100, 200, 300 or just 1 through 100?
-
Have you printed out the variables (all but the image $content) and see if they hold the right items? My bet would be $user is either not valid or not being passed through. And : if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } Is sort of backwards. I would recommend this: if (get_magic_quotes_gpc()) { $fileName = stripslashes($fileName); } $fileName = mysql_real_escape_string($fileName);
-
Bottom left hand corner above quick reply.
-
Follow the structure you have. I am not sure what type of fields you want because you are vague and did not provide the html form. $fieldname = $_POST['fieldname']; $fieldname2 = $_POST['fieldname2']; etc.
-
The below doesn't use scandir but it does the same thing as scandir but it also filters what is in the folder. $dir = "templates"; foreach (glob($dir . "/*.xml") as $filename) { echo "<p>$filename size " . filesize($filename) . "</p>\n"; } That should scan the templates dir for xml files. For a scandir example: $dir = '/templates'; $files = scandir($dir); foreach ($files as $filename) { if (stristr($filename, ".xml") !== false) { $fileData = file_get_contents($file); // parsing data here } } As you can see, glob is easier as it pulls what you want, not everything including the kitchen sink. EDIT: Modified the scandir version to be correct.
-
From the looks of it that code is correct. Are you sure your database does not have any bad data in it? And when you do the select count should you be limiting that in any way?
-
Use glob foreach (glob('*.xml')) as $file) { $fileData = file_get_contents($file); // parsing data here }
-
if($logged_in){ echo '<a href="tex.php?id=' . $rows['id'] . '">' . $rows['title'] . ' - <i>'.$rows['author'].'</i></a>'; }else{ echo '<p class="logintext"><a href="main.php">Login / Register</a></p>'; } Should fix you up.
-
Why not just change the session.save_path to be within your own directories then make that directory be protected by you. This is preferred especially on a shared host. You should be able to use .htaccess to change where the session saves the data at.
-
Going a little loopy are we? print "<table border='1'>"; for($c=1; $c<=10; $c++) { print "<tr> <td>$c</td> <td><input type='text' name='$c' size='20'></td> <td> <select name='valincome'>"; for($cc=0; $cc<=50000; $cc=$cc+100) { print "<option value='$cc'>$cc</option>"; } print "</select> </td> </tr>"; } print "</table>"; You should really learn the Basic Syntax of php, as it shows you are really lacking on that knowledge. EDIT: Beaten to it
-
Not sure what you mean, but I bet explode and implode are what you are after. $subtypeDesc = "Made from quality thermal paper treated on one side to produce an image from heat. These rolls are wound with the treated side out, which suits most machines. They are measured width of paper x diameter of roll x inside diameter of core."; $subtypes = explode(".", $subtypeDesc); implode("</li><li>", $subtypes); echo $subtypes;
-
Great. It is nice to see that some people can test and implement logic based on someone stating it. Glad it worked and good luck.
-
Your setcookie is wrong. You can try using .htaccess or even ini_set to set the session save. But if your host has sessions disabled, then yea. You have no control over that. Check the phpinfo and see if there is a section called "SESSIONS" that states "disabled" under it. Sessions should be default on most php builds unless they turned it off.
-
if (isset($p[1])) { if(strlen($p[1]) == 0) $price = $p[0].".00"; else if(strlen($p[1]) == 1) $price = $p[0].".".$p[1]."0"; } Basically $p[1] was not being populated, for whatever reason. You may want to look into that. This should solve that issue either way.
-
One You are adding spaces inside the ' of the sql, this is not good practice and will cause different issues. $sql = "SELECT * FROM users WHERE username='". $username ."'"; // and this one here too: mysql_query("INSERT INTO users VALUES(`id`,'". $username ."')") or die(mysql_error()); At least you were consistent. Two you should trim the username coming from post and escape it: $username = mysql_real_escape_string(trim($_POST['username'])); Just incase anyone posts bad characters. Finally you should check if username is populated before moving on: if(empty($username)) { Fix those items and see where that gets you. EDIT: Also your form will show up no matter what, I do not think you want this. I would move the if before the form and put the form in it's own if statement after the if $_POST['submit'] isset. Something like: if ($curnum > 0 || !isset($_POST['submit'])) { Then put the form inside that. So it only shows if there is an error. I would also make the mysql_num_rows part an if else: if(mysql_num_rows($res) > 0) { $curnum ++; echo $curnum . ". The username '". $username ."' already exists!</br>\n"; }else { mysql_query("INSERT INTO users VALUES(`id`,' ". $username ." ')") or die(mysql_error()); }
-
print "<select name='income'>"; for($i=1; $i<30; $i++) { print "<option value='$i'>$i</option>"; } print "</select>"; You had a semicolon ; after the for portion.
-
As long as the batch file accepts a parameter (I think you need to code that way) system or any one of the exec functions would work.
-
[SOLVED] How do I find the last element in my associative array?
premiso replied to tvance929's topic in PHP Coding Help
If you arsort the array, then it will put the lowest value at the bottom. Then your code "should" work. EDIT: Never mind, I dunno what I was thinking when I posted that. It is an associative array After that arsort end will grab the last item from the array, which will be the lowest value for you to test. -
[SOLVED] How do I find the last element in my associative array?
premiso replied to tvance929's topic in PHP Coding Help
Post a print_r of the current array so we can see what we are dealing with. -
The file being written to needs to have Write permissions. chmod 0777 will grant it full permissions to anyone.
-
Perhaps posting/searching through the right forum will help you. PHPFreaks ModRewrite
-
You did not use "flush" you used "clean" instead. ob_start(); $ip = $_POST['ip']; $subnet = $_POST['subnet']; $description = $_POST['description']; echo ' conf t <br> interface x/x <br> ip address '.$ip.' '.$subnet.' <br> description '.$description.' <br> no shutdown <br> '; $LogToFile = ob_get_contents(); $myFile = "test.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = "$LogToFile"; fwrite($fh, $stringData); fclose($fh); ob_end_flush(); // note the flush not clean.
-
You always set the session x to random no matter what. You need to test that if session['x'] isset and $_POST['submit'] isset then you do not do the number generator. If it is not, then you do the number generator.
-
ob_end_flush You just have to use a different function to send it to the browser.