ProSpartan
-
Posts
40 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by ProSpartan
-
-
Okay, I've searched and searched and am hoping someone here can help me out. I've been trying to get a VBScript program to open a word document, search for a specific char and replace it with a Addin field (i.e. { SEQ @ } ) Here's what I have thus far: Const wdReplaceAll = 2 Set objWord = CreateObject("Word.Application")objWord.Visible = TrueSet ObjDoc = objWord.Documents.Open("C:\path\to\.doc")Set objSelection = objWord.Selection With objSelectionobjSelection.Find.Text = "@"objSelection.Find.Forward = TrueobjSelection.MatchWholeWord = TrueobjSelection.Find.Replace.Text = "replacement text"objSelection.Find.Execute ,,,,,,,,,,wdReplaceAll .Fields.Add .Range, -1, "SEQ @", True End With objDoc.SaveobjWord.Quit This code works for "Find/Replace" but does not work for fields.Much help would be awesome! Thanks! Edit, 27 Fed 13 (10:21 CST): In red/strikthrough is removed, plain red is added.
-
PHP Database
in PHP
Okay, thanks. It worked.
-
PHP Database
in PHP
I'm back with a new problem, haha. When i enter text into the textarea of my html page to submit it to the list, but what it does not like is when i use an apostrophe. the error i get is: Error: You have an error in your SQL syntax; check tge manual that corresponds to your MySQL server version for the right syntax to use near ' some text about the input ) ' at line 1. Any thoughts of what could be done?
-
PHP Database
in PHP
Thanks. That's all the question i have for now. Thanks everyone who helped me on this project. Couldn't have done it without all y'all!
-
PHP Database
in PHP
Okay, but then if the table is empty, i don't really want to be adding task 57 of 1 task.As for the auto-increment, there's no reason to reset it. Just let it keep increasing, there's no problem with that.
Okay, i'll keep this in mind for when i make a database with users. But over time, the database will get bigger, taking up more space, so deleting the entry will help with disk space management. So back to my three question that i asked,1. which was answered.2. Resetting AUTO_INCREMENT3. From tasks x, how do i decrease the numbers up from there, tasks x, up.eg for 3. I delete tasks x. I want tasks x+1, x+2, x+3, x+4 to be decreased down to x, x+1, x+2, x+3. how?also, you may want to consider an alternative to deleting the record outright as there is an optional method of just "disabling" the record instead.
As for this, do i assign it to a variable, '$num = "SELECT COUNT(*) AS num FROM table" ', or is 'num' the variable created that contains the count, and called via '$num'?You can use COUNT to get the number of records in a table: SELECT COUNT(*) AS num FROM table -
PHP Database
in PHP
Okay... After much work on this and help from everyone, i've gotten the insert and viewTasks completed. Now, i need help with another problem that has risen. I created a delete.php for deleting tasks in the list. i've gotten to where it will delete the task from the list via and AUTO_INCREMENT number. 1. How do I check to see if the table has nothing in it (empty)?2. How do I reset the AUTO_INCREMENT?3. In thinking of future, how do I delete a task from w number, and decrease the AUTO_INCREMENT number from there Number 3 example: I have 10 tasks. I delete number 4 from the table. How do i decrement the numbers from 5 to 10? delete.php so far
<html><body> <?php$con = mysql_connect("localhost", "root", "");if(!$con){die('Could not connect: ' . mysql_error());}$tasknumber=$_POST['number'];mysql_select_db("tasks", $con);$delete = "DELETE FROM tasks.taskstable WHERE taskNumber=$tasknumber";if(!mysql_query($delete, $con)){die('Error: ' . mysql_error());}mysql_query("UPDATE tasks.taskstable SET taskNumber=taskNumber - 1"); //Reset AUTO_INCREMENT$result = mysql_query("SELECT * FROM tasks.taskstable"); $row = mysql_fetch_array($result);if(isset($row['tasknumber'])){mysql_query("ALTER TABLE tasks.taskstable AUTO_INCREMENT = 1");echo "No tasks left";}mysql_close($con);?> <form method="link" action="index.html"><input type="Submit" value="Return" /></form> </body></html>
-
PHP Database
in PHP
Okay, i got them to show up.
phpMyAdmin does not work. No idea why. It is now that i fixed the while loop.what about some of my questions? -
PHP Database
in PHP
index.html
<html><head><title>Tasks to Complete</title></head><body><table border="1" width="100%" height="100%"><tr width="100%" height="10%"> <td colspan="2" height="10%"> <h2 align="center">Welcome to the Task List</h2> </td></tr><tr width="100%" height="90%"> <td width="50%" height="100%"> <form action="insert.php" method="post"> <fieldset> <legend>Insert Tasks Here:</legend> <textarea rows="15" cols="50" name="task"></textarea> </br> </br> <input type="radio" name="importance" id="highly important" value="Highly Important">Highly Important</input> </br> <input type="radio" name="importance" id="important" value="Important">Important</input> </br> <input type="radio" name="importance" id="can wait" value="Can Wait">Can Wait</input> </br> <p>Date Assigned <input type="text" name="date" id="date" /></p> <p>Time Assigned <input type="text" name="time" id="time" /></p> <input type="submit" id="submit task" value="Submit Task" /> </fieldset> </form> </td> <td width="50%" height="100%"> <iframe width="100%" height="100%" src="viewTasks.php"> </iframe> </td></tr></table></body></html>
insert.php
<html><body><?php$con = mysql_connect('localhost', 'root', '');if(!$con){die('Could not connect: ' . mysql_error());}mysql_select_db('tasks', $con);$sql = "INSERT INTO tasks.taskstable (task, importance, dateAssigned, timeAssigned) VALUES ('$_POST[task]', '$_POST[importance]', '$_POST[date]', '$_POST[time]')";if(!mysql_query($sql, $con)){die('Error: ' . mysql_error());}echo "1 record added";mysql_close($con);?><form method="link" action="index.html"><input type="Submit" value="Return" /></form></body></html>
viewTasks.php
<html><body><?php$con = mysql_connect("localhost", "root", "");if(!$con){die('Could not connectL ' . mysql_error());}mysql_select_db("tasks", $con);$result = mysql_query("SELECT * FROM tasks.taskstable");if(!$result){die('Invalid query: ' . mysql_error());}echo "<table border='1' width='100%'><tr><th width='40%'>Task</th><th width='20%'>Importance</th><th width='20%'>Date Assigned</th><th width='20%'>Time Assigned</th></tr>";while($row = mysql_fetch_array($result));{echo "<tr>";echo "<td>" . $row['task'] . "</td>";echo "<td>" . $row['importance'] . "</td>";echo "<td>" . $row['dateAssigned'] . "</td>";echo "<td>" . $row['timeAssigned'] . "</td>";echo "</tr>";}mysql_close($con);?></body></html>
connect.php (first time use)
<html><body><?php$conn=mysql_connect('localhost','root','');if(!$conn){die('Could not connect: ' . mysql_error());}if(mysql_query("CREATE DATABASE tasks", $conn)){echo "Database Created";}else{echo "Error creating database: " . mysql_error();}mysql_select_db("tasks", $conn);$sql = "CREATE TABLE tasksTable(taskNumber int NOT NULL AUTO_INCREMENT,PRIMARY KEY(taskNumber),task Text,importance Text,dateAssigned Text,timeAssigned Text)";mysql_query($sql, $conn);mysql_close($conn);?><script language="javascript">function redirect () { setTimeout("go_now()",10000);}function go_no() { window.location.href = "index.html"}</script></body></html>
-
PHP Database
in PHP
Yeah, the error handeling is still there, but i get no errors. I added a return button to return back to index.html which is where an iframe pulls the viewTasks.php via src. <iframe width="100%" height="100%" src="viewTasks.php"> </iframe> Could it be that?
-
PHP Database
in PHP
I've followed the examples step by step. insert.php mysql_select_db('tasks', $con);$sql = "INSERT INTO tasks.taskstable (task, importance, dateAssigned, timeAssigned) VALUES ('$_POST[task]', '$_POST[importance]', '$_POST[date]', '$_POST[time]')"; viewTasks.php mysql_select_db("tasks", $con);$result = mysql_query("SELECT * FROM tasks.taskstable");while($row = mysql_fetch_array($result));{ echo "<tr>"; echo "<td>" . $row['task'] . "</td>"; echo "<td>" . $row['importance'] . "</td>"; echo "<td>" . $row['dateAssigned'] . "</td>"; echo "<td>" . $row['timeAssigned'] . "</td>"; echo "</tr>";} But the viewTasks does not work. it is empty still.
-
PHP Database
in PHP
$con = mysql_connect("localhost", "root", "");Post the updated code for that.
Yeah, i noticed that as well, so i fixed it. It is tasksTable.from your previous post, the names of the tables were different
will $result = mysql_query("SELECT * FROM tasks.db.tasksTable"); work?You could specify to get a certain field in a certain table in a certain database like this: SELECT database_name.table_name.field_name FROM ... -
PHP Database
in PHP
Okay, it was the username/password. So the database is created db.opt and the table, taskstable.frm. I got one record added, but the taskView.php does not show the records.
-
PHP Database
in PHP
Okay, what do i do? Just take the .mdb off? I think my error was in that my html was not opening/calling the connect.php, which would make it to where the database is not created. But now i am getting an error where i cannot create the database. Error creating database: Access denied for user ''@'localhost' to database 'tasks' Do i need to be the admin of the computer?You use the mysql extension to connect to a MySQL database, not an Access database. -
PHP Database
in PHP
As far as i know, i've done everything correctly. Nothing looks wrong. The code for connecting/creating the database. (connect.php)
<html><body><?php$conn=mysql_connect('localhost','','');if(!$conn){die('Could not connect: ' . mysql_error());}if(mysql_query("CREATE DATABASE tasks", $conn)){echo "Database Created";}else{echo "Error creating database: " . mysql_error();}mysql_select_db("tasks.mdb", $conn);$sql = "CREATE TABLE tasksTable(taskNumber int NOT NULL AOUT_INCREMENT,PRIMARY KEY(taskNumber),task Text,importance Text,dateAssigned Text,timeAssigned Text)";mysql_query($sql, $conn);mysql_close($conn);?></body></html>
Code for the insert (insert.php)
<html><body><?php$con = mysql_connect('localhost', '', '');if(!$con){die('Could not connect: ' . mysql_error());}mysql_select_db('tasks.mdb', $con);$sql = "INSERT INTO taskTable (Task, Importance, DateAssigned, TimeAssigned) VALUES ('$_POST[task]', '$_POST[importance]', '$_POST[date]', '$_POST[time]')";if(!mysql_query($sql, $con)){die('Error: ' . mysql_error());}echo "1 record added";mysql_close($con);?></body></html>
Code for viewing the database (viewTasks.php)
<html><body><?php$con = mysql_connect("localhost", "", "");if(!$con){die('Could not connectL ' . mysql_error());}mysql_select_db("tasks.mdb", $con);$result = mysql_query("SELECT * FROM tasksTable");echo "<table border='1' width='100%'><tr><th width='40%'>Task</th><th width='20%'>Importance</th><th width='20%'>Date Assigned</th><th width='20%'>Time Assigned</th></tr>";while($row = mysql_fetch_array($result));{echo "<tr>";echo "<td>" . $row['Task'] . "</td>";echo "<td>" . $row['Importance'] . "</td>";echo "<td>" . $row['DateAssigned'] . "</td>";echo "<td>" . $row['TimeAssigned'] . "</td>";echo "</tr>";}mysql_close($con);?></body></html>
If there is something wrong with the code, then i can not see where it is at. line 29 should work, but as I read from the topic you posted, the $result will return a boolean of false when it does not connect, which can cause the boolean error.
-
PHP Database
in PHP
in the insert.php, i get the error on line 29 Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given. In the function call is $result which is equal to mysql_query("SELECT * FROM tasksTable"); Also, when submitting a task via submit button, it pulls an error stating that no database is selected, even though the code should be selecting one (found in insert.php). Now the connec.php work fine, as far as i know. It gives me no errors.
-
PHP Database
in PHP
Hello all, I'd like to thank thescientist and niche for the help they gave me on my first help topic. I am now here asking in the PHP side of things of how i can get php to connect to a .mdb (MS Access Database), use that to input text, save, and display. Here is my html source:
<html><head><title>Tasks to Complete</title></head><body><table border="1" width="100%" height="100%"><tr width="100%" height="10%"> <td colspan="2" height="10%"> <h2 align="center">Welcome to the Task List</h2> </td></tr><tr width="100%" height="90%"> <td width="50%" height="100%"> <form action="insert.php" method="post"> <fieldset> <legend>Insert Tasks Here:</legend> <textarea rows="15" cols="50" name="task"></textarea> </br> </br> <input type="radio" name="importance" id="highly important" value="Highly Important">Highly Important</input> </br> <input type="radio" name="importance" id="important" value="Important">Important</input> </br> <input type="radio" name="importance" id="can wait" value="Can Wait">Can Wait</input> </br> <p>Date Assigned <input type="text" name="date" id="date" /></p> <p>Time Assigned <input type="text" name="time" id="time" /></p> <input type="submit" id="submit task" value="Submit Task" /> </fieldset> </form> </td> <td width="50%" height="100%"> <iframe width="100%" height="100%" src="viewTasks.php"> </iframe> </td></tr></table></body></html>
I tried to use mysql in php, but it did not work. The three attached files are the php i have created so far in trying to get a mysql database. If it can work, i'll stick with the php files, other wise, i'll need some help in trying to get connected to a .mdb file. Thanks, -ProSpartan
-
Okay, that fixed that problem. I'll start a new thread then, for database connections. But before i do, i guess i should search for existing ones on this forum.
-
Okay, i've started a php file to create a database, but i get an error. MySQL Error: Error creating database: Access denied for user ''@'localhost' to database 'tasks' Do I need to have admin rights?
-
Okay, i just fixed it. I had to use, in the input type for radio, the value="name" for it to work.
-
okay, i used a windows box and installed EasyPHP, which seems to work. Although, the output from the php on the task input adds "on" right after. I think that is the radio button. Not sure how to fix that to display the id or name.
-
I will try and see about getting someone who can download things and get it on my RedHat.Why not just do the WAMP that was suggested earlier? -
There are files for apache, which should be installed.
-
it seems as though php does not work on red hat 6.0. Does anyone know how to get it running? I had installed all of the packages from the disk.
-
Okay, there must be something wrong with my computers php. it does not want to view variables. I'll look into this.
VBScript MS-Word Find & Replace Char for Addin Fields
in VBScript
Posted
Yes, i have seen that page already. It did work, if I remember correctly when I used it, but the program needs to find a specific char, "@", and replace it with the addin field { SEQ }.