jcbones
Staff Alumni-
Posts
2,653 -
Joined
-
Last visited
-
Days Won
8
Everything posted by jcbones
-
php update query changed all rows. Please help
jcbones replied to php-newbies's topic in PHP Coding Help
I'm sorry, it is my fault: $query ="UPDATE Customer_Registration SET Firstname='$Firstname',lastname='$lastname',Address='$Address',Postcode='$Postcode',Phone='$Phone',Email='$Email',Customer_Type='$Customer_Type',Computer_type='$Computer_type',Computer_maker='$Computer_maker',Model='$Model',OS='$OS', Appointment_date='$Appointment_date',Problem='$Problem',Solution='$Solution',Comment='$Comment' WHERE cf_id=$cf_id"or die (mysql_error()); You shouldn't add the last part to the variable. $query ="UPDATE Customer_Registration SET Firstname='$Firstname',lastname='$lastname',Address='$Address',Postcode='$Postcode',Phone='$Phone',Email='$Email',Customer_Type='$Customer_Type',Computer_type='$Computer_type',Computer_maker='$Computer_maker',Model='$Model',OS='$OS', Appointment_date='$Appointment_date',Problem='$Problem',Solution='$Solution',Comment='$Comment' WHERE cf_id=$cf_id"; Now, if cf_id is not listed as an integer field, then you should enclose it in single quotes. WHERE cf_id='$cf_id' I re-instate what Pik says also. You need to pass the cf_id through your form. -
php update query changed all rows. Please help
jcbones replied to php-newbies's topic in PHP Coding Help
You missed a $ in this line: $query ="UPDATE Customer_Registration SET Firstname='$Firstname',lastname='$lastname',Address='$Address',Postcode='$Postcode',Phone='$Phone',Email='$Email',Customer_Type='$Customer_Type',Computer_type='$Computer_type',Computer_maker='$Computer_maker',Model='$Model',OS='$OS', Appointment_date='$Appointment_date',Problem='$Problem',Solution='$Solution',Comment='$Comment' WHERE cf_id=cf_id"or die (mysql_error()); I think it should be: $query ="UPDATE Customer_Registration SET Firstname='$Firstname',lastname='$lastname',Address='$Address',Postcode='$Postcode',Phone='$Phone',Email='$Email',Customer_Type='$Customer_Type',Computer_type='$Computer_type',Computer_maker='$Computer_maker',Model='$Model',OS='$OS', Appointment_date='$Appointment_date',Problem='$Problem',Solution='$Solution',Comment='$Comment' WHERE cf_id=$cf_id"or die (mysql_error()); -
What "other array"?
-
Writing to an exact Ln, Col of a file
jcbones replied to Freedom-n-Democrazy's topic in PHP Coding Help
You could use file(), then select the line from the resulting array. You would then have to know the file specifics in order to be able to explode() the line down to get the right column. After all of this, you would need to put it all back together, and file_put_contents(). -
Yep, it looks like I missed a closing ) on every line I put in there. if(in_array($filename,array('..','.'))) { continue; }
-
<link rel="stylesheet" type="text/css" href="style.css"> <span class="note"> <?php echo "directoryname3"; ?></span> <?php $dir="directoryname3"; if ($dir_list = opendir($dir)) { while(($filename = readdir($dir_list)) !== false) { if(in_array($filename,array('..','.')) { continue; } ?> <p><a href="<?php echo $filename; ?>"><?php echo $filename; ?></a></p> <?php } closedir($dir_list); } ?> <br><br> <span class="note"> <?php echo "<b>directoryname3</B>"; ?></span> <?php $dir="directoryname3"; if ($dir_list = opendir($dir)) { while(($filename = readdir($dir_list)) !== false) { if(in_array($filename,array('..','.')) { continue; } ?> <p><a href="<?php echo $filename; ?>"><?php echo $filename; ?></a></p> <?php } closedir($dir_list); } ?> <br><br> <span class="note"> <?php echo "<b>directoryname3</B>"; ?></span> <?php $dir="directoryname3"; if ($dir_list = opendir($dir)) { while(($filename = readdir($dir_list)) !== false) { if(in_array($filename,array('..','.')) { continue; } ?> <p><a href="<?php echo $filename; ?>"><?php echo $filename; ?></a></p> <?php } closedir($dir_list); } ?> <br><br> <span class="note"> <?php echo "<b>directoryname</B>"; ?></span> <?php $dir="directoryname"; if ($dir_list = opendir($dir)) { while(($filename = readdir($dir_list)) !== false) { if(in_array($filename,array('..','.')) { continue; } ?> <p><a href="<?php echo $filename; ?>"><?php echo $filename; ?></a></p> <?php } closedir($dir_list); } ?>
-
http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/ Simple Image makes this easy, and has great documentation that gets right to the point.
-
$title = 'PHP freaks Rocks'; $title = substr($title,0,strrpos($title,' ')); echo $title;
-
something not working, and I can't see what :(.. image upload
jcbones replied to roth_t's topic in PHP Coding Help
Here: $newwidth=200; $newheight=($height/$width)*$newwidth; $tmp=imagecreatetruecolor($newwidth,$newheight); $newwidth1=200; $newheight1=($height/$width)*$newwidth1; $tmp1=imagecreatetruecolor($newwidth1,$newheight1); You can see that you make the images the same size. Change one of the $newwidth(1) to the thumbnail width size. ie 50 -
This code: $i = count($matches[0]); echo $matches[0][$i]; Will NOT work, as $i would be 221 (which leads me to believe that you echo'd the $i and then later a 6 to get the returned number. The reason it would be 221 is that array's start at 0, but count starts at 1. So you need to subtract 1 from the count, in order to get the highest key from a numerical array.
-
Is your localhost running Windows? If so, you will have to schedule using task scheduler. C++ is an option, but if the economy scripts output to the web, PHP is the better choice IMHO.
-
If you are on a *nix server, then yes a cron job (crontab) is what you will need. Crontab quick reference If your host has cpanel or equiv. then there will be a easy user interface for you to set up a crontab.
-
Using PHP with MySQL - code doesn't work, but is parsed OK
jcbones replied to Freedom-n-Democrazy's topic in PHP Coding Help
Ah, I see that being nice is lost on you. Good luck in the future. PS. I heard better jokes about my last name in elementary school. -
Change: if(in_array($file,array('.','..'))) { continue; } To: if(in_array($file,array('.','..')) || strrchr($file,'.') == '.LCK') { continue; } This is un-tested, so let me know how it goes.
-
Sorry for the double post again. But, how would I go about doing ^^ ? Or I guess, do you have time to explain it a bit? This explains it a bit. http://www.zymic.com/tutorials/php/sanitisation-and-validation-in-php/
-
% is the wildcard character. $sql = "SELECT * FROM players WHERE $search_by LIKE '$search%' "; This will give you data that starts with the letters you searched. $sql = "SELECT * FROM players WHERE $search_by LIKE '%$search' "; This will give you data that ends with the characters you searched. $sql = "SELECT * FROM players WHERE $search_by LIKE '%$search%' "; This will combine the two, and give you results that start, end, or in-between.
-
Replace that line with these two lines. $name = strrchr($value,'/'); echo '<li><a href="'.$value.'">'.substr($name,1).'</a></li>';
-
Yes, the optional parameter to strstr() is available only on PHP 5.3.0 and later versions. Hold on a sec, and I will get a work around to that.
-
Using PHP with MySQL - code doesn't work, but is parsed OK
jcbones replied to Freedom-n-Democrazy's topic in PHP Coding Help
And, that is why I asked what you were trying to do, and got the lame answer of "update a html form". I also told you that you were setting the id to the same id you were looking for. One line of code means NOTHING in a PHP script. That line could work, yet something else breaks it. You should post 5 lines above and below the line you think is the problem. If you post your code, I would be glad to help. -
Using PHP with MySQL - code doesn't work, but is parsed OK
jcbones replied to Freedom-n-Democrazy's topic in PHP Coding Help
So you are trying to set the id to a row that already has that id? I wonder why it doesn't work. Tell us what you are trying to accomplish, please. -
From my library. Make sure you don't close the directory with a slash. ex. full/path/to/directory/ <-wrong full/path/to/directory <-right <?php function dirContents($dir) { if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if(in_array($file,array('.','..'))) { continue; } if(is_dir($dir.'/'.$file)) { $contents[$dir.'/'.$file] = dirContents($dir.'/'.$file); } else { $contents[] = $dir . '/' . $file; } } closedir($dh); } } return $contents; } function processArray($array) { if(is_array($array)) { echo '<ol>'; foreach($array as $key => $value) { if(is_int($key)) { echo '<li><a href="'.$value.'">'.str_replace('/','',strstr(strrchr($value,'/'),'.',true)).'</a></li>'; } else { echo '<li><span style="font-weight:bold">' . $key . '</span>'; processArray($value); echo '</li>'; } } echo '</ol>'; } } processArray(dirContents('PATH TO DIRECTORY')); ?>
-
It really depends. Are you going to have 10 static html files? Without images = Yes, With images = NO! I usually group my files according to what they do. Just like you would a filing cabinet. If you have to add something in a file, there is no question where that file resides. And, it will not take you 2 hours to find it.
-
Newby: Help to debug application which outputs blank pages
jcbones replied to danwednesday's topic in PHP Coding Help
Open the scripts that generate blank pages, and add these lines at the very top. <?php //if this tag is already the first thing on the page, you can omit it. error_reporting(-1); ini_set('display_errors',1); -
Sure, but first you will have to do one other thing. Top of Script <?php error_reporting(-1); ini_set('display_errors',1); Search in the Script and: Replace: $result = mysql_query($sql); With: $result = mysql_query($sql) or trigger_error(mysql_error()); Post back with the error.
-
$query ="Insert into Accounts(Name,lastName,emailId,DOB,password) VALUES('$fname','$lname','$mail','$dob','$password')"; Remove: $query=mysql_real_escape_string($statement); Explanation: Strings sent to MySQL must be enclosed in single quotes.