wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
Make sure you use that function suggested by ignace when you grab the data from the database. Not when you insert data into the database
-
This line $file = file('./file.txt'); Needs to be $file = array_map('trim', file('./file.txt')); Now your code will work as you expected.
-
Are you using short tags eg (<? ?> or <?= ?>) in your code. These tags are not enabled by default. To enable short tags on WAMP left click the wamp taksbar icon and select PHP > PHP Settings > short open tag. You should also make sure you're placing your code in .php files. PHP code will not be parsed in any other files. However you can configure Apache to parse other files as PHP.
-
change it from mysql to mysqli
wildteen88 replied to Danny620's topic in PHP Installation and Configuration
By editing the config.inc.php and changing this line $cfg['Servers'][$i]['extension'] = 'mysql'; to $cfg['Servers'][$i]['extension'] = 'mysqli'; You will need to make sure the mysqli extension is enabled in your php.ini in order for phpmyadmin to use mysqli. -
Apache2.2.11 and PHP5 install..test.php error why?
wildteen88 replied to weevil's topic in PHP Installation and Configuration
I do not recommend moving files out side the PHP installation folder. Instead you should extract the contents of the zip to C:\PHP. Now add the PHP folder to the PATH Environment Variable. Next rename the php.ini-recommended file to just php.ini. Open the php.ini and change extension_dir = "./" to extension_dir = "C:/PHP/ext" Save the php.ini and restart Apache. Go to C:/Sever/htdocs delete all files, except test.php. Now go to http://localhost and you should see a directory listing with test.php listed. Click test.php. Does it run? -
How are you constructing the array? Post your code
-
Your best bet is regex if you want the tags to match. $str = '[i]Hello [b]World[/b][/i] [u]Underline[/u]'; $str = preg_replace('~\[b\](.*)\[/b\]~', '<b>$1</b>', $str); $str = preg_replace('~\[i\](.*)\[/i\]~', '<i>$1</i>', $str); $str = preg_replace('~\[u\](.*)\[/u\]~', '<u>$1</u>', $str);
-
You need to check if the form has been submitted before running your query. The only way to see if a form has been submitted is to see if the $_POST vars exists. Like so if(isset($_POST['submit'])) { $rnamez = mysql_real_escape_string($_POST['ranchname']); $update = mysql_query("UPDATE players SET ranchname = '$rnamez' WHERE id = '".$_SESSION['id']."'"); }
-
You do not need a while loop as the query will only return one result. You only need to have $row = mysql_fetch_array($result); The only time you use a while loop is if the query returns more than one result.
-
Search engine Script In PHP It can be used to connect mySQL DB
wildteen88 replied to Dhiraj Datar's topic in PHP Coding Help
Do you have a question? NOTE: When posting code please wrap it in code tags -
My code wont output anything. It is just the basics. You need to add the code in yourself to edit the Job The code to edit the job needs be where the comment (orange text) is. Like so if(mysql_num_rows($result) == 1) { // display form to edit job ?> Edit JobID #<?php echo $job_id; ?> here Add your form here <?php }
-
Change this line <a href="edit.php" class="bodylinks">Edit Vacancy</a> to <a href="edit.php?id=<?php echo $row['jobID']?>" class="bodylinks">Edit Vacancy</a> Now in edit.php to retrieve the Job id. you'd use $_GET['id']. Example code for edit.php if(isset($_GET['id']) && is_numeric($_GET['id'])) { $job_id = (int) $_GET['id']; $sql = 'SELECT * FROM edworld_jobs WEHERE jobID = '.$job_id; $result = mysql_query($sql); if(mysql_num_rows($result) == 1) { // display form to edit job } }
-
What I'd do is define a constant called ROOT which contains the full path to my sites root folder. So add this file to common.php define('ROOT', $_SERVER['DOCUMENT_ROOT'].'/'); Now include common.php as you normally would. But when including your other files such as template.class.php for example you'd use include ROOT.'class/template.class.php'; This will sort out your path issues.
-
Yes as suggested by dan. First convert the date from your database to unix timestamp using strtotime $time = strtotime($row['date']); Now using the date (click that link for documentation) function you can format the date how you like. example $time = strtotime($row['date']); echo date('D jS M Y', $time);
-
[SOLVED] Problem with checking array & writing
wildteen88 replied to Tonic-_-'s topic in PHP Coding Help
Change this line to $users = file('users.txt'); to $users = array_map('trim', file('users.txt')); -
[SOLVED] Problem with checking array & writing
wildteen88 replied to Tonic-_-'s topic in PHP Coding Help
Thats what Dans code does. -
Oh the issue is with write.php. Change this line $contents .= $filename . '-' . filesize($filename) . "\r" ; To $contents .= $filename . '-' . filesize($filename) . "\n" ; Run write.php followed by test.php.
-
That can be written as $contents = file('datafiles.rtf'); $contents = array_map('trim', $contents); foreach($contents as $line) { list($filename, $size) = explode('-', $line); $files[$filename] = $size; } echo '<pre>'.print_r($files, true).'</pre>';
-
I wasn't being sarcastic. I was just replying to your question.
-
Ofcourse you need to connect to mysql in order for you to perform any SQL queries. If you are querying the database to populate your form then it wont work if you're not connected to mysql. This table is strictly for MySQL use only. The table you created in your database has nothing to do with the user table in the mysql database. You should not be using the MySQL database in your PHP scripts.
-
When I'm reporting posts the page just loads and loads, browser doesn't time out and no errors are shown. However the report is being sent. Seems a strange one.
-
Newlines for windows is \r\n \t is for tab
-
In order for me to tell you that. I need to know what your script is supposed to do. What is your script not doing. Does it return any errors etc.
-
What is wrong with that code? Whats your problem/question. You need to post more info. Also do note when posting code please use code tags ( ).
-
Pop-ups On Server Run, Please Help...
wildteen88 replied to Kaizard's topic in PHP Installation and Configuration
You should keep all files that come with PHP in C:/PHP5. Now add PHP to PATH Environment Variable. Moveing files outside of PHP installation folder can cause more issues. For extensions to load correctly you need to configure the extension_dir directive to point to the ext folder, eg extension_dir = "C:/PHP5/ext" Save php.ini and restart Apache for changes to take affect.